From 4f476793b914c5319556eb2132b3adced4d9f96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Sat, 15 Oct 2022 22:51:50 +0900 Subject: [PATCH 01/27] Handle more literals --- .../src/compress/optimize/sequences.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index e21b2c224272..5cabeab86524 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -1665,6 +1665,16 @@ where }; if !self.is_skippable_for_seq(Some(a), &Expr::Ident(b_left.clone())) { + if is_trivial_lit(&b_assign.right) { + // As we are not *skipping* lhs, we can inline here + if let Some(a_id) = a.id() { + if a_id == b_left.to_id() { + if self.replace_seq_assignment(a, b)? { + return Ok(true); + } + } + } + } return Ok(false); } @@ -2224,8 +2234,8 @@ where .unwrap_or_else(|| undefined(DUMMY_SP)) } Mergable::Expr(a) => { - if can_remove { - if let Expr::Assign(e) = a { + if can_remove || $force_drop { + if let Expr::Assign(e @ AssignExpr { op: op!("="), .. }) = a { report_change!( "sequences: Dropping assignment as we are going to drop the \ variable declaration. ({})", From 7aa2c8e8b583c7300dbe09203343b8c7eb27748a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Sat, 15 Oct 2022 22:52:56 +0900 Subject: [PATCH 02/27] Fix test inputs --- .../tests/pass-1/compute/1/input.js | 22 +++++++++++-------- .../tests/pass-default/compute/1/input.js | 22 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/crates/swc_ecma_minifier/tests/pass-1/compute/1/input.js b/crates/swc_ecma_minifier/tests/pass-1/compute/1/input.js index 881e2edf89fe..2d9b8de32de5 100644 --- a/crates/swc_ecma_minifier/tests/pass-1/compute/1/input.js +++ b/crates/swc_ecma_minifier/tests/pass-1/compute/1/input.js @@ -1,9 +1,13 @@ -console.log((function () { - var a = [ - 94, - 173, - 190, - 239 - ], b = 0; - return b |= 94, b <<= 8, b |= 173, b <<= 8, b |= 190, b <<= 8, b |= 239; -})().toString(16)); \ No newline at end of file +function f() { + var a = [94, 173, 190, 239]; + var b = 0; + b |= a[0]; + b <<= 8; + b |= a[1]; + b <<= 8; + b |= a[2]; + b <<= 8; + b |= a[3]; + return b; +} +console.log(f().toString(16)); \ No newline at end of file diff --git a/crates/swc_ecma_minifier/tests/pass-default/compute/1/input.js b/crates/swc_ecma_minifier/tests/pass-default/compute/1/input.js index 881e2edf89fe..2d9b8de32de5 100644 --- a/crates/swc_ecma_minifier/tests/pass-default/compute/1/input.js +++ b/crates/swc_ecma_minifier/tests/pass-default/compute/1/input.js @@ -1,9 +1,13 @@ -console.log((function () { - var a = [ - 94, - 173, - 190, - 239 - ], b = 0; - return b |= 94, b <<= 8, b |= 173, b <<= 8, b |= 190, b <<= 8, b |= 239; -})().toString(16)); \ No newline at end of file +function f() { + var a = [94, 173, 190, 239]; + var b = 0; + b |= a[0]; + b <<= 8; + b |= a[1]; + b <<= 8; + b |= a[2]; + b <<= 8; + b |= a[3]; + return b; +} +console.log(f().toString(16)); \ No newline at end of file From 679d49a2ebe75c21fde95dceae4e07bc89a0fddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 17 Oct 2022 09:44:39 +0900 Subject: [PATCH 03/27] inline more / run expression simplifier --- .../src/compress/optimize/inline.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs index d5e5f7876cde..97f978e6593e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs @@ -1,7 +1,9 @@ use swc_atoms::js_word; use swc_common::{util::take::Take, EqIgnoreSpan, Spanned}; use swc_ecma_ast::*; +use swc_ecma_transforms_optimization::simplify::expr_simplifier; use swc_ecma_utils::{class_has_side_effect, find_pat_ids, ExprExt}; +use swc_ecma_visit::VisitMutWith; use super::Optimizer; use crate::{ @@ -680,6 +682,25 @@ where /// Actually inlines variables. pub(super) fn inline(&mut self, e: &mut Expr) { + if let Expr::Member(me) = e { + if let MemberProp::Computed(ref mut prop) = me.prop { + if let Expr::Lit(Lit::Num(..)) = &*prop.expr { + if let Expr::Ident(obj) = &*me.obj { + let new = self.vars.lits_for_array_access.get(&obj.to_id()); + + if let Some(new) = new { + me.obj = new.clone(); + e.visit_mut_with(&mut expr_simplifier( + self.marks.unresolved_mark, + Default::default(), + )); + } + return; + } + } + } + } + if let Expr::Ident(i) = e { let id = i.to_id(); if let Some(value) = self From 33848a7c9d2dc933cdd873109f901e62361b8434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 17 Oct 2022 09:45:50 +0900 Subject: [PATCH 04/27] TODO --- crates/swc_ecma_minifier/src/compress/optimize/inline.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs index 97f978e6593e..f5290475aae0 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs @@ -690,6 +690,8 @@ where if let Some(new) = new { me.obj = new.clone(); + // TODO(kdy1): Optimize performance by skipping visiting of children + // nodes. e.visit_mut_with(&mut expr_simplifier( self.marks.unresolved_mark, Default::default(), From dbe3e78f68313ce9b2b74627b01569a778f1c517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 17 Oct 2022 11:47:06 +0900 Subject: [PATCH 05/27] Track changes --- crates/swc_ecma_minifier/src/compress/optimize/inline.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs index f5290475aae0..d4749599b1e0 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/inline.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/inline.rs @@ -689,6 +689,9 @@ where let new = self.vars.lits_for_array_access.get(&obj.to_id()); if let Some(new) = new { + report_change!("inline: Inlined array access"); + self.changed = true; + me.obj = new.clone(); // TODO(kdy1): Optimize performance by skipping visiting of children // nodes. From 4d74cc631ba1a45c891b12172df6674565ee1946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 09:39:07 +0900 Subject: [PATCH 06/27] Revert --- .../src/compress/optimize/sequences.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index 5cabeab86524..21d2ee75c275 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -1665,16 +1665,6 @@ where }; if !self.is_skippable_for_seq(Some(a), &Expr::Ident(b_left.clone())) { - if is_trivial_lit(&b_assign.right) { - // As we are not *skipping* lhs, we can inline here - if let Some(a_id) = a.id() { - if a_id == b_left.to_id() { - if self.replace_seq_assignment(a, b)? { - return Ok(true); - } - } - } - } return Ok(false); } From 6a0dfc3d3e03cc550a684b391a523198d098f24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 09:41:14 +0900 Subject: [PATCH 07/27] Fix --- .../src/compress/optimize/sequences.rs | 80 ++++++++++++++----- 1 file changed, 58 insertions(+), 22 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index 21d2ee75c275..63b229581225 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -1665,6 +1665,20 @@ where }; if !self.is_skippable_for_seq(Some(a), &Expr::Ident(b_left.clone())) { + // Let's be safe + if IdentUsageFinder::find(&b_left.to_id(), &b_assign.right) { + return Ok(false); + } + + // As we are not *skipping* lhs, we can inline here + if let Some(a_id) = a.id() { + if a_id == b_left.to_id() { + if self.replace_seq_assignment(a, b)? { + return Ok(true); + } + } + } + return Ok(false); } @@ -2202,7 +2216,7 @@ where } macro_rules! take_a { - ($force_drop:expr) => { + ($force_drop:expr, $drop_op:expr) => { match a { Mergable::Var(a) => { if self.options.unused { @@ -2225,14 +2239,16 @@ where } Mergable::Expr(a) => { if can_remove || $force_drop { - if let Expr::Assign(e @ AssignExpr { op: op!("="), .. }) = a { - report_change!( - "sequences: Dropping assignment as we are going to drop the \ - variable declaration. ({})", - left_id - ); - - **a = *e.right.take(); + if let Expr::Assign(e) = a { + if e.op == op!("=") || $drop_op { + report_change!( + "sequences: Dropping assignment as we are going to drop \ + the variable declaration. ({})", + left_id + ); + + **a = *e.right.take(); + } } } @@ -2256,7 +2272,10 @@ where Expr::Assign(b @ AssignExpr { op: op!("="), .. }) => { if let Some(b_left) = b.left.as_ident() { if b_left.to_id() == left_id.to_id() { - let mut a_expr = take_a!(true); + report_change!("sequences: Merged assignment into another assignment"); + self.changed = true; + + let mut a_expr = take_a!(true, false); let a_expr = self.ignore_return_value(&mut a_expr); if let Some(a) = a_expr { @@ -2271,19 +2290,28 @@ where } Expr::Assign(b) => { if let Some(b_left) = b.left.as_ident() { - if b_left.to_id() == left_id.to_id() { - if let Some(bin_op) = b.op.to_update() { - b.op = op!("="); + if let Mergable::Expr(Expr::Assign(AssignExpr { op: a_op, .. })) = a { + if can_drop_op_for(*a_op, b.op) { + if b_left.to_id() == left_id.to_id() { + if let Some(bin_op) = b.op.to_update() { + report_change!( + "sequences: Merged assignment into another (op) assignment" + ); + self.changed = true; - let to = take_a!(true); + b.op = op!("="); - b.right = Box::new(Expr::Bin(BinExpr { - span: DUMMY_SP, - op: bin_op, - left: to, - right: b.right.take(), - })); - return Ok(true); + let to = take_a!(true, true); + + b.right = Box::new(Expr::Bin(BinExpr { + span: DUMMY_SP, + op: bin_op, + left: to, + right: b.right.take(), + })); + return Ok(true); + } + } } } } @@ -2319,7 +2347,7 @@ where left_id.span.ctxt ); - let to = take_a!(false); + let to = take_a!(false, false); replace_id_with_expr(b, left_id.to_id(), to); @@ -2449,3 +2477,11 @@ pub(crate) fn is_trivial_lit(e: &Expr) -> bool { _ => false, } } + +/// This assumes `a.left.to_id() == b.left.to_id()` +fn can_drop_op_for(a: AssignOp, b: AssignOp) -> bool { + match (a, b) { + (op!("+="), op!("+=")) => true, + _ => false, + } +} From 5b106143ac6e59ee3a6928ad429066ac6d148630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 09:42:04 +0900 Subject: [PATCH 08/27] can_drop_op_for --- .../swc_ecma_minifier/src/compress/optimize/sequences.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index 63b229581225..a99560c2785b 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -2480,8 +2480,9 @@ pub(crate) fn is_trivial_lit(e: &Expr) -> bool { /// This assumes `a.left.to_id() == b.left.to_id()` fn can_drop_op_for(a: AssignOp, b: AssignOp) -> bool { - match (a, b) { - (op!("+="), op!("+=")) => true, - _ => false, + if a == b { + return matches!(a, op!("+=") | op!("-=")); } + + false } From 2e30b68d2183b1101dd2d6fadb2a2a66aec2e630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 09:46:08 +0900 Subject: [PATCH 09/27] Update test refs --- ...onAssignmentLHSCanBeAssigned.2.minified.js | 4 ++-- ...ssignmentWithInvalidOperands.2.minified.js | 4 ++-- .../destructuringControlFlow.2.minified.js | 4 ++-- .../tsc-references/symbolType12.2.minified.js | 2 +- .../tests/benches-full/echarts.js | 4 ++-- .../tests/benches-full/moment.js | 2 +- .../tests/benches-full/terser.js | 2 +- .../tests/fixture/issues/5280/output.js | 3 ++- .../fixture/issues/firebase-core/1/output.js | 2 +- .../issues/firebase-firestore/1/output.js | 2 +- .../tests/fixture/issues/moment/1/output.js | 2 +- .../d6e1aeb5-38a8d7ae57119c23/output.js | 11 ++++++---- .../pages/index-cb36c1bf7f830e3c/output.js | 2 +- .../fixture/next/react-pdf-renderer/output.js | 2 +- .../syncfusion/933-e9f9a6bf671b96fc/output.js | 4 ++-- .../fixture/next/wrap-contracts/output.js | 20 +++++++++---------- .../full/issue-5912-bigdecimal/output.js | 1 + .../tests/pass-1/1/output.js | 4 +++- .../tests/pass-1/compute/1/output.js | 9 +++++++-- .../tests/pass-default/compute/1/output.js | 4 ++-- .../projects/output/jquery.mobile-1.4.2.js | 2 +- .../tests/projects/output/react-dom-17.0.2.js | 2 +- 22 files changed, 52 insertions(+), 40 deletions(-) diff --git a/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.2.minified.js b/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.2.minified.js index 3af0914af4e1..6cb14ad63d3e 100644 --- a/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.2.minified.js +++ b/crates/swc/tests/tsc-references/compoundAdditionAssignmentLHSCanBeAssigned.2.minified.js @@ -1,5 +1,5 @@ //// [compoundAdditionAssignmentLHSCanBeAssigned.ts] -var E, a, b, x1, x2, x3, x4, x6; +var E; !function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), x1 += a, x1 += b, x1 += !0, x1 += 0, x1 += "", x1 += E.a, x1 += {}, x1 += null, x1 += void 0, x2 += a, x2 += b, x2 += !0, x2 += 0, x2 += "", x2 += E.a, x2 += {}, x2 += null, x2 += void 0, x3 += a, x3 += 0, x3 += E.a, x3 += null, x3 += void 0, x4 += a, x4 += 0, x4 += E.a, x4 += null, x4 += void 0, x6 += a, x6 += ""; +}(E || (E = {})), E.a, E.a, E.a, E.a; diff --git a/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.2.minified.js b/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.2.minified.js index 8febd7177d3c..dc4a5cc26f98 100644 --- a/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.2.minified.js +++ b/crates/swc/tests/tsc-references/compoundAdditionAssignmentWithInvalidOperands.2.minified.js @@ -1,5 +1,5 @@ //// [compoundAdditionAssignmentWithInvalidOperands.ts] -var E, a, x1, x2, x3, x4, x5; +var E; !function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), x1 += a, x1 += !0, x1 += 0, x1 += E.a, x1 += {}, x1 += null, x1 += void 0, x2 += a, x2 += !0, x2 += 0, x2 += E.a, x2 += {}, x2 += null, x2 += void 0, x3 += a, x3 += !0, x3 += 0, x3 += E.a, x3 += {}, x3 += null, x3 += void 0, x4 += a, x4 += !0, x4 += {}, x5 += a, x5 += !0, x5 += {}; +}(E || (E = {})), E.a, E.a, E.a; diff --git a/crates/swc/tests/tsc-references/destructuringControlFlow.2.minified.js b/crates/swc/tests/tsc-references/destructuringControlFlow.2.minified.js index 85ea1db5a1e6..5e5396f223a8 100644 --- a/crates/swc/tests/tsc-references/destructuringControlFlow.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringControlFlow.2.minified.js @@ -1,4 +1,4 @@ //// [destructuringControlFlow.ts] -(0, [ +[ "foo" -][1]).toUpperCase(); +][1].toUpperCase(); diff --git a/crates/swc/tests/tsc-references/symbolType12.2.minified.js b/crates/swc/tests/tsc-references/symbolType12.2.minified.js index 34d7e405cac3..6edefe0d09e6 100644 --- a/crates/swc/tests/tsc-references/symbolType12.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolType12.2.minified.js @@ -1,3 +1,3 @@ //// [symbolType12.ts] var s = Symbol.for("assign"), str = ""; -s *= s, s *= 0, s /= s, s /= 0, s %= s, s %= 0, s += s, s += 0, s += "", str += s, s -= s, s -= 0, s <<= s, s <<= 0, s >>= s, s >>= 0, s >>>= s, s >>>= 0, s &= s, s &= 0, s ^= s, s ^= 0, s |= s, s |= 0, str += s || str; +s *= s, s *= 0, s /= s, s /= 0, s %= s, s %= 0, str += s = "0", s -= 0, s <<= s, s <<= 0, s >>= s, s >>= 0, s >>>= s, s >>>= 0, s &= s, s &= 0, s ^= s, s ^= 0, s |= s, s |= 0, str += s || str; diff --git a/crates/swc_ecma_minifier/tests/benches-full/echarts.js b/crates/swc_ecma_minifier/tests/benches-full/echarts.js index 0f86dca9d4c3..61e060ea4ec3 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/echarts.js +++ b/crates/swc_ecma_minifier/tests/benches-full/echarts.js @@ -5298,7 +5298,7 @@ var width = data[i++], height = data[i++]; if (x1 = x0 + width, y1 = y0 + height, isStroke) { if (containStroke(x0, y0, x1, y0, lineWidth, x, y) || containStroke(x1, y0, x1, y1, lineWidth, x, y) || containStroke(x1, y1, x0, y1, lineWidth, x, y) || containStroke(x0, y1, x0, y0, lineWidth, x, y)) return !0; - } else w += windingLine(x1, y0, x1, y1, x, y), w += windingLine(x0, y1, x0, y0, x, y); + } else w = windingLine(x1, y0, x1, y1, x, y) + windingLine(x0, y1, x0, y0, x, y); break; case CMD$1.Z: if (isStroke) { @@ -34777,7 +34777,7 @@ var blockMetaList = result1.meta, buttonContainer = document.createElement('div'); buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;'; var buttonStyle = "float:right;margin-right:20px;border:none;cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px", closeButton = document.createElement('div'), refreshButton = document.createElement('div'); - buttonStyle += ';background-color:' + model.get('buttonColor'), buttonStyle += ';color:' + model.get('buttonTextColor'); + buttonStyle = ';background-color:' + model.get('buttonColor') + ';color:' + model.get('buttonTextColor'); var self1 = this; function close() { container.removeChild(root), self1._dom = null; diff --git a/crates/swc_ecma_minifier/tests/benches-full/moment.js b/crates/swc_ecma_minifier/tests/benches-full/moment.js index 65762db554b4..84b6cfb9b255 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/moment.js +++ b/crates/swc_ecma_minifier/tests/benches-full/moment.js @@ -799,7 +799,7 @@ getParsingFlags(config).invalidFormat = !0, config._d = new Date(NaN); return; } - for(i = 0; i < config._f.length; i++)currentScore = 0, validFormatFound = !1, tempConfig = copyConfig({}, config), null != config._useUTC && (tempConfig._useUTC = config._useUTC), tempConfig._f = config._f[i], configFromStringAndFormat(tempConfig), isValid(tempConfig) && (validFormatFound = !0), currentScore += getParsingFlags(tempConfig).charsLeftOver, currentScore += 10 * getParsingFlags(tempConfig).unusedTokens.length, getParsingFlags(tempConfig).score = currentScore, bestFormatIsValid ? currentScore < scoreToBeat && (scoreToBeat = currentScore, bestMoment = tempConfig) : (null == scoreToBeat || currentScore < scoreToBeat || validFormatFound) && (scoreToBeat = currentScore, bestMoment = tempConfig, validFormatFound && (bestFormatIsValid = !0)); + for(i = 0; i < config._f.length; i++)currentScore = 0, validFormatFound = !1, tempConfig = copyConfig({}, config), null != config._useUTC && (tempConfig._useUTC = config._useUTC), tempConfig._f = config._f[i], configFromStringAndFormat(tempConfig), isValid(tempConfig) && (validFormatFound = !0), currentScore = getParsingFlags(tempConfig).charsLeftOver + 10 * getParsingFlags(tempConfig).unusedTokens.length, getParsingFlags(tempConfig).score = currentScore, bestFormatIsValid ? currentScore < scoreToBeat && (scoreToBeat = currentScore, bestMoment = tempConfig) : (null == scoreToBeat || currentScore < scoreToBeat || validFormatFound) && (scoreToBeat = currentScore, bestMoment = tempConfig, validFormatFound && (bestFormatIsValid = !0)); extend(config, bestMoment || tempConfig); }(config) : format ? configFromStringAndFormat(config) : isUndefined(input = (config1 = config)._i) ? config1._d = new Date(hooks.now()) : isDate(input) ? config1._d = new Date(input.valueOf()) : 'string' == typeof input ? function(config) { var matched = aspNetJsonRegex.exec(config._i); diff --git a/crates/swc_ecma_minifier/tests/benches-full/terser.js b/crates/swc_ecma_minifier/tests/benches-full/terser.js index 4e40d19e1364..0f8d8b800dae 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/terser.js +++ b/crates/swc_ecma_minifier/tests/benches-full/terser.js @@ -1912,7 +1912,7 @@ base && base.PROPS && (props = props.concat(base.PROPS)); for(var code = "return function AST_" + type + "(props){ if (props) { ", i = props.length; --i >= 0;)code += "this." + props[i] + " = props." + props[i] + ";"; const proto = base && Object.create(base.prototype); - (proto && proto.initialize || methods && methods.initialize) && (code += "this.initialize();"), code += "}", code += "this.flags = 0;"; + (proto && proto.initialize || methods && methods.initialize) && (code += "this.initialize();"), code = "}this.flags = 0;"; var ctor = Function(code += "}")(); if (proto && (ctor.prototype = proto, ctor.BASE = base), base && base.SUBCLASSES.push(ctor), ctor.prototype.CTOR = ctor, ctor.prototype.constructor = ctor, ctor.PROPS = props || null, ctor.SELF_PROPS = self_props, ctor.SUBCLASSES = [], type && (ctor.prototype.TYPE = ctor.TYPE = type), methods) for(i in methods)HOP(methods, i) && ("$" === i[0] ? ctor[i.substr(1)] = methods[i] : ctor.prototype[i] = methods[i]); return ctor.DEFMETHOD = function(name, method) { diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/5280/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/5280/output.js index b0173968afac..0f7b8a6d5db0 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/5280/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/5280/output.js @@ -1,3 +1,4 @@ export function source() { - console.log(6, 1, 1); + let c = 0, a = 1; + console.log(a += 5, c += 1, c); } 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 289ca0671d5e..2fede38b1aec 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 @@ -1287,7 +1287,7 @@ d = !0; } d || (b1 = "", xa(c, function(c, d) { - b1 += d, b1 += ":", b1 += c, b1 += "\r\n"; + b1 = d + ":", b1 = c + "\r\n"; }), c = b1, "string" == typeof a ? null != c && encodeURIComponent(String(c)) : R(a, b, c)); } function Hd(a, b, c) { 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 b6397311e62e..30836716d8ad 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 @@ -838,7 +838,7 @@ const e = t; if (null === e.A) { let t1 = e.path.canonicalString(); - null !== e.collectionGroup && (t1 += "|cg:" + e.collectionGroup), t1 += "|f:", t1 += e.filters.map((t)=>t.field.canonicalString() + t.op.toString() + xt(t.value)).join(","), t1 += "|ob:", t1 += e.orderBy.map((t)=>t.field.canonicalString() + t.dir).join(","), At(e.limit) || (t1 += "|l:", t1 += e.limit), e.startAt && (t1 += "|lb:", t1 += ce(e.startAt)), e.endAt && (t1 += "|ub:", t1 += ce(e.endAt)), e.A = t1; + null !== e.collectionGroup && (t1 += "|cg:" + e.collectionGroup), t1 = "|f:" + e.filters.map((t)=>t.field.canonicalString() + t.op.toString() + xt(t.value)).join(","), t1 = "|ob:" + e.orderBy.map((t)=>t.field.canonicalString() + t.dir).join(","), At(e.limit) || (t1 = "|l:" + e.limit), e.startAt && (t1 = "|lb:" + ce(e.startAt)), e.endAt && (t1 = "|ub:" + ce(e.endAt)), e.A = t1; } return e.A; } 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 e073acc00204..64f34e892c8f 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 @@ -799,7 +799,7 @@ getParsingFlags(config).invalidFormat = !0, config._d = new Date(NaN); return; } - for(i = 0; i < config._f.length; i++)currentScore = 0, validFormatFound = !1, tempConfig = copyConfig({}, config), null != config._useUTC && (tempConfig._useUTC = config._useUTC), tempConfig._f = config._f[i], configFromStringAndFormat(tempConfig), isValid(tempConfig) && (validFormatFound = !0), currentScore += getParsingFlags(tempConfig).charsLeftOver, currentScore += 10 * getParsingFlags(tempConfig).unusedTokens.length, getParsingFlags(tempConfig).score = currentScore, bestFormatIsValid ? currentScore < scoreToBeat && (scoreToBeat = currentScore, bestMoment = tempConfig) : (null == scoreToBeat || currentScore < scoreToBeat || validFormatFound) && (scoreToBeat = currentScore, bestMoment = tempConfig, validFormatFound && (bestFormatIsValid = !0)); + for(i = 0; i < config._f.length; i++)currentScore = 0, validFormatFound = !1, tempConfig = copyConfig({}, config), null != config._useUTC && (tempConfig._useUTC = config._useUTC), tempConfig._f = config._f[i], configFromStringAndFormat(tempConfig), isValid(tempConfig) && (validFormatFound = !0), currentScore = getParsingFlags(tempConfig).charsLeftOver + 10 * getParsingFlags(tempConfig).unusedTokens.length, getParsingFlags(tempConfig).score = currentScore, bestFormatIsValid ? currentScore < scoreToBeat && (scoreToBeat = currentScore, bestMoment = tempConfig) : (null == scoreToBeat || currentScore < scoreToBeat || validFormatFound) && (scoreToBeat = currentScore, bestMoment = tempConfig, validFormatFound && (bestFormatIsValid = !0)); extend(config, bestMoment || tempConfig); }(config) : format ? configFromStringAndFormat(config) : isUndefined(input = (config1 = config)._i) ? config1._d = new Date(hooks.now()) : isDate(input) ? config1._d = new Date(input.valueOf()) : "string" == typeof input ? function(config) { var matched = aspNetJsonRegex.exec(config._i); 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 7ad555e435c5..ad20db0abdd3 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 @@ -9364,7 +9364,7 @@ pts: buffer[0].pts, dts: buffer[0].dts }; i < tagSize;)tag.data.set(buffer[0].data.subarray(0, tagSize - i), i), i += buffer[0].data.byteLength, bufferSize -= buffer[0].data.byteLength, buffer.shift(); - frameStart = 10, 0x40 & tag.data[5] && (frameStart += 4, frameStart += parseSyncSafeInteger$1(tag.data.subarray(10, 14)), tagSize -= parseSyncSafeInteger$1(tag.data.subarray(16, 20))); + frameStart = 10, 0x40 & tag.data[5] && (frameStart = 4 + parseSyncSafeInteger$1(tag.data.subarray(10, 14)), tagSize -= parseSyncSafeInteger$1(tag.data.subarray(16, 20))); do { if ((frameSize = parseSyncSafeInteger$1(tag.data.subarray(frameStart + 4, frameStart + 8))) < 1) { this.trigger("log", { @@ -9380,7 +9380,7 @@ var d = frame.data, size = (0x01 & d[3]) << 30 | d[4] << 22 | d[5] << 14 | d[6] << 6 | d[7] >>> 2; size *= 4, size += 0x03 & d[7], frame.timeStamp = size, void 0 === tag.pts && void 0 === tag.dts && (tag.pts = frame.timeStamp, tag.dts = frame.timeStamp), this.trigger("timestamp", frame); } - tag.frames.push(frame), frameStart += 10, frameStart += frameSize; + tag.frames.push(frame), frameStart = 10 + frameSize; }while (frameStart < tagSize) this.trigger("data", tag); } @@ -9920,7 +9920,7 @@ }, parseAacTimestamp: function(packet) { var frameStart, frameSize, frame; - frameStart = 10, 0x40 & packet[5] && (frameStart += 4, frameStart += parseSyncSafeInteger(packet.subarray(10, 14))); + frameStart = 10, 0x40 & packet[5] && (frameStart = 4 + parseSyncSafeInteger(packet.subarray(10, 14))); do { if ((frameSize = parseSyncSafeInteger(packet.subarray(frameStart + 4, frameStart + 8))) < 1) break; if ("PRIV" === String.fromCharCode(packet[frameStart], packet[frameStart + 1], packet[frameStart + 2], packet[frameStart + 3])) { @@ -9933,7 +9933,7 @@ break; } } - frameStart += 10, frameStart += frameSize; + frameStart = 10 + frameSize; }while (frameStart < packet.byteLength) return null; } @@ -10247,6 +10247,9 @@ var result = ""; return result += String.fromCharCode(buffer[0]), result += String.fromCharCode(buffer[1]), result += String.fromCharCode(buffer[2]), result += String.fromCharCode(buffer[3]); }, toUnsigned$2 = bin.toUnsigned, findBox_1 = function findBox(data, path) { + }, parseType$1 = function(buffer) { + return String.fromCharCode(buffer[0]), String.fromCharCode(buffer[1]), String.fromCharCode(buffer[2]) + String.fromCharCode(buffer[3]); + }, toUnsigned$2 = bin.toUnsigned, findBox = function findBox(data, path) { var i, size, type, end, subresults, results = []; if (!path.length) return null; for(i = 0; i < data.byteLength;)size = toUnsigned$2(data[i] << 24 | data[i + 1] << 16 | data[i + 2] << 8 | data[i + 3]), type = parseType_1(data.subarray(i + 4, i + 8)), end = size > 1 ? i + size : data.byteLength, type === path[0] && (1 === path.length ? results.push(data.subarray(i + 8, end)) : (subresults = findBox(data.subarray(i + 8, end), path.slice(1))).length && (results = results.concat(subresults))), i = end; 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 fd14a60344f8..44fcab2173bb 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 @@ -68,7 +68,7 @@ }, BigInt(0)); if (void 0 !== _ref$signed && _ref$signed) { var max = BYTE_TABLE[bytes.length] / BigInt(2) - BigInt(1); - (number = BigInt(number)) > max && (number -= max, number -= max, number -= BigInt(2)); + (number = BigInt(number)) > max && (number = max - max, number -= BigInt(2)); } return Number(number); }, numberToBytes = function(number, _temp2) { diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js index 6870729257f5..59fb776550d9 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js @@ -15868,7 +15868,7 @@ i += "".concat(t[0], " and ").concat(t[1], " arguments"); break; default: - i += t.slice(0, o - 1).join(", "), i += ", and ".concat(t[o - 1], " arguments"); + i = t.slice(0, o - 1).join(", ") + ", and ".concat(t[o - 1], " arguments"); } return "".concat(i, " must be specified"); }, TypeError), e.exports.codes = l; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js b/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js index 69a09cebd80b..db3c61384752 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js @@ -19185,7 +19185,7 @@ }, Toolbar.prototype.itemWidthCal = function(items) { var style, _this = this, width = 0; return [].slice.call((0, ej2_base.td)('.' + CLS_ITEM, items)).forEach(function(el) { - (0, ej2_base.pn)(el) && (style = window.getComputedStyle(el), width += _this.isVertical ? el.offsetHeight : el.offsetWidth, width += parseFloat(_this.isVertical ? style.marginTop : style.marginRight), width += parseFloat(_this.isVertical ? style.marginBottom : style.marginLeft)); + (0, ej2_base.pn)(el) && (style = window.getComputedStyle(el), width = (_this.isVertical ? el.offsetHeight : el.offsetWidth) + parseFloat(_this.isVertical ? style.marginTop : style.marginRight), width += parseFloat(_this.isVertical ? style.marginBottom : style.marginLeft)); }), width; }, Toolbar.prototype.getScrollCntEle = function(innerItem) { var trgClass = this.isVertical ? '.e-vscroll-content' : '.e-hscroll-content'; @@ -23519,7 +23519,7 @@ }); }, ToolbarRenderer.prototype.renderColorPickerDropDown = function(args, item, colorPicker, defaultColor) { var range, _this = this, proxy = this, css = classes.i7 + ' ' + classes.Fs + (this.parent.inlineMode ? ' ' + classes.ZV : ''); - css += ' ' + ('backgroundcolor' === item ? classes.Z8 : classes.UQ), css += ' ' + this.parent.cssClass; + css = ' ' + ('backgroundcolor' === item ? classes.Z8 : classes.UQ) + ' ' + this.parent.cssClass; var content = proxy.parent.createElement('span', { className: classes.uN }), inlineEle = proxy.parent.createElement('span', { diff --git a/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js b/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js index e49902b1363a..0bce540d2d44 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js @@ -636,7 +636,7 @@ isNegNum && (num = -num), assert('number' == typeof num), assert(num < 0x4000000); for(var carry = 0, i = 0; i < this.length; i++){ var w = (0 | this.words[i]) * num, lo = (0x3ffffff & w) + (0x3ffffff & carry); - carry >>= 26, carry += w / 0x4000000 | 0, carry += lo >>> 26, this.words[i] = 0x3ffffff & lo; + carry >>= 26, carry = (w / 0x4000000 | 0) + (lo >>> 26), this.words[i] = 0x3ffffff & lo; } return 0 !== carry && (this.words[i] = carry, this.length++), isNegNum ? this.ineg() : this; }, BN.prototype.muln = function(num) { @@ -7909,7 +7909,7 @@ assert('number' == typeof num), assert(num < 0x4000000); for(var carry = 0, i = 0; i < this.length; i++){ var w = (0 | this.words[i]) * num, lo = (0x3ffffff & w) + (0x3ffffff & carry); - carry >>= 26, carry += w / 0x4000000 | 0, carry += lo >>> 26, this.words[i] = 0x3ffffff & lo; + carry >>= 26, carry = (w / 0x4000000 | 0) + (lo >>> 26), this.words[i] = 0x3ffffff & lo; } return 0 !== carry && (this.words[i] = carry, this.length++), this; }, BN.prototype.muln = function(num) { @@ -13605,15 +13605,15 @@ return al + bl >>> 0; } function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { - var carry, lo = al; - return carry = 0 + ((lo = lo + bl >>> 0) < al ? 1 : 0), carry += (lo = lo + cl >>> 0) < cl ? 1 : 0, ah + bh + ch + dh + (carry += (lo = lo + dl >>> 0) < dl ? 1 : 0) >>> 0; + var carry = 0, lo = al; + return carry = ((lo = lo + bl >>> 0) < al ? 1 : 0) + ((lo = lo + cl >>> 0) < cl ? 1 : 0), ah + bh + ch + dh + (carry += (lo = lo + dl >>> 0) < dl ? 1 : 0) >>> 0; } function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { return al + bl + cl + dl >>> 0; } function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { - var carry, lo = al; - return carry = 0 + ((lo = lo + bl >>> 0) < al ? 1 : 0), carry += (lo = lo + cl >>> 0) < cl ? 1 : 0, carry += (lo = lo + dl >>> 0) < dl ? 1 : 0, ah + bh + ch + dh + eh + (carry += (lo = lo + el >>> 0) < el ? 1 : 0) >>> 0; + var carry = 0, lo = al; + return carry = ((lo = lo + bl >>> 0) < al ? 1 : 0) + ((lo = lo + cl >>> 0) < cl ? 1 : 0), ah + bh + ch + dh + eh + (carry = ((lo = lo + dl >>> 0) < dl ? 1 : 0) + ((lo = lo + el >>> 0) < el ? 1 : 0)) >>> 0; } function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { return al + bl + cl + dl + el >>> 0; @@ -18960,7 +18960,7 @@ let i = 0; for(; i < maximumValuesToStringify - 1; i++){ const tmp = stringifyFnReplacer(i, value, stack, replacer, spacer, indentation); - res += void 0 !== tmp ? tmp : 'null', res += join; + res = (void 0 !== tmp ? tmp : 'null') + join; } const tmp1 = stringifyFnReplacer(i, value, stack, replacer, spacer, indentation); if (res += void 0 !== tmp1 ? tmp1 : 'null', value.length - 1 > maximumBreadth) { @@ -19013,7 +19013,7 @@ let i = 0; for(; i < maximumValuesToStringify - 1; i++){ const tmp = stringifyArrayReplacer(i, value[i], stack, replacer, spacer, indentation); - res += void 0 !== tmp ? tmp : 'null', res += join; + res = (void 0 !== tmp ? tmp : 'null') + join; } const tmp1 = stringifyArrayReplacer(i, value[i], stack, replacer, spacer, indentation); if (res += void 0 !== tmp1 ? tmp1 : 'null', value.length - 1 > maximumBreadth) { @@ -19063,7 +19063,7 @@ let i = 0; for(; i < maximumValuesToStringify - 1; i++){ const tmp = stringifyIndent(i, value[i], stack, spacer, indentation); - res += void 0 !== tmp ? tmp : 'null', res += join; + res = (void 0 !== tmp ? tmp : 'null') + join; } const tmp1 = stringifyIndent(i, value[i], stack, spacer, indentation); if (res += void 0 !== tmp1 ? tmp1 : 'null', value.length - 1 > maximumBreadth) { @@ -19119,7 +19119,7 @@ let i = 0; for(; i < maximumValuesToStringify - 1; i++){ const tmp = stringifySimple(i, value[i], stack); - res += void 0 !== tmp ? tmp : 'null', res += ','; + res = (void 0 !== tmp ? tmp : 'null') + ','; } const tmp1 = stringifySimple(i, value[i], stack); if (res += void 0 !== tmp1 ? tmp1 : 'null', value.length - 1 > maximumBreadth) { diff --git a/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js b/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js index 9610a23d916f..9a7bc4c9eb55 100644 --- a/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js +++ b/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js @@ -1 +1,2 @@ !function(n){if(void 0===t)var t={};if(void 0===e)var e={};if(e.document||(e.document=t),void 0===r)var r={};function i(){}function o(t){var r=e.bigdecimal[t],i=r;if(r.__init__){for(var o in(i=function(){var n=Array.prototype.slice.call(arguments);return r.__init__(n)}).prototype=r.prototype,r)if(r.hasOwnProperty(o)){if("function"==typeof r[o]&&o.match(/_va$/)){var u=o.replace(/_va$/,"");i[u]=function n(){var t=Array.prototype.slice.call(arguments);return n.inner_method(t)},i[u].inner_method=r[o]}else i[o]=r[o]}}var f=i.prototype;for(var o in f)if(f.hasOwnProperty(o)&&"function"==typeof f[o]&&o.match(/_va$/)){var u=o.replace(/_va$/,"");f[u]=function n(){var t=Array.prototype.slice.call(arguments);return n.inner_method.apply(this,[t])},f[u].inner_method=f[o],delete f[o]}n[t]=i}r.userAgent||(r.userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22"),function(){var n,t,o=e,u=o.document,f=o.__gwtStatsEvent?function(n){return o.__gwtStatsEvent(n)}:null,c=o.__gwtStatsSessionId?o.__gwtStatsSessionId:null;function s(){}function a(){}function h(){}function b(){}function l(){}function g(){}function w(){}function d(){}function _(){}function v(){}function m(){}function y(){}function C(){}function S(){}function M(){}function x(){}function B(){}function A(){}function N(){}function I(){}function E(){}function R(){}function O(){}function D(){}function k(){}function L(){}function U(){}function P(){}function Q(){}function T(){nX()}function j(){nZ()}function F(){tD()}function H(){ej()}function $(){ej()}function V(){ej()}function q(){ej()}function G(){ej()}function z(){ej()}function J(){nW()}function K(){nc(this)}function W(){nc(this)}function Z(n){iP(this,n)}function X(n){this.c=n}function Y(n){this.b=n}function nn(n){this.b=n}function nt(n){this.b=n}function ne(n){ej(),this.f=n}function nr(n){ne.call(this,n)}function ni(n){ne.call(this,n)}function no(n){ne.call(this,n)}function nu(n){ne.call(this,n)}function nf(n){ne.call(this,n)}function nc(n){n.b=new C}function ns(){this.b=new C}function na(){na=l,ut=new w}function nh(){nh=l,t=new nY}function nb(n,t){nh(),n[oy]=t}function nl(n,t){nh(),function(n,t){var e,r,i,u,f,c,s,a,h,b;for(f=0,s=i_(n,om,0),c=o;ft?n:t}function n_(n,t){return!rA(n,t)}function nv(n){this.b=new iS(n)}function nm(){this.b=(rj(),uj)}function ny(){this.b=(iB(),u2)}function nC(n,e){var r;nh(),r=t.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tg(n){return nG(n,15)?n:new n1(n)}function tw(){try{null.a()}catch(n){return n}}function td(n){var t;return(t=new N).d=i$+n,t.c=1,t}function tp(n,t){return nF(n)?n.eQ(t):n===t}function t_(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tv(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function tm(n,t,e){return(iH=new M).l=n,iH.m=t,iH.h=e,iH}function ty(n,t){return nT(n)===nT(t)||null!=n&&tp(n,t)}function tC(n,t){throw new nu("Index: "+n+", Size: "+t)}function tS(n,t){if(!n)throw new G;this.f=t,tR(this,n)}function tM(n,t){if(!n)throw new G;this.f=t,tR(this,n)}function tx(n,t,e,r){ez.call(this,n,t,e),ic(this,r)}function tB(n,t){ez.call(this,n,0,n.length),ic(this,t)}function tA(n,t){ez.call(this,t6(n),0,n.length),ic(this,t)}function tN(n){ne.call(this,"String index out of range: "+n)}function tI(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tE(n,t){ry(n.b,n.b,n.e,t.b,t.e),tW(n),n.c=-2}function tR(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=rr(eA(t)))}function tO(){tO=l,ue=[],ur=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new S,ue,ur)}function tD(){uy||(uy=!0,new T,new j,function(){if(nl(ox,i$),o.bigdecimal.BigDecimal)var n=o.bigdecimal.BigDecimal;o.bigdecimal.BigDecimal=ff(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fD?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new ng,nb(this.__gwt_instance,this))});var t=o.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)o.bigdecimal.BigDecimal[p]=n[p];o.bigdecimal.BigDecimal.ROUND_CEILING=2,o.bigdecimal.BigDecimal.ROUND_DOWN=1,o.bigdecimal.BigDecimal.ROUND_FLOOR=3,o.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,o.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,o.bigdecimal.BigDecimal.ROUND_HALF_UP=4,o.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,o.bigdecimal.BigDecimal.ROUND_UP=0,o.bigdecimal.BigDecimal.__init__=ff(function(n){var t=function(n){var t,e;if(iU(),(e=iI(n))==i8)t=new nk(new nq(n[0].toString()));else if("BigInteger number"==e)t=new tS(new nq(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new te(new nq(n[0].toString()),n[1],new iS(n[2].toString()));else if("BigInteger MathContext"==e)t=new n4(new nq(n[0].toString()),new iS(n[1].toString()));else if(e==oS)t=new n2(t6(n[0].toString()));else if("array number number"==e)t=new ez(t6(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tx(t6(n[0].toString()),n[1],n[2],new iS(n[3].toString()));else if("array MathContext"==e)t=new tB(t6(n[0].toString()),new iS(n[1].toString()));else if(e==ok)t=new eu(n[0]);else if(e==oL)t=new ep(n[0],new iS(n[1].toString()));else if(e==oF)t=new Z(n[0].toString());else if("string MathContext"==e)t=new tA(n[0].toString(),new iS(n[1].toString()));else throw new ne("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nL(t)}(n);return nE(t)}),t.abs_va=ff(function(n){return nE(this.__gwt_instance.s(n))}),t.add_va=ff(function(n){return nE(this.__gwt_instance.t(n))}),t.byteValueExact=ff(function(){return this.__gwt_instance.u()}),t.compareTo=ff(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=ff(function(n){return nE(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=ff(function(n){return nE(this.__gwt_instance.x(n))}),t.doubleValue=ff(function(){return this.__gwt_instance.z()}),t.equals=ff(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=ff(function(){return this.__gwt_instance.A()}),t.hashCode=ff(function(){return this.__gwt_instance.hC()}),t.intValue=ff(function(){return this.__gwt_instance.B()}),t.intValueExact=ff(function(){return this.__gwt_instance.C()}),t.max=ff(function(n){return nE(this.__gwt_instance.F(n.__gwt_instance))}),t.min=ff(function(n){return nE(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=ff(function(n){return nE(this.__gwt_instance.H(n))}),t.movePointRight=ff(function(n){return nE(this.__gwt_instance.I(n))}),t.multiply_va=ff(function(n){return nE(this.__gwt_instance.J(n))}),t.negate_va=ff(function(n){return nE(this.__gwt_instance.K(n))}),t.plus_va=ff(function(n){return nE(this.__gwt_instance.L(n))}),t.pow_va=ff(function(n){return nE(this.__gwt_instance.M(n))}),t.precision=ff(function(){return this.__gwt_instance.q()}),t.remainder_va=ff(function(n){return nE(this.__gwt_instance.N(n))}),t.round=ff(function(n){return nE(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=ff(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=ff(function(n){return nE(this.__gwt_instance.Q(n))}),t.setScale_va=ff(function(n){return nE(this.__gwt_instance.R(n))}),t.shortValueExact=ff(function(){return this.__gwt_instance.S()}),t.signum=ff(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=ff(function(){return nE(this.__gwt_instance.T())}),t.subtract_va=ff(function(n){return nE(this.__gwt_instance.U(n))}),t.toBigInteger=ff(function(){return nE(this.__gwt_instance.V())}),t.toBigIntegerExact=ff(function(){return nE(this.__gwt_instance.W())}),t.toEngineeringString=ff(function(){return this.__gwt_instance.X()}),t.toPlainString=ff(function(){return this.__gwt_instance.Y()}),t.toString=ff(function(){return this.__gwt_instance.tS()}),t.ulp=ff(function(){return nE(this.__gwt_instance.Z())}),t.unscaledValue=ff(function(){return nE(this.__gwt_instance.$())}),t.divideAndRemainder_va=ff(function(n){return nR(this.__gwt_instance.w(n))}),t.longValue=ff(function(){return this.__gwt_instance.E()}),t.longValueExact=ff(function(){return this.__gwt_instance.D()}),o.bigdecimal.BigDecimal.valueOf_va=ff(function(n){var t=function(n){var t,e;if(iU(),(e=iI(n))==ok)t=function(n){if(!isFinite(n)||isNaN(n))throw new nw(os);return new Z(i$+n)}(n[0]);else if(e==ok)t=tZ(e3(n[0]));else if(e==oU)t=ek(e3(n[0]),n[1]);else throw new ne("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nL(t)}(n);return nE(t)}),o.bigdecimal.BigDecimal.log=ff(function(n){iU(),typeof console!==oH&&console.log&&console.log(n)}),o.bigdecimal.BigDecimal.logObj=ff(function(n){iU(),typeof console!==oH&&console.log&&typeof JSON!==oH&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),o.bigdecimal.BigDecimal.ONE=ff(function(){var n=(iU(),new nL(ug));return nE(n)}),o.bigdecimal.BigDecimal.TEN=ff(function(){var n=(iU(),new nL(uw));return nE(n)}),o.bigdecimal.BigDecimal.ZERO=ff(function(){var n=(iU(),new nL(ud));return nE(n)}),nC(fD,o.bigdecimal.BigDecimal)}())}function tk(n,t,e){var r;return(r=new N).d=n+t,r.c=4,r.b=e,r}function tL(n,t,e,r,i){var o;return tJ(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tN(e)}(n.length,t,r),t4(n,t,r)}function tP(n,t){return ib(),t=n.c.c)throw new z;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tC(r,i),t.b[e]}function tj(n,t){return!!nG(t,1)&&String(n)==t}function tF(){ne.call(this,"Add not supported on this collection")}function tH(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function t$(n,t){rK(),this.f=n,this.e=1,this.b=tJ(fd,{6:1},-1,[t])}function tV(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tq(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tG(n,t,e,r){var i,o;return null==t&&(t=oD),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tz(n,t,e,r){var i;return ry(i=tL(fd,{6:1},-1,t,1),n,t,e,r),i}function tJ(n,t,e,r){return tO(),function(n,t,e){tO();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tZ(n){return rA(n,oz)&&n_(n,oX)?uc[nx(n)]:new eo(n,0)}function tX(n,t){return 0==t||0==n.f?n:t>0?e4(n,t):rX(n,-t)}function tY(n,t){return 0==t||0==n.f?n:t>0?rX(n,t):e4(n,-t)}function t1(n){var t;return 0==n.f?-1:((t=eg(n))<<5)+ec(n.b[t])}function t0(n){var t;return 0!=(t=nx(n))?ec(t):ec(nx(rJ(n,32)))+32}function t2(n,t){var e;return 0==(e=eR(n,t)).length?(new d).o(t):tl(e,1)}function t4(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t3(n,t,e,r){var i;return ih(i=tL(fd,{6:1},-1,t+1,1),n,t,e,r),i}function t6(n){var t,e;return t=tL(fJ,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nx(y=iE(ts(e3(b.b[0]),o3),ts(e3(l.b[0]),o3))),0==(C=nx(rU(y,32)))?new t$(v,S):new ti(v,2,tJ(fd,{6:1},-1,[S,C]))):(eq(b.b,g,l.b,w,d=tL(fd,{6:1},-1,_,1)),tW(m=new ti(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=is(t,a.eb(f)),o=is(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iC(iC(u=n(is(a,i),is(o,h)),s),r)).eb(f),iC(iC(s=s.eb(f<<1),u),r))}(n,t))}function et(n,t){var e;if(t.f<=0)throw new nr(oe);return(e=rF(n,t)).f<0?iC(e,t):e}function ee(n){var t;t=new nz,n.d&&n6(t,new nt(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nB(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eU(n.g)),n.d).r()}function ed(n){return n.b<54?new tr(-n.g,n.f):new tM((n.d||(n.d=eU(n.g)),n.d).cb(),n.f)}function ep(n,t){if(!isFinite(n)||isNaN(n))throw new nw(os);iP(this,n.toPrecision(20)),ic(this,t)}function e_(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function ev(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function em(n,t){var e,r;return t?((e=t[oy])||(e=new(r=t.gC(),t9(er(n.b,r)))(t),t[oy]=e),e):null}function ey(n){var t,e;return 32==(e=rH(n.h))?32==(t=rH(n.m))?rH(n.l)+32:t+20-10:e-12}function eC(n){return tm(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eS(){eS=l,ui=tm(4194303,4194303,524287),uo=tm(0,0,524288),uu=e3(1),e3(2),uf=e3(0)}function eM(n,t){ih(n.b,n.b,n.e,t.b,t.e),n.e=nd(np(n.e,t.e)+1,n.b.length),tW(n),n.c=-2}function ex(n,t){var e;e=~~t>>5,n.e+=e+(rH(n.b[n.e-1])-(31&t)>=0?0:1),rC(n.b,n.b,e,31&t),tW(n),n.c=-2}function eB(n,t){var e,r;e=~~t>>5,n.e>>r:0,tW(n))}function eA(n){var t;return t=n.e>1?ta(rL(e3(n.b[1]),32),ts(e3(n.b[0]),o3)):ts(e3(n.b[0]),o3),iE(e3(n.f),t)}function eN(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:n_(ts(e3(n[r]),o3),ts(e3(t[r]),o3))?-1:1}function eI(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eE(n,t,e,r){if(iF=t,n)try{ff(im)()}catch(i){n(t)}else ff(im)()}function eR(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eo(oz,2147483647):new eo(oz,-2147483648)}function eU(n){return(rK(),n<0)?-1!=n?new ro(-1,-n):uC:n<=10?uM[ei(n)]:new ro(1,n)}function eP(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,tm(t,e,r)}function eQ(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function eT(n){var t,e,r;for(r=0,e=tL(fC,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rB(ts(e3(n[r]),o3),ts(e3(i[r]),o3));break}}return u=new ti(1,o+1,n),e&&tE(u,t),tW(u),u}(o,e)}function e$(n,t){var e;return n===t||!!nG(t,17)&&(e=tQ(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eV(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&eg(n)==n.e-1&&(e=~~(e-1)),t-=rH(e))}function eq(n,t,e,r,i){ib(),0!=t&&0!=r&&(1==t?i[r]=rf(i,e,r,n[0]):1==r?i[t]=rf(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nT(n)===nT(t)&&r==i){io(n,r,e);return}for(f=0;f2147483647))return ei(n);throw new nr("Underflow")}function eK(n,t){if(rj(),n<0)throw new no("Digits < 0");if(!t)throw new nf("null RoundingMode");this.b=n,this.c=t}function eW(n){return(rK(),n_(n,oz))?tv(n,oG)?new ri(-1,eP(n)):uC:rB(n,oZ)?new ri(1,n):uM[nx(n)]}function eZ(n){var t;return n_(n,oz)&&(n=tm(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nx(rJ(n,32)))?rH(t):rH(nx(n))+32)}function eX(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),tm(4194303&e,4194303&r,1048575&i)}function eY(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),tm(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-np(e,n.bb())}function e0(n,t){var e;return n===t||!!nG(t,16)&&(e=tQ(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e2(n,t,e){var r,i,o;for(o=oz,r=t-1;r>=0;--r)i=r0(eX(rL(o,32),ts(e3(n[r]),o3)),e),o=e3(nx(rJ(i,32)));return nx(o)}function e4(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rC(r=tL(fd,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tW(o=new ti(n.f,i,r)),o}function e3(n){var t,e;return n>-129&&n<128?(t=n+128,null==o8&&(o8=tL(fE,{6:1},2,256,0)),(e=o8[t])||(e=o8[t]=eC(n)),e):eC(n)}function e6(n){var t,e;return(rK(),n>5)+1,1))[t]=1<<(31&n),new ti(1,t+1,e))}function e5(n){rK(),0==n.length?(this.f=0,this.e=1,this.b=tJ(fd,{6:1},-1,[0])):(this.f=1,this.e=n.length,this.b=n,tW(this))}function e9(n){return 0==n.length||n[0]>iV&&n[n.length-1]>iV?n:n.replace(/^(\s*)/,i$).replace(/\s*$/,i$)}function e7(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function e8(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==l||nH(e,1)))throw new $}return n[t]=e}function rn(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=eH(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=eH(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tL(f5,{6:1},17,8,0),a=n,e8(s,0,t),h=eH(t,t,r,i),u=1;u<=7;++u)e8(s,u,eH(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=eH(a,a,r,i);return a}(f,r,t,e,o),eH(u,(rK(),uS),e,o)}function rs(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nw("Radix out of range");if(0==n.length)throw new nw("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(iM(),uU)[e])),0!=(d=l%u)&&++o,c=tL(fd,{6:1},-1,o,1),r=uL[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:n_(ts(e3(n[i]),o3),ts(e3(t[i]),o3))?-1:1}function rl(n,t){var e,r,i;for(r=tL(fd,{6:1},-1,i=n.e,1),nd(eg(n),eg(t)),e=0;e999999999)throw new nr(oa);return e=n.f*t,0==n.b&&-1!=n.g?eL(e):new tS((n.d||(n.d=eU(n.g)),n.d).db(t),eJ(e))}function rd(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fo[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fi[n]=t,t*=.5}function r_(){r_=l,uR=tJ(fJ,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rv(n){var t;return 0!=n.c?n.c:n.b<54?(t=r2(n.g),n.c=nx(ts(t,oG)),n.c=33*n.c+nx(ts(rJ(t,32),oG)),n.c=17*n.c+ei(n.f),n.c):(n.c=17*n.d.hC()+ei(n.f),n.c)}function rm(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=e_(n*t,0),0!=u&&(i=e_((u<=0?0-u:u)*2,t<=0?0-t:t),o+=r8(1&ei(o),f*(5+i),r)),new tr(o,e)}function ry(n,t,e,r,i){var o,u;for(u=0,o=oz;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rO(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=ei(nU(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eZ(r2(n))}function rE(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eW(rN(eA(e),eA(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rx(n,e),rx(t,r),1==rn(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eW(rN(eA(n),eA(t)));break}if(t.e>1.2*n.e)0!=(t=rF(t,n)).r()&&rx(t,t.bb());else do tE(t,n),rx(t,t.bb());while(rn(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?ex(f,i):(rx(c,r-e0&&ex(f,i-r+e)),e+=i),0!=(i=e1(h,u))&&(ex(h,i),r>=e?ex(c,i):(rx(f,e-r0&&ex(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)):e<=r?(r$(s,h),r$(f,c)):(r$(h,s),r$(c,f)),0==h.r()||0==s.r())throw new nr(ot);return eO(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():is(t,f)),0>f.r()&&(f=iC(f,t)),f}(n,t);for(o=32*t.e,h=eh(t),u=np((b=eh(n)).e,h.e),c=new ti(1,1,tL(fd,{6:1},-1,u+1,1)),(s=new ti(1,1,tL(fd,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rx(h,r),rx(b,i),ex(c,i),e+=r-i):(rx(h,r),rx(b,i),ex(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rn(h,b)>0;)tE(h,b),a=h.bb(),rx(h,a),eM(c,s),ex(s,a),e+=a;for(;0>=rn(h,b)&&(tE(b,h),0!=b.r());)a=b.bb(),rx(b,a),eM(s,c),ex(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new nr(ot);return rn(c,t)>=0&&tE(c,t),c=is(t,c),f=ru(t),e>o&&(c=eH(c,(rK(),uS),t,f),e-=o),c=eH(c,e6(o-e),t,f)}(et(n._(),t),t)).f)throw new nr(ot);return n.f<0?is(t,e):e}function rO(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rD(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eL(e):n.b+t.b<54?new tr(n.g*t.g,eJ(e)):new tS(en((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),eJ(e))}function rk(n,t){var e;if(t<0)throw new nr("Negative exponent");if(0==t)return uS;if(1==t||n.eQ(uS)||n.eQ(uB))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return en(e6(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(ib(),rK(),r=uS,e=n;t>1;t>>=1)(1&t)!=0&&(r=en(r,e)),e=1==e.e?en(e,e):new e5(io(e.b,e.e,tL(fd,{6:1},-1,e.e<<1,1)));return en(r,e)}(n,t)}function rL(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),tm(4194303&r,4194303&i,1048575&o)}function rP(n){switch(iB(),n){case 2:return uZ;case 1:return uX;case 3:return uY;case 5:return u1;case 6:return u0;case 4:return u2;case 7:return u4;case 0:return u3;default:throw new no("Invalid rounding mode")}}function rQ(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new nr(ob);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=eg(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rT(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ia((n.d||(n.d=eU(n.g)),n.d),iv(t)).r()&&++t),n.e=ei(t)),n.e}function rj(){rj=l,uP=new eK(34,(iB(),u0)),uQ=new eK(7,u0),uT=new eK(16,u0),uj=new eK(0,u2),uF=tJ(fJ,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),uH=tJ(fJ,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rF(n,t){var e,r,i,o;if(0==t.f)throw new nr(on);return((o=n.e)!=(e=t.e)?o>e?1:-1:eN(n.b,t.b,o))==-1?n:(r=tL(fd,{6:1},-1,e,1),1==e?r[0]=e2(n.b,o,t.b[0]):r=ik(null,o-e+1,n.b,o,t.b,e),tW(i=new ti(n.f,e,r)),i)}function rH(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16),e+=t=~~(r=(n=~~n>>t)-256)>>16&8,n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function r$(n,t){if(0==n.f)ix(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ih(n.b,n.b,n.e,t.b,t.e):rb(n.b,t.b,n.e,t.e)>0?ry(n.b,n.b,n.e,t.b,t.e):(r5(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=np(n.e,t.e)+1,tW(n),n.c=-2}function rV(n,t){var e;e=rn(n,t),0==n.f?(ix(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ih(n.b,n.b,n.e,t.b,t.e),n.f=e):rb(n.b,t.b,n.e,t.e)>0?ry(n.b,n.b,n.e,t.b,t.e):(r5(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=np(n.e,t.e)+1,tW(n),n.c=-2}function rq(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new nr(oe);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uB:0==r.f&&0==t.f?uS:(t.f<0&&(r=rR(n,e),t=t.cb()),i=e.gb(0)?rc(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rc(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rK(),u=uS,i=eh(t),r=eh(n),n.gb(0)&&eB(i,e-1),eB(r,e),o=i.ab()-1;o>=0;--o)eB(f=eh(u),e),u=en(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eB(u=en(u,r),e);return eB(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e5(tL(fd,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eB(b=en(is(h,a),s),f),b.f<0&&(b=iC(b,e6(f))),iC(a,en(c,b))),r.f<0&&t.gb(0)&&(i=et(en(is(e,uS),i),e)),i)}function rG(n,t){var e,r,i,o,u,f,c;if(i=eg(n),(r=eg(t))>=n.e)return rK(),uB;for(u=tL(fd,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=nd(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new tr(n.g,eJ(t)):new tS((n.d||(n.d=eU(n.g)),n.d),eJ(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),tm(4194303&i,4194303&o,1048575&u)}function rK(){var n;for(n=0,rK=l,uS=new t$(1,1),ux=new t$(1,10),uB=new t$(0,0),uC=new t$(-1,1),uM=tJ(f5,{6:1},17,[uB,uS,new t$(1,2),new t$(1,3),new t$(1,4),new t$(1,5),new t$(1,6),new t$(1,7),new t$(1,8),new t$(1,9),ux]),uA=tL(f5,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tL(fd,{6:1},-1,u=nd(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rK(),uC):(rK(),uB);if(rO(i=tL(fd,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rS(n,t,e):rS(t,n,-e):np(n.b,t.b)+1<54?new tr(n.g+t.g,n.f):new tM(iC((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),n.f)}function r0(n,t){var e,r,i,o,u;return(r=ts(e3(t),o3),rA(n,oz))?(o=iN(n,r,!1),u=n3(n,r)):(o=iN(e=rU(n,1),i=e3(~~t>>>1),!1),u=eX(rL(u=n3(e,i),1),ts(n,oJ)),(1&t)!=0&&(rB(o,u)?rB(eY(o,u),r)?(u=eX(u,eY(rL(r,1),o)),o=eY(o,oK)):(u=eX(u,eY(r,o)),o=eY(o,oJ)):u=eY(u,o))),ta(rL(u,32),ts(o,o3))}function r2(n){var t,e,r,i;return isNaN(n)?(eS(),uf):n<-0x8000000000000000?(eS(),uo):n>=0x7fffffffffffffff?(eS(),ui):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=ei(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=ei(n/4194304),n-=4194304*t),i=tm(ei(n),t,e),r&&eQ(i),i)}function r4(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iK;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iz+r4(eP(n));for(e=n,r=i$;!(0==e.l&&0==e.m&&0==e.h);){if(e=iN(e,e3(1e9),!0),t=i$+nx(o7),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iK+t;r=t+r}return r}function r3(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new nr(on);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iN(g=ts(e3(S[0]),o3),w=ts(e3(l),o3),!1),v=n3(g,w),x!=i&&(d=eP(d)),x<0&&(v=eP(v)),tJ(f5,{6:1},17,[eW(d),eW(v)])):(_=tL(fd,{6:1},-1,M,1),m=tJ(fd,{6:1},-1,[ir(_,S,M,l)]),y=new ti(x==i?1:-1,M,_),C=new ti(x,1,m),tW(y),tW(C),tJ(f5,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eN(a,e,h))<0)?tJ(f5,{6:1},17,[uB,n]):(b=n.f,f=ik(o=tL(fd,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new ti(b==i?1:-1,u,o),s=new ti(b,r,f),tW(c),tW(s),tJ(f5,{6:1},17,[c,s]))}function r6(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eU(n.g)),n.d;if(n.f<0)return en((n.d||(n.d=eU(n.g)),n.d),iv(-n.f));if(n.f>(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eU(n.g)),n.d).bb()||0!=(t=r3((n.d||(n.d=eU(n.g)),n.d),iv(n.f)))[1].r())throw new nr(ol);return t[0]}function r5(n,t,e,r,i){var o,u;if(o=oz,e36)throw new nw("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nw(oc+n+iq);return i}function r7(n){var t,e;if(0==n.f)return rK(),uC;if(e$(n,(rK(),uC)))return uB;if(e=tL(fd,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function it(n,t){var e,r,i,o,u,f,c,s;if(c=0==n.f?1:n.f,u=tL(fd,{6:1},-1,f=np((o=~~t>>5)+1,n.e)+1,1),e=1<<(31&t),ix(n.b,0,u,0,n.e),n.f<0){if(o>=n.e)u[o]=e;else if(o>(r=eg(n)))u[o]^=e;else if(o=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rq(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rA(a=ta(rL(s,32),ts(e3(t[f]),o3)),oz)?(c=iN(a,o,!1),s=n3(a,o)):(c=iN(i=rU(a,1),u=e3(~~r>>>1),!1),s=eX(rL(s=n3(i,u),1),ts(a,oJ)),(1&r)!=0&&(rB(c,s)?rB(eY(c,s),o)?(s=eX(s,eY(rL(o,1),c)),c=eY(c,oK)):(s=eX(s,eY(o,c)),c=eY(c,oJ)):s=eY(s,c))),n[f]=nx(ts(c,o3));return nx(s)}function ii(n,t){var e,r,i,o,u,f,c;if(u=tL(fd,{6:1},-1,f=np(n.e,t.e),1),i=eg(n),e=r=eg(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=nd(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nU((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=en(u,iv(r))),rn(o,u))}function ic(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r2(ub[r]),b=eY(r2(c.f),e3(r)),h=iN(g=r2(c.g),l,!1),tv(a=n3(g,l),oz)&&(s=t_(eY(rL(n_(a,oz)?eP(a):a,1),l),oz)?0:n_(eY(rL(n_(a,oz)?eP(a):a,1),l),oz)?-1:1,h=eX(h,e3(r8(1&nx(h),(t_(a,oz)?0:n_(a,oz)?-1:1)*(5+s),t.c))),n8(rr(n_(h,oz)?eP(h):h))>=t.b&&(h=nP(h,oZ),b=eY(b,oJ))),c.f=eJ(rr(b)),c.e=t.b,c.g=rr(h),c.b=eZ(h),c.d=null;return}f=iv(r),i=r3((n.d||(n.d=eU(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rn(eF(i[1]._()),f),0!=(e=r8(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&e8(i,0,iC(i[0],eW(e3(e)))),new nk(i[0]).q()>o&&(e8(i,0,ia(i[0],(rK(),ux))),--u)),n.f=eJ(u),n.e=o,tR(n,i[0])}}function is(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ts(e3(n.b[0]),o3),r=ts(e3(t.b[0]),o3),u<0&&(e=eP(e)),c<0&&(r=eP(r)),eW(eY(e,r));if(-1==(i=o!=f?o>f?1:-1:eN(n.b,t.b,o)))h=-c,a=u==c?tz(t.b,f,n.b,o):t3(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rK(),uB;a=tz(n.b,o,t.b,f)}else a=t3(n.b,o,t.b,f);return tW(s=new ti(h,a.length,a)),s}function ia(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new nr(on);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nP(ts(e3(n.b[0]),o3),ts(e3(t.b[0]),o3)),s!=i&&(a=eP(a)),eW(a)):0==(e=c!=r?c>r?1:-1:eN(n.b,t.b,c))?s==i?uS:uC:-1==e?uB:(o=tL(fd,{6:1},-1,u=c-r+1,1),1==r?ir(o,n.b,c,t.b[0]):ik(o,u,n.b,c,t.b,r),tW(f=new ti(s==i?1:-1,u,o)),f)}function ih(n,t,e,r,i){var o,u;if(o=eX(ts(e3(t[0]),o3),ts(e3(r[0]),o3)),n[0]=nx(o),o=rJ(o,32),e>=i){for(u=1;u0){if(i0?u=tP(u,ei(i)):i<0&&(o=tP(o,ei(-i))),iw(o,u,e,r)}function ig(n,t){var e,r,i,o,u,f,c;if(r=eg(t),(i=eg(n))>=t.e)return t;if(u=tL(fd,{6:1},-1,f=t.e,1),rt.ab()?(c=eA(s),o=eA(t),i=t_(eY(rL(n_(c,oz)?eP(c):c,1),n_(o,oz)?eP(o):o),oz)?0:n_(eY(rL(n_(c,oz)?eP(c):c,1),n_(o,oz)?eP(o):o),oz)?-1:1,i=r8(f.gb(0)?1:0,a*(5+i),r)):(i=rn(eF(s._()),t._()),i=r8(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return ek(eX(eA(f),e3(i)),e);f=iC(f,eW(e3(i)))}return new tS(f,e)}function id(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v;if(iM(),(u=n_(n,oz))&&(n=eP(n)),t_(n,oz))switch(t){case 0:return iK;case 1:return iZ;case 2:return iX;case 3:return iY;case 4:return i1;case 5:return i0;case 6:return i2;default:return s=new K,t<0?s.b.b+=i3:s.b.b+=i4,b=s.b,b.b+=-2147483648==t?"2147483648":i$+-t,s.b.b}c=tL(fJ,{6:1},-1,19,1),e=18,h=n;do f=h,h=nP(h,oZ),c[--e]=65535&nx(eX(o1,eY(f,iE(h,oZ))));while(tv(h,oz))if(r=eY(eY(eY(oY,e3(e)),e3(t)),oJ),0==t)return u&&(c[--e]=45),tU(c,e,18-e);if(t>0&&rA(r,oq)){if(rA(r,oz)){for(o=17,i=e+nx(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tU(c,e,18-e+1)}for(o=2;n_(e3(o),eX(eP(r),oJ));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tU(c,e,18-e)}return(a=e+1,s=new W,u&&(s.b.b+=iz),18-a>=1)?(tI(s,c[e]),s.b.b+=iJ,l=s.b,g=tU(c,e+1,18-e-1),l.b+=g):(w=s.b,d=tU(c,e,18-e),w.b+=d),s.b.b+=of,rB(r,oz)&&(s.b.b+=iG),_=s.b,v=i$+r4(r),_.b+=v,s.b.b}(r2(n.g),ei(n.f)),n.i):(i=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eU(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new K).b,u.b+=i,n.f>0&&r>=-6?r>=0?n9(o,e-ei(n.f),iJ):(tt(o.b,t-1,t-1,iW),n9(o,t+1,tU(us,0,-ei(r)-1))):(e-t>=1&&(tt(o.b,t,t,iJ),++e),tt(o.b,e,e,of),r>0&&n9(o,++e,iG),n9(o,++e,i$+r4(r2(r)))),n.i=o.b.b,n.i)}function ip(n,t){var e,r,i,o,u,f;if(i=eg(n),o=eg(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==i$;)--s;s1e6)throw new nr("power of ten too big");if(n<=2147483647)return u$[1].db(t).eb(t);for(i=r=u$[1].db(2147483647),e=r2(n-2147483647),t=ei(n%2147483647);rB(e,o4);)i=en(i,r),e=eY(e,o4);for(i=(i=en(i,u$[1].db(t))).eb(2147483647),e=r2(n-2147483647);rB(e,o4);)i=i.eb(2147483647),e=eY(e,o4);return i.eb(t)}function im(){var n,t;f&&rM("com.iriscouch.gwtapp.client.BigDecimalApp"),nW(new J),nX(new T),nZ(new j),tD(new F),f&&rM("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oQ)?oQ:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=oH)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oj:-1!=t.indexOf(oO)&&u.documentMode>=9?"ie9":-1!=t.indexOf(oO)&&u.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tj(oj,n)||o.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),f&&rM("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=u.compatMode,n=tJ(fN,{6:1},1,[oi]);e>5,this.b=tL(fd,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tW(this)}}function iC(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ts(e3(n.b[0]),o3),r=ts(e3(t.b[0]),o3),u==c)?(l=nx(s=eX(e,r)),0==(b=nx(rU(s,32)))?new t$(u,l):new ti(u,2,tJ(fd,{6:1},-1,[l,b]))):eW(u<0?eY(r,e):eY(e,r));if(u==c)h=u,a=o>=f?t3(n.b,o,t.b,f):t3(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eN(n.b,t.b,o)))return rK(),uB;1==i?(h=u,a=tz(n.b,o,t.b,f)):(h=c,a=tz(t.b,f,n.b,o))}return tW(s=new ti(h,a.length,a)),s}function iS(n){var t,e,r,i;if(rj(),null==n)throw new nf("null string");if((t=t6(n)).length<27||t.length>45)throw new no(oM);for(r=0;rft.length)throw new V;if(o=null,i=null,67==r[0]?(i=uZ,o=u6):68==r[0]?(i=uX,o=u5):70==r[0]?(i=uY,o=u9):72==r[0]?e>6&&(68==r[5]?(i=u1,o=u7):69==r[5]?(i=u0,o=u8):85==r[5]&&(i=u2,o=fn)):85==r[0]&&(80==r[1]?(i=u3,o=fe):78==r[1]&&(i=u4,o=ft)),i&&e==o.length){for(t=1;tl||r+i>s)throw new q;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tQ(n,11),o=tQ(e,11),nT(n)===nT(e)&&tr;)e8(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eJ(e+(o>u?o:u)),s=(i=o-u)>0?(ib(),i>19!=0&&(t=eP(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?ec(b):0==h&&0!=l&&0==b?ec(l)+22:0!=h&&0==l&&0==b?ec(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rJ(n,u),c&&eQ(f),e&&(o7=tm(0,0,0)),f;n=nQ((eS(),ui)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eP(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rJ(g,u),w&&eQ(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eQ(f),o&&(r?(o7=eP(n),i&&(o7=eY(o7,(eS(),uu)))):o7=tm(n.l,n.m,n.h)),f}(r?n:tm(n.l,n.m,n.h),t,c,o,i,e):(e&&(o7=o?eP(n):tm(n.l,n.m,n.h)),tm(0,0,0))}function iI(n){var t=[];for(var e in n){var r=typeof n[e];r!=oP?t[t.length]=r:n[e]instanceof Array?t[t.length]=oS:o&&o.bigdecimal&&o.bigdecimal.BigInteger&&n[e]instanceof o.bigdecimal.BigInteger?t[t.length]=i8:o&&o.bigdecimal&&o.bigdecimal.BigDecimal&&n[e]instanceof o.bigdecimal.BigDecimal?t[t.length]=i5:o&&o.bigdecimal&&o.bigdecimal.RoundingMode&&n[e]instanceof o.bigdecimal.RoundingMode?t[t.length]=og:o&&o.bigdecimal&&o.bigdecimal.MathContext&&n[e]instanceof o.bigdecimal.MathContext?t[t.length]=oh:t[t.length]=oP}return t.join(iV)}function iE(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,tm(b,l&=4194303,g&=1048575)}function iR(n,t,e){var r,i,o,u,f,c,s,a;if(a=rr(eX(e3(e.b),oK))+(t.e>0?t.e:nU((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=uv.length-1,s=tJ(f5,{6:1},17,[(n.d||(n.d=eU(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iA(n,t);if(a>0&&(e8(s,0,en((n.d||(n.d=eU(n.g)),n.d),iv(a))),c+=a),u=(s=r3(s[0],(t.d||(t.d=eU(t.g)),t.d)))[0],0!=s[1].r())r=rn(eF(s[1]),(t.d||(t.d=eU(t.g)),t.d)),u=iC(en(u,(rK(),ux)),eW(e3(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r3(u,uv[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?np(n.b,t.b)+1<54?new tr(n.g-t.g,n.f):new tM(is((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),n.f):e>0?e0?t.e:nU((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rK(),r=uB;else if(0==o)r=ia((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d));else if(o>0)u=iv(o),r=ia((n.d||(n.d=eU(n.g)),n.d),en((t.d||(t.d=eU(t.g)),t.d),u)),r=en(r,u);else{for(u=iv(-o),r=ia(en((n.d||(n.d=eU(n.g)),n.d),u),(t.d||(t.d=eU(t.g)),t.d));!r.gb(0);)if(0==(f=r3(r,uv[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nx(m=r0(eX(rL(ts(e3(w[h]),o3),32),ts(e3(w[h-1]),o3)),c)),v=nx(rJ(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iE(ts(e3(s),o3),ts(e3(d[o-2]),o3)),y=eX(rL(e3(v),32),ts(e3(w[h-2]),o3)),32>rH(nx(rU(g=eX(ts(e3(v),o3),ts(e3(c),o3)),32)))?_=!0:v=nx(g)}while(rB(th(l,o$),th(y,o$)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oz,u=oz;f0)e8(b,0,ia((n.d||(n.d=eU(n.g)),n.d),en((t.d||(t.d=eU(t.g)),t.d),iv(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,e8(b,0,en(b[0],iv(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r3(en((n.d||(n.d=eU(n.g)),n.d),iv(u)),(t.d||(t.d=eU(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nk(b[1]).q()+u-t.q())&&(e8(b,1,ia(en(b[1],iv(u)),(t.d||(t.d=eU(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new nr(ou);if(0==b[0].r())return eL(o);for(w=b[0],g=(c=new nk(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r3(w,uv[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new nr(ou);return c.f=eJ(h),tR(c,w),c}function iT(){var n;for(n=0,iT=l,uz=tJ(fd,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uJ=tL(f5,{6:1},17,(uK=tJ(fd,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rA(n,oz)?(e=nP(n,o2),r=n3(n,o2)):(e=nP(t=rU(n,1),o0),r=eX(rL(r=n3(t,o0),1),ts(n,oJ))),ta(rL(r,32),ts(e,o3))}(eX(rL(y,32),ts(e3(M[c]),o3))),M[c]=nx(w),y=e3(nx(rJ(w,32)));d=nx(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tU(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tU(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tU(v,e,_-e)}return(S=e+1,m=new W,h&&(m.b.b+=iz),_-S>=1)?(tI(m,v[e]),m.b.b+=iJ,N=m.b,I=tU(v,e+1,_-e-1),N.b+=I):(E=m.b,R=tU(v,e,_-e),E.b+=R),m.b.b+=of,o>0&&(m.b.b+=iG),O=m.b,O.b+=i$+o,m.b.b}f&&f({moduleName:"gwtapp",sessionId:c,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iF,iH,i$="",iV=" ",iq='"',iG="+",iz="-",iJ=".",iK="0",iW="0.",iZ="0.0",iX="0.00",iY="0.000",i1="0.0000",i0="0.00000",i2="0.000000",i4="0E",i3="0E+",i6=":",i5="BigDecimal",i9="BigDecimal MathContext",i7="BigDecimal;",i8="BigInteger",on="BigInteger divide by zero",ot="BigInteger not invertible.",oe="BigInteger: modulus not positive",or="BigInteger;",oi="CSS1Compat",oo="Division by zero",ou="Division impossible",of="E",oc='For input string: "',os="Infinite or NaN",oa="Invalid Operation",oh="MathContext",ob="Negative bit address",ol="Rounding necessary",og="RoundingMode",ow="RoundingMode;",od="String",op="[Lcom.iriscouch.gwtapp.client.",o_="[Ljava.lang.",ov="[Ljava.math.",om="\\.",oy="__gwtex_wrap",oC="anonymous",oS="array",oM="bad string format",ox="bigdecimal",oB="com.google.gwt.core.client.",oA="com.google.gwt.core.client.impl.",oN="com.iriscouch.gwtapp.client.",oI="java.lang.",oE="java.math.",oR="java.util.",oO="msie",oD="null",ok="number",oL="number MathContext",oU="number number",oP="object",oQ="opera",oT="org.timepedia.exporter.client.",oj="safari",oF="string",oH="undefined",o$={l:0,m:0,h:524288},oV={l:0,m:4193280,h:1048575},oq={l:4194298,m:4194303,h:1048575},oG={l:4194303,m:4194303,h:1048575},oz={l:0,m:0,h:0},oJ={l:1,m:0,h:0},oK={l:2,m:0,h:0},oW={l:5,m:0,h:0},oZ={l:10,m:0,h:0},oX={l:11,m:0,h:0},oY={l:18,m:0,h:0},o1={l:48,m:0,h:0},o0={l:877824,m:119,h:0},o2={l:1755648,m:238,h:0},o4={l:4194303,m:511,h:0},o3={l:4194303,m:1023,h:0},o6={l:0,m:1024,h:0};(iH=s.prototype={}).eQ=function(n){return this===n},iH.gC=function(){return fc},iH.hC=function(){return nj(this)},iH.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tL(fJ,{6:1},-1,8,1),r_(),e=7,n>=0)for(;n>15;)t[e--]=uR[15&n],n>>=4;else for(;e>0;)t[e--]=uR[15&n],n>>=4;return t[e]=uR[15&n],t4(t,e,8)}(this.hC())},iH.toString=function(){return this.tS()},iH.tM=l,iH.cM={},(iH=a.prototype=new s).gC=function(){return fa},iH.j=function(){return this.f},iH.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},iH.cM={6:1,15:1},iH.f=null,(iH=h.prototype=new a).gC=function(){return fh},iH.cM={6:1,15:1},(iH=ne.prototype=b.prototype=new h).gC=function(){return fb},iH.cM={6:1,12:1,15:1},(iH=n1.prototype=(function(){}).prototype=new b).gC=function(){return fl},iH.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?oD:tn(e)?null==(r=t9(e))?null:r.name:nG(e,1)?od:(nF(e)?e.gC():fg).d,this.b=tn(n=this.c)?null==(i=t9(n))?null:i.message:n+i$,this.d="("+this.e+"): "+this.b+(tn(t=this.c)?function(n){var t=i$;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t9(t)):i$)),this.d},iH.cM={6:1,12:1,15:1},iH.b=null,iH.c=null,iH.d=null,iH.e=null,(iH=g.prototype=new s).gC=function(){return fw};var o5=0,o9=0;(iH=w.prototype=(function(){}).prototype=new g).gC=function(){return fv},iH.b=null,iH.c=null,(iH=d.prototype=_.prototype=new s).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i6+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oC},iH.gC=function(){return fm},iH.o=function(n){return[]},(iH=v.prototype=new _).k=function(){return tl(this.o(tw()),this.p())},iH.gC=function(){return fS},iH.o=function(n){return eR(this,n)},iH.p=function(){return 2},(iH=m.prototype=(function(){}).prototype=new v).k=function(){return es(this)},iH.n=function(n){var t,e;return 0==n.length||(0==(e=e9(n)).indexOf("at ")&&(e=n7(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oC:(-1!=(t=(e=e9(e.substr(0,t-0))).indexOf("."))&&(e=n7(e,t+1)),e.length>0?e:oC)},iH.gC=function(){return fM},iH.o=function(n){return t2(this,n)},iH.p=function(){return 3},(iH=y.prototype=new s).gC=function(){return fx},(iH=C.prototype=(function(){}).prototype=new y).gC=function(){return fB},iH.b=i$,(iH=S.prototype=(function(){}).prototype=new s).gC=function(){return this.aC},iH.aC=null,iH.qI=0;var o7=null,o8=null;(iH=M.prototype=(function(){}).prototype=new s).gC=function(){return fI},iH.cM={2:1},(iH=x.prototype=new s).gC=function(){return fR},iH.cM={6:1,10:1};var un=null;(iH=eo.prototype=tr.prototype=tM.prototype=tA.prototype=Z.prototype=ep.prototype=eu.prototype=tB.prototype=tx.prototype=ez.prototype=n2.prototype=n4.prototype=te.prototype=tS.prototype=nk.prototype=B.prototype=new x).eQ=function(n){return e0(this,n)},iH.gC=function(){return fO},iH.hC=function(){return rv(this)},iH.q=function(){return rT(this)},iH.r=function(){return ew(this)},iH.tS=function(){return id(this)},iH.cM={6:1,8:1,10:1,16:1},iH.b=0,iH.c=0,iH.d=null,iH.e=0,iH.f=0,iH.g=0,iH.i=null;var ut,ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_=null,uv=null,um=null;(iH=nL.prototype=ng.prototype=(function(){}).prototype=new B).s=function(n){var t,e,r;if((e=iI(n))==i$)t=0>ew(this)?ed(this):this;else if(e==oh)t=0>(r=t7(this,new iS(n[0].toString()))).r()?ed(r):r;else throw new ne("Unknown call signature for interim = super.abs: "+e);return new nL(t)},iH.t=function(n){var t,e;if((e=iI(n))==i5)t=r1(this,new Z(n[0].toString()));else if(e==i9)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t7(r1(n,t),e);if((n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)0?t.e:nU((t.b-1)*.3010299956639812)+1)<-r-1))return t7(r1(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nU((i.b-1)*.3010299956639812)+1)?t7(r1(n,t),e):(f=(o=i.r())==u.r()?iC(rW((i.d||(i.d=eU(i.g)),i.d),10),eW(e3(o))):iC(rW(f=is((i.d||(i.d=eU(i.g)),i.d),eW(e3(o))),10),eW(e3(9*o))),t7(i=new tM(f,i.f+1),e))}(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.add: "+e);return new nL(t)},iH.u=function(){return~~(nx(t8(this,8))<<24)>>24},iH.v=function(n){return iu(this,n)},iH.w=function(n){var t,e,r,i;if((i=iI(n))==i5)e=eb(this,new Z(n[0].toString()));else if(i==i9)e=el(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tL(fk,{6:1},3,e.length,0);t129?n*=1/0:n=t5(id(this)),n},iH.gC=function(){return fD},iH.hC=function(){return rv(this)},iH.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nU((this.b-1)*.3010299956639812)+1)?0:(n=new n0(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eU(this.g)),this.d):this.f<0?en((this.d||(this.d=eU(this.g)),this.d),iv(-this.f)):ia((this.d||(this.d=eU(this.g)),this.d),iv(this.f)))).f*n.b[0]},iH.C=function(){return nx(t8(this,32))},iH.D=function(){return nx(t8(this,32))},iH.E=function(){return t5(id(this))},iH.F=function(n){return new nL(iu(this,n)>=0?this:n)},iH.G=function(n){return new nL(0>=iu(this,n)?this:n)},iH.H=function(n){return new nL(rz(this,this.f+n))},iH.I=function(n){return new nL(rz(this,this.f-n))},iH.J=function(n){var t,e;if((e=iI(n))==i5)t=rD(this,new Z(n[0].toString()));else if(e==i9)t=tb(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.multiply: "+e);return new nL(t)},iH.K=function(n){var t,e;if((e=iI(n))==i$)t=ed(this);else if(e==oh)t=ed(t7(this,new iS(n[0].toString())));else throw new ne("Unknown call signature for interim = super.negate: "+e);return new nL(t)},iH.L=function(n){var t,e;if((e=iI(n))==i$)t=this;else if(e==oh)t=t7(this,new iS(n[0].toString()));else throw new ne("Unknown call signature for interim = super.plus: "+e);return new nL(t)},iH.M=function(n){var t,e;if((e=iI(n))==ok)t=rw(this,n[0]);else if(e==oL)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=ei(n8(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rw(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new nr(oa);for(u>0&&(f=new eK(u+i+1,e.c)),r=t7(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tb(r,r,f),(o&c)==c&&(r=tb(r,n,f)),c>>=1;return t<0&&(r=iR(ug,r,f)),ic(r,e),r}(this,n[0],new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.pow: "+e);return new nL(t)},iH.q=function(){return rT(this)},iH.N=function(n){var t,e;if((e=iI(n))==i5)t=eb(this,new Z(n[0].toString()))[1];else if(e==i9)t=el(this,new Z(n[0].toString()),new iS(n[1].toString()))[1];else throw new ne("Unknown call signature for interim = super.remainder: "+e);return new nL(t)},iH.O=function(n){return new nL(t7(this,new iS(ea(n.b))))},iH.P=function(){return ei(this.f)},iH.Q=function(n){var t,e;return new nL((t=this,(e=t.f-n,t.b<54)?0==t.g?eL(e):new tr(t.g,eJ(e)):new tS((t.d||(t.d=eU(t.g)),t.d),eJ(e))))},iH.R=function(n){var t,e;if((e=iI(n))==ok)t=rY(this,n[0],(iB(),u4));else if(e==oU)t=rY(this,n[0],rP(n[1]));else if("number RoundingMode"==e)t=rY(this,n[0],tc(n[1].toString()));else throw new ne("Unknown call signature for interim = super.setScale: "+e);return new nL(t)},iH.S=function(){return~~(nx(t8(this,16))<<16)>>16},iH.r=function(){return ew(this)},iH.T=function(){return new nL(function(n){var t,e,r,i,o;if(t=1,e=uv.length-1,r=n.f,0==n.b&&-1!=n.g)return new Z(iK);for(n.d||(n.d=eU(n.g)),o=n.d;!o.gb(0);)if(0==(i=r3(o,uv[t]))[1].r())r-=t,t0?i.e:nU((i.b-1)*.3010299956639812)+1)0?r.e:nU((r.b-1)*.3010299956639812)+1)?(f=(c=ew(r))!=i.r()?iC(rW((r.d||(r.d=eU(r.g)),r.d),10),eW(e3(c))):iC(rW(f=is((r.d||(r.d=eU(r.g)),r.d),eW(e3(c))),10),eW(e3(9*c))),t7(new tM(f,r.f+1),o)):t7(iO(r,i),o);else throw new ne("Unknown call signature for interim = super.subtract: "+e);return new nL(t)},iH.V=function(){return new n0(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eU(this.g)),this.d):this.f<0?en((this.d||(this.d=eU(this.g)),this.d),iv(-this.f)):ia((this.d||(this.d=eU(this.g)),this.d),iv(this.f)))},iH.W=function(){return new n0(r6(this))},iH.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eU(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nV(u),n.f>0&&i>=-6)i>=0?n9(c,r-ei(n.f),iJ):(tt(c.b,t-1,t-1,iW),n9(c,t+1,tU(us,0,-ei(i)-1)));else{if(e=r-t,0!=(f=ei(i%3))&&(0==(n.d||(n.d=eU(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n9(c,r++,iK);r-t>=1&&(tt(c.b,t,t,iJ),++r),0!=i&&(tt(c.b,r,r,of),i>0&&n9(c,++r,iG),n9(c,++r,i$+r4(r2(i))))}return c.b.b}(this)},iH.Y=function(){return function(n){var t,e,r,i,o,u;if(r=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ew(n)?1:0,e=n.f,i=new W(r.length+1+((o=ei(n.f))<0?-o:o)),1==t&&(i.b.b+=iz),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iW;e>us.length;e-=us.length)tq(i,us);n5(i,us,ei(e)),nI(i,n7(r,t))}else nI(i,(u=ei(e=t-e),r.substr(t,u-t))),i.b.b+=iJ,nI(i,n7(r,ei(e)))}else{for(nI(i,n7(r,t));e<-us.length;e+=us.length)tq(i,us);n5(i,us,ei(-e))}return i.b.b}(this)},iH.tS=function(){return id(this)},iH.Z=function(){return new nL(new tr(1,this.f))},iH.$=function(){return new n0((this.d||(this.d=eU(this.g)),this.d))},iH.cM={3:1,6:1,8:1,10:1,16:1,24:1},(iH=F.prototype=(function(){}).prototype=new s).gC=function(){return fL};var uy=!1;(iH=ro.prototype=ri.prototype=ti.prototype=e5.prototype=t$.prototype=ra.prototype=nq.prototype=iy.prototype=A.prototype=new x)._=function(){return this.f<0?new ti(1,this.e,this.b):this},iH.ab=function(){return eV(this)},iH.eQ=function(n){return e$(this,n)},iH.gC=function(){return fU},iH.bb=function(){return t1(this)},iH.hC=function(){return eD(this)},iH.cb=function(){return 0==this.f?this:new ti(-this.f,this.e,this.b)},iH.db=function(n){return rk(this,n)},iH.eb=function(n){return tX(this,n)},iH.fb=function(n){return tY(this,n)},iH.r=function(){return this.f},iH.gb=function(n){return rQ(this,n)},iH.tS=function(){return ij(this,0)},iH.cM={6:1,8:1,10:1,17:1},iH.b=null,iH.c=-2,iH.d=0,iH.e=0,iH.f=0;var uC,uS,uM,ux,uB,uA=null;(iH=n0.prototype=nO.prototype=nD.prototype=(function(){}).prototype=new A)._=function(){return new n0(this.f<0?new ti(1,this.e,this.b):this)},iH.hb=function(n){return new n0(iC(this,n))},iH.ib=function(n){return new n0(0==n.f||0==this.f?(rK(),uB):e$(n,(rK(),uC))?this:e$(this,uC)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=nd(n.e,t.e),(e=np(eg(n),eg(t)))>=i)return rK(),uB;for(r=tL(fd,{6:1},-1,i,1);e0?rG(n,this):this.e>n.e?ip(this,n):ip(n,this))},iH.jb=function(n){return new n0(0==n.f?this:0==this.f?(rK(),uB):e$(this,(rK(),uC))?new n0(r7(n)):e$(n,uC)?uB:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tL(fd,{6:1},-1,n.e,1),r=nd(n.e,t.e),e=eg(n);e=n.e)return n;for(o=tL(fd,{6:1},-1,u=nd(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=eg(n),o=eg(t),i>=t.e)return n;if(c=np(n.e,t.e),r=i,o>i){for(f=tL(fd,{6:1},-1,c,1),u=nd(n.e,o);r=t.e)return rK(),uB;if(u=tL(fd,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},iH.qb=function(n){return new n0(rE(this,n))},iH.gC=function(){return fP},iH.bb=function(){return t1(this)},iH.hC=function(){return eD(this)},iH.B=function(){return this.f*this.b[0]},iH.rb=function(n){return function(n,t){var e,r;if(iT(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rQ(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uK,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n0(this.f<0?new ti(1,this.e,this.b):this),n)},iH.sb=function(){return t5(ij(this,0))},iH.tb=function(n){return new n0(1==rn(this,n)?this:n)},iH.ub=function(n){return new n0(-1==rn(this,n)?this:n)},iH.vb=function(n){return new n0(et(this,n))},iH.wb=function(n){return new n0(rR(this,n))},iH.xb=function(n,t){return new n0(rq(this,n,t))},iH.yb=function(n){return new n0(en(this,n))},iH.cb=function(){return new n0(0==this.f?this:new ti(-this.f,this.e,this.b))},iH.zb=function(){return new n0(function(n){if(n.f<0)throw new nr("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(iT(),o=tL(fd,{6:1},-1,uK.length,1),r=tL(f_,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uK[e];++e);return uJ[e]}for(f=new ti(1,n.e,tL(fd,{6:1},-1,n.e+1,1)),ix(n.b,0,f.b,0,n.e),rQ(n,0)?tK(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rl(this,n):rl(n,this):ig(this,n):n.f>0?ig(n,this):eg(n)>eg(this)?rZ(n,this):rZ(this,n))},iH.db=function(n){return new n0(rk(this,n))},iH.Cb=function(n){return new n0(rF(this,n))},iH.Db=function(n){return new n0(rQ(this,n)?this:it(this,n))},iH.eb=function(n){return new n0(tX(this,n))},iH.fb=function(n){return new n0(tY(this,n))},iH.r=function(){return this.f},iH.Eb=function(n){return new n0(is(this,n))},iH.gb=function(n){return rQ(this,n)},iH.Fb=function(n){var t,e;if((e=iI(n))==i$)t=ij(this,0);else if(e==ok)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(iM(),g=n.f,s=n.e,u=n.b,0==g)return iK;if(1==s)return _=ts(e3(u[0]),o3),g<0&&(_=eP(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return i$+r4(n);if(e=tL(fJ,{6:1},-1,65,1),r_(),r=64,i=e3(t),rA(n,oz)){for(;rA(n,i);)e[r--]=uR[nx(n3(n,i))],n=iN(n,i,!1);e[r]=uR[nx(n)]}else{for(;!rB(n,eP(i));)e[r--]=uR[nx(eP(n3(n,i)))],n=iN(n,i,!1);e[r--]=uR[nx(eP(n))],e[r]=45}return t4(e,r,65)}(_,t);if(10==t||t<2||t>36)return ij(n,0);if(l=tL(fJ,{6:1},-1,b=ei(eV(new n0(n.f<0?new ti(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(ix(u,0,w=tL(fd,{6:1},-1,s,1),0,s),d=s,r=uU[t],e=uL[t-2];;){h=ir(w,w,d,e),a=i;do l[--i]=ev(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=ev(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tU(l,i,b-i)}(this,n[0]);else throw new ne("Unknown call signature for result = super.toString: "+e);return t},iH.Gb=function(n){return new n0(0==n.f?this:0==this.f?n:e$(n,(rK(),uC))?new n0(r7(this)):e$(this,uC)?new n0(r7(n)):this.f>0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iL(this,n):n.f>0?iL(n,this):eg(n)>eg(this)?ii(n,this):ii(this,n))},iH.cM={4:1,6:1,8:1,10:1,17:1,24:1},(iH=j.prototype=(function(){}).prototype=new s).gC=function(){return fT};var uN=!1;(iH=nv.prototype=nm.prototype=(function(){}).prototype=new s).gC=function(){return fj},iH.Hb=function(){return this.b.b},iH.Ib=function(){return new Y(this.b.c)},iH.hC=function(){return nM(this.b)},iH.tS=function(){return ea(this.b)},iH.cM={24:1},iH.b=null,(iH=T.prototype=(function(){}).prototype=new s).gC=function(){return fF};var uI=!1;(iH=Y.prototype=ny.prototype=(function(){}).prototype=new s).gC=function(){return fH},iH.Jb=function(){return this.b.b},iH.tS=function(){return this.b.b},iH.cM={5:1,24:1},iH.b=null,(iH=J.prototype=(function(){}).prototype=new s).gC=function(){return fV};var uE=!1;(iH=nr.prototype=(function(){}).prototype=new b).gC=function(){return fq},iH.cM={6:1,12:1,15:1},(iH=ni.prototype=$.prototype=(function(){}).prototype=new b).gC=function(){return fz},iH.cM={6:1,12:1,15:1},(iH=N.prototype=(function(){}).prototype=new s).gC=function(){return fK},iH.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?i$:"class ")+this.d},iH.b=null,iH.c=0,iH.d=null,(iH=H.prototype=(function(){}).prototype=new b).gC=function(){return fW},iH.cM={6:1,12:1,15:1},(iH=I.prototype=new s).eQ=function(n){return this===n},iH.gC=function(){return fs},iH.hC=function(){return nj(this)},iH.tS=function(){return this.b},iH.cM={6:1,8:1,9:1},iH.b=null,iH.c=0,(iH=no.prototype=V.prototype=E.prototype=new b).gC=function(){return fZ},iH.cM={6:1,12:1,15:1},(iH=nu.prototype=q.prototype=R.prototype=new b).gC=function(){return fG},iH.cM={6:1,12:1,15:1},(iH=nf.prototype=G.prototype=(function(){}).prototype=new b).gC=function(){return fX},iH.cM={6:1,12:1,15:1},(iH=nw.prototype=(function(){}).prototype=new E).gC=function(){return fY},iH.cM={6:1,12:1,15:1},(iH=to.prototype=(function(){}).prototype=new s).gC=function(){return fy},iH.tS=function(){return this.b+iJ+this.d+"(Unknown Source"+(this.c>=0?i6+this.c:i$)+")"},iH.cM={6:1,13:1},iH.b=null,iH.c=0,iH.d=null,(iH=String.prototype).eQ=function(n){return tj(this,n)},iH.gC=function(){return fA},iH.hC=function(){var n,t;return nJ(),null!=(t=uD[n=i6+this])?t:(null==(t=uO[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;et?n:t}function nv(n,t){return!rN(n,t)}function nm(n){this.b=new iM(n)}function ny(){this.b=(rF(),uF)}function nC(){this.b=(iA(),u4)}function nS(n,t){var e;nb(),e=o.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tw(n){return nz(n,15)?n:new n0(n)}function td(){try{null.a()}catch(n){return n}}function tp(n){var t;return(t=new I).d=iV+n,t.c=1,t}function t_(n,t){return nH(n)?n.eQ(t):n===t}function tv(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tm(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function ty(n,t,e){return(i$=new x).l=n,i$.m=t,i$.h=e,i$}function tC(n,t){return nj(n)===nj(t)||null!=n&&t_(n,t)}function tS(n,t){throw new nf("Index: "+n+", Size: "+t)}function tM(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tx(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tB(n,t,e,r){eJ.call(this,n,t,e),is(this,r)}function tA(n,t){eJ.call(this,n,0,n.length),is(this,t)}function tN(n,t){eJ.call(this,t5(n),0,n.length),is(this,t)}function tI(n){nr.call(this,"String index out of range: "+n)}function tE(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tR(n,t){rC(n.b,n.b,n.e,t.b,t.e),tZ(n),n.c=-2}function tO(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=ri(eN(t)))}function tD(){tD=g,ur=[],ui=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new M,ur,ui)}function tk(){uC||(uC=!0,new j,new F,function(){if(ng(oB,iV),u.bigdecimal.BigDecimal)var n=u.bigdecimal.BigDecimal;u.bigdecimal.BigDecimal=fc(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fk?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new nw,nl(this.__gwt_instance,this))});var t=u.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)u.bigdecimal.BigDecimal[p]=n[p];u.bigdecimal.BigDecimal.ROUND_CEILING=2,u.bigdecimal.BigDecimal.ROUND_DOWN=1,u.bigdecimal.BigDecimal.ROUND_FLOOR=3,u.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,u.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,u.bigdecimal.BigDecimal.ROUND_HALF_UP=4,u.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,u.bigdecimal.BigDecimal.ROUND_UP=0,u.bigdecimal.BigDecimal.__init__=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==on)t=new nL(new nG(n[0].toString()));else if("BigInteger number"==e)t=new tM(new nG(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new tr(new nG(n[0].toString()),n[1],new iM(n[2].toString()));else if("BigInteger MathContext"==e)t=new n3(new nG(n[0].toString()),new iM(n[1].toString()));else if(e==oM)t=new n4(t5(n[0].toString()));else if("array number number"==e)t=new eJ(t5(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tB(t5(n[0].toString()),n[1],n[2],new iM(n[3].toString()));else if("array MathContext"==e)t=new tA(t5(n[0].toString()),new iM(n[1].toString()));else if(e==oL)t=new ef(n[0]);else if(e==oU)t=new e_(n[0],new iM(n[1].toString()));else if(e==oH)t=new X(n[0].toString());else if("string MathContext"==e)t=new tN(n[0].toString(),new iM(n[1].toString()));else throw new nr("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nU(t)}(n);return nR(t)}),t.abs_va=fc(function(n){return nR(this.__gwt_instance.s(n))}),t.add_va=fc(function(n){return nR(this.__gwt_instance.t(n))}),t.byteValueExact=fc(function(){return this.__gwt_instance.u()}),t.compareTo=fc(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=fc(function(n){return nR(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=fc(function(n){return nR(this.__gwt_instance.x(n))}),t.doubleValue=fc(function(){return this.__gwt_instance.z()}),t.equals=fc(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=fc(function(){return this.__gwt_instance.A()}),t.hashCode=fc(function(){return this.__gwt_instance.hC()}),t.intValue=fc(function(){return this.__gwt_instance.B()}),t.intValueExact=fc(function(){return this.__gwt_instance.C()}),t.max=fc(function(n){return nR(this.__gwt_instance.F(n.__gwt_instance))}),t.min=fc(function(n){return nR(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=fc(function(n){return nR(this.__gwt_instance.H(n))}),t.movePointRight=fc(function(n){return nR(this.__gwt_instance.I(n))}),t.multiply_va=fc(function(n){return nR(this.__gwt_instance.J(n))}),t.negate_va=fc(function(n){return nR(this.__gwt_instance.K(n))}),t.plus_va=fc(function(n){return nR(this.__gwt_instance.L(n))}),t.pow_va=fc(function(n){return nR(this.__gwt_instance.M(n))}),t.precision=fc(function(){return this.__gwt_instance.q()}),t.remainder_va=fc(function(n){return nR(this.__gwt_instance.N(n))}),t.round=fc(function(n){return nR(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=fc(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=fc(function(n){return nR(this.__gwt_instance.Q(n))}),t.setScale_va=fc(function(n){return nR(this.__gwt_instance.R(n))}),t.shortValueExact=fc(function(){return this.__gwt_instance.S()}),t.signum=fc(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=fc(function(){return nR(this.__gwt_instance.T())}),t.subtract_va=fc(function(n){return nR(this.__gwt_instance.U(n))}),t.toBigInteger=fc(function(){return nR(this.__gwt_instance.V())}),t.toBigIntegerExact=fc(function(){return nR(this.__gwt_instance.W())}),t.toEngineeringString=fc(function(){return this.__gwt_instance.X()}),t.toPlainString=fc(function(){return this.__gwt_instance.Y()}),t.toString=fc(function(){return this.__gwt_instance.tS()}),t.ulp=fc(function(){return nR(this.__gwt_instance.Z())}),t.unscaledValue=fc(function(){return nR(this.__gwt_instance.$())}),t.divideAndRemainder_va=fc(function(n){return nO(this.__gwt_instance.w(n))}),t.longValue=fc(function(){return this.__gwt_instance.E()}),t.longValueExact=fc(function(){return this.__gwt_instance.D()}),u.bigdecimal.BigDecimal.valueOf_va=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==oL)t=function(n){if(!isFinite(n)||isNaN(n))throw new nd(oa);return new X(iV+n)}(n[0]);else if(e==oL)t=tX(e6(n[0]));else if(e==oP)t=eL(e6(n[0]),n[1]);else throw new nr("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nU(t)}(n);return nR(t)}),u.bigdecimal.BigDecimal.log=fc(function(n){iP(),typeof console!==o$&&console.log&&console.log(n)}),u.bigdecimal.BigDecimal.logObj=fc(function(n){iP(),typeof console!==o$&&console.log&&typeof JSON!==o$&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),u.bigdecimal.BigDecimal.ONE=fc(function(){var n=(iP(),new nU(uw));return nR(n)}),u.bigdecimal.BigDecimal.TEN=fc(function(){var n=(iP(),new nU(ud));return nR(n)}),u.bigdecimal.BigDecimal.ZERO=fc(function(){var n=(iP(),new nU(up));return nR(n)}),nS(fk,u.bigdecimal.BigDecimal)}())}function tL(n,t,e){var r;return(r=new I).d=n+t,r.c=4,r.b=e,r}function tU(n,t,e,r,i){var o;return tK(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tI(e)}(n.length,t,r),t3(n,t,r)}function tQ(n,t){return il(),t=n.c.c)throw new J;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tS(r,i),t.b[e]}function tF(n,t){return!!nz(t,1)&&String(n)==t}function tH(){nr.call(this,"Add not supported on this collection")}function t$(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function tV(n,t){rW(),this.f=n,this.e=1,this.b=tK(fp,{6:1},-1,[t])}function tq(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tG(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tz(n,t,e,r){var i,o;return null==t&&(t=ok),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tJ(n,t,e,r){var i;return rC(i=tU(fp,{6:1},-1,t,1),n,t,e,r),i}function tK(n,t,e,r){return tD(),function(n,t,e){tD();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tX(n){return rN(n,oJ)&&nv(n,oY)?us[nB(n)]:new eu(n,0)}function tY(n,t){return 0==t||0==n.f?n:t>0?e3(n,t):rY(n,-t)}function t1(n,t){return 0==t||0==n.f?n:t>0?rY(n,t):e3(n,-t)}function t0(n){var t;return 0==n.f?-1:((t=ew(n))<<5)+es(n.b[t])}function t2(n){var t;return 0!=(t=nB(n))?es(t):es(nB(rK(n,32)))+32}function t4(n,t){var e;return 0==(e=eO(n,t)).length?(new _).o(t):tg(e,1)}function t3(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t6(n,t,e,r){var i;return ib(i=tU(fp,{6:1},-1,t+1,1),n,t,e,r),i}function t5(n){var t,e;return t=tU(fK,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nB(y=iR(ta(e6(b.b[0]),o6),ta(e6(l.b[0]),o6))),0==(C=nB(rP(y,32)))?new tV(v,S):new to(v,2,tK(fp,{6:1},-1,[S,C]))):(eG(b.b,g,l.b,w,d=tU(fp,{6:1},-1,_,1)),tZ(m=new to(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=ia(t,a.eb(f)),o=ia(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iS(iS(u=n(ia(a,i),ia(o,h)),s),r)).eb(f),iS(iS(s=s.eb(f<<1),u),r))}(n,t))}function ee(n,t){var e;if(t.f<=0)throw new ni(or);return(e=rH(n,t)).f<0?iS(e,t):e}function er(n){var t;t=new nJ,n.d&&n5(t,new ne(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nA(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eP(n.g)),n.d).r()}function ep(n){return n.b<54?new ti(-n.g,n.f):new tx((n.d||(n.d=eP(n.g)),n.d).cb(),n.f)}function e_(n,t){if(!isFinite(n)||isNaN(n))throw new nd(oa);iQ(this,n.toPrecision(20)),is(this,t)}function ev(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function em(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function ey(n,t){var e,r;return t?((e=t[oC])||(e=new(r=t.gC(),t7(ei(n.b,r)))(t),t[oC]=e),e):null}function eC(n){var t,e;return 32==(e=r$(n.h))?32==(t=r$(n.m))?r$(n.l)+32:t+20-10:e-12}function eS(n){return ty(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eM(){eM=g,uo=ty(4194303,4194303,524287),uu=ty(0,0,524288),uf=e6(1),e6(2),uc=e6(0)}function ex(n,t){ib(n.b,n.b,n.e,t.b,t.e),n.e=np(n_(n.e,t.e)+1,n.b.length),tZ(n),n.c=-2}function eB(n,t){var e;e=~~t>>5,n.e+=e+(r$(n.b[n.e-1])-(31&t)>=0?0:1),rS(n.b,n.b,e,31&t),tZ(n),n.c=-2}function eA(n,t){var e,r;e=~~t>>5,n.e>>r:0,tZ(n))}function eN(n){var t;return t=n.e>1?th(rU(e6(n.b[1]),32),ta(e6(n.b[0]),o6)):ta(e6(n.b[0]),o6),iR(e6(n.f),t)}function eI(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:nv(ta(e6(n[r]),o6),ta(e6(t[r]),o6))?-1:1}function eE(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eR(n,t,e,r){if(iH=t,n)try{fc(iy)()}catch(i){n(t)}else fc(iy)()}function eO(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eu(oJ,2147483647):new eu(oJ,-2147483648)}function eP(n){return(rW(),n<0)?-1!=n?new ru(-1,-n):uS:n<=10?ux[eo(n)]:new ru(1,n)}function eQ(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,ty(t,e,r)}function eT(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function ej(n){var t,e,r;for(r=0,e=tU(fS,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rA(ta(e6(n[r]),o6),ta(e6(i[r]),o6));break}}return u=new to(1,o+1,n),e&&tR(u,t),tZ(u),u}(o,e)}function eV(n,t){var e;return n===t||!!nz(t,17)&&(e=tT(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eq(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&ew(n)==n.e-1&&(e=~~(e-1)),t-=r$(e))}function eG(n,t,e,r,i){il(),0!=t&&0!=r&&(1==t?i[r]=rc(i,e,r,n[0]):1==r?i[t]=rc(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nj(n)===nj(t)&&r==i){iu(n,r,e);return}for(f=0;f2147483647))return eo(n);throw new ni("Underflow")}function eW(n,t){if(rF(),n<0)throw new nu("Digits < 0");if(!t)throw new nc("null RoundingMode");this.b=n,this.c=t}function eZ(n){return(rW(),nv(n,oJ))?tm(n,oz)?new ro(-1,eQ(n)):uS:rA(n,oX)?new ro(1,n):ux[nB(n)]}function eX(n){var t;return nv(n,oJ)&&(n=ty(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nB(rK(n,32)))?r$(t):r$(nB(n))+32)}function eY(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e0(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-n_(e,n.bb())}function e2(n,t){var e;return n===t||!!nz(t,16)&&(e=tT(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e4(n,t,e){var r,i,o;for(o=oJ,r=t-1;r>=0;--r)i=r2(eY(rU(o,32),ta(e6(n[r]),o6)),e),o=e6(nB(rK(i,32)));return nB(o)}function e3(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rS(r=tU(fp,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tZ(o=new to(n.f,i,r)),o}function e6(n){var t,e;return n>-129&&n<128?(t=n+128,null==un&&(un=tU(fR,{6:1},2,256,0)),(e=un[t])||(e=un[t]=eS(n)),e):eS(n)}function e5(n){var t,e,r;return(rW(),n>5,t=31&n,(r=tU(fp,{6:1},-1,e+1,1))[e]=1<iq&&n[n.length-1]>iq?n:n.replace(/^(\s*)/,iV).replace(/\s*$/,iV)}function e8(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function rn(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==g||n$(e,1)))throw new V}return n[t]=e}function rt(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=e$(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=e$(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tU(f9,{6:1},17,8,0),a=n,rn(s,0,t),h=e$(t,t,r,i),u=1;u<=7;++u)rn(s,u,e$(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=e$(a,a,r,i);return a}(f,r,t,e,o),e$(u,(rW(),uM),e,o)}function ra(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nd("Radix out of range");if(0==n.length)throw new nd("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(ix(),uP)[e])),0!=(d=l%u)&&++o,c=tU(fp,{6:1},-1,o,1),r=uU[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:nv(ta(e6(n[i]),o6),ta(e6(t[i]),o6))?-1:1}function rg(n,t){var e,r,i;for(r=tU(fp,{6:1},-1,i=n.e,1),np(ew(n),ew(t)),e=0;e999999999)throw new ni(oh);return e=n.f*t,0==n.b&&-1!=n.g?eU(e):new tM((n.d||(n.d=eP(n.g)),n.d).db(t),eK(e))}function rp(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fu[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fo[n]=t,t*=.5}function rv(){rv=g,uO=tK(fK,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rm(n){var t;return 0!=n.c?n.c:n.b<54?(t=r4(n.g),n.c=nB(ta(t,oz)),n.c=33*n.c+nB(ta(rK(t,32),oz)),n.c=17*n.c+eo(n.f),n.c):(n.c=17*n.d.hC()+eo(n.f),n.c)}function ry(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=ev(n*t,0),0!=u&&(i=ev((u<=0?0-u:u)*2,t<=0?0-t:t),o+=it(1&eo(o),f*(5+i),r)),new ti(o,e)}function rC(n,t,e,r,i){var o,u;for(u=0,o=oJ;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rD(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=eo(nP(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eX(r4(n))}function rR(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eZ(rI(eN(e),eN(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rB(n,e),rB(t,r),1==rt(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eZ(rI(eN(n),eN(t)));break}if(t.e>1.2*n.e)0!=(t=rH(t,n)).r()&&rB(t,t.bb());else do tR(t,n),rB(t,t.bb());while(rt(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?eB(f,i):(rB(c,r-e0&&eB(f,i-r+e)),e+=i),0!=(i=e0(h,u))&&(eB(h,i),r>=e?eB(c,i):(rB(f,e-r0&&eB(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rq(s,h),rq(f,c)):(rq(h,s),rq(c,f)):e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)),0==h.r()||0==s.r())throw new ni(oe);return eD(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():ia(t,f)),0>f.r()&&(f=iS(f,t)),f}(n,t);for(o=32*t.e,h=eb(t),u=n_((b=eb(n)).e,h.e),c=new to(1,1,tU(fp,{6:1},-1,u+1,1)),(s=new to(1,1,tU(fp,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rB(h,r),rB(b,i),eB(c,i),e+=r-i):(rB(h,r),rB(b,i),eB(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rt(h,b)>0;)tR(h,b),a=h.bb(),rB(h,a),ex(c,s),eB(s,a),e+=a;for(;0>=rt(h,b)&&(tR(b,h),0!=b.r());)a=b.bb(),rB(b,a),ex(s,c),eB(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new ni(oe);return rt(c,t)>=0&&tR(c,t),c=ia(t,c),f=rf(t),e>o&&(c=e$(c,(rW(),uM),t,f),e-=o),c=e$(c,e5(o-e),t,f)}(ee(n._(),t),t)).f)throw new ni(oe);return n.f<0?ia(t,e):e}function rD(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rk(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eU(e):n.b+t.b<54?new ti(n.g*t.g,eK(e)):new tM(et((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),eK(e))}function rL(n,t){var e;if(t<0)throw new ni("Negative exponent");if(0==t)return uM;if(1==t||n.eQ(uM)||n.eQ(uA))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return et(e5(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(il(),rW(),r=uM,e=n;t>1;t>>=1)(1&t)!=0&&(r=et(r,e)),e=1==e.e?et(e,e):new e9(iu(e.b,e.e,tU(fp,{6:1},-1,e.e<<1,1)));return et(r,e)}(n,t)}function rU(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),ty(4194303&r,4194303&i,1048575&o)}function rQ(n){switch(iA(),n){case 2:return uX;case 1:return uY;case 3:return u1;case 5:return u0;case 6:return u2;case 4:return u4;case 7:return u3;case 0:return u6;default:throw new nu("Invalid rounding mode")}}function rT(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new ni(ol);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=ew(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rj(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ih((n.d||(n.d=eP(n.g)),n.d),im(t)).r()&&++t),n.e=eo(t)),n.e}function rF(){rF=g,uQ=new eW(34,(iA(),u2)),uT=new eW(7,u2),uj=new eW(16,u2),uF=new eW(0,u4),uH=tK(fK,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),u$=tK(fK,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rH(n,t){var e,r,i,o;if(0==t.f)throw new ni(ot);return((o=n.e)!=(e=t.e)?o>e?1:-1:eI(n.b,t.b,o))==-1?n:(r=tU(fp,{6:1},-1,e,1),1==e?r[0]=e4(n.b,o,t.b[0]):r=iL(null,o-e+1,n.b,o,t.b,e),tZ(i=new to(n.f,e,r)),i)}function r$(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16),e+=t=~~(r=(n=~~n>>t)-256)>>16&8,n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function rV(n,t){if(0==n.f)iB(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ib(n.b,n.b,n.e,t.b,t.e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rq(n,t){var e;e=rt(n,t),0==n.f?(iB(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ib(n.b,n.b,n.e,t.b,t.e),n.f=e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rG(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new ni(or);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uA:0==r.f&&0==t.f?uM:(t.f<0&&(r=rO(n,e),t=t.cb()),i=e.gb(0)?rs(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rs(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rW(),u=uM,i=eb(t),r=eb(n),n.gb(0)&&eA(i,e-1),eA(r,e),o=i.ab()-1;o>=0;--o)eA(f=eb(u),e),u=et(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eA(u=et(u,r),e);return eA(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e9(tU(fp,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eA(b=et(ia(h,a),s),f),b.f<0&&(b=iS(b,e5(f))),iS(a,et(c,b))),r.f<0&&t.gb(0)&&(i=ee(et(ia(e,uM),i),e)),i)}function rz(n,t){var e,r,i,o,u,f,c;if(i=ew(n),(r=ew(t))>=n.e)return rW(),uA;for(u=tU(fp,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=np(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new ti(n.g,eK(t)):new tM((n.d||(n.d=eP(n.g)),n.d),eK(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),ty(4194303&i,4194303&o,1048575&u)}function rW(){var n;for(n=0,rW=g,uM=new tV(1,1),uB=new tV(1,10),uA=new tV(0,0),uS=new tV(-1,1),ux=tK(f9,{6:1},17,[uA,uM,new tV(1,2),new tV(1,3),new tV(1,4),new tV(1,5),new tV(1,6),new tV(1,7),new tV(1,8),new tV(1,9),uB]),uN=tU(f9,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rW(),uS):(rW(),uA);if(rD(i=tU(fp,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rM(n,t,e):rM(t,n,-e):n_(n.b,t.b)+1<54?new ti(n.g+t.g,n.f):new tx(iS((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f)}function r2(n,t){var e,r,i,o,u;return(r=ta(e6(t),o6),rN(n,oJ))?(o=iI(n,r,!1),u=n6(n,r)):(o=iI(e=rP(n,1),i=e6(~~t>>>1),!1),u=eY(rU(u=n6(e,i),1),ta(n,oK)),(1&t)!=0&&(rA(o,u)?rA(e1(o,u),r)?(u=eY(u,e1(rU(r,1),o)),o=e1(o,oW)):(u=eY(u,e1(r,o)),o=e1(o,oK)):u=e1(u,o))),th(rU(u,32),ta(o,o6))}function r4(n){var t,e,r,i;return isNaN(n)?(eM(),uc):n<-0x8000000000000000?(eM(),uu):n>=0x7fffffffffffffff?(eM(),uo):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=eo(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=eo(n/4194304),n-=4194304*t),i=ty(eo(n),t,e),r&&eT(i),i)}function r3(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iW;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iJ+r3(eQ(n));for(e=n,r=iV;!(0==e.l&&0==e.m&&0==e.h);){if(e=iI(e,e6(1e9),!0),t=iV+nB(o8),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iW+t;r=t+r}return r}function r6(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new ni(ot);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iI(g=ta(e6(S[0]),o6),w=ta(e6(l),o6),!1),v=n6(g,w),x!=i&&(d=eQ(d)),x<0&&(v=eQ(v)),tK(f9,{6:1},17,[eZ(d),eZ(v)])):(_=tU(fp,{6:1},-1,M,1),m=tK(fp,{6:1},-1,[ii(_,S,M,l)]),y=new to(x==i?1:-1,M,_),C=new to(x,1,m),tZ(y),tZ(C),tK(f9,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eI(a,e,h))<0)?tK(f9,{6:1},17,[uA,n]):(b=n.f,f=iL(o=tU(fp,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new to(b==i?1:-1,u,o),s=new to(b,r,f),tZ(c),tZ(s),tK(f9,{6:1},17,[c,s]))}function r5(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eP(n.g)),n.d;if(n.f<0)return et((n.d||(n.d=eP(n.g)),n.d),im(-n.f));if(n.f>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eP(n.g)),n.d).bb()||0!=(t=r6((n.d||(n.d=eP(n.g)),n.d),im(n.f)))[1].r())throw new ni(og);return t[0]}function r9(n,t,e,r,i){var o,u;if(o=oJ,e36)throw new nd("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nd(os+n+iG);return i}function r8(n){var t,e;if(0==n.f)return rW(),uS;if(eV(n,(rW(),uS)))return uA;if(e=tU(fp,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function ie(n,t){var e,r,i,o,u,f,c,s,a;if(s=0==n.f?1:n.f,u=~~t>>5,e=31&t,f=tU(fp,{6:1},-1,c=n_(u+1,n.e)+1,1),r=1<=n.e)f[u]=r;else if(u>(i=ew(n)))f[u]^=r;else if(u=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rG(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rN(a=th(rU(s,32),ta(e6(t[f]),o6)),oJ)?(c=iI(a,o,!1),s=n6(a,o)):(c=iI(i=rP(a,1),u=e6(~~r>>>1),!1),s=eY(rU(s=n6(i,u),1),ta(a,oK)),(1&r)!=0&&(rA(c,s)?rA(e1(c,s),o)?(s=eY(s,e1(rU(o,1),c)),c=e1(c,oW)):(s=eY(s,e1(o,c)),c=e1(c,oK)):s=e1(s,c))),n[f]=nB(ta(c,o6));return nB(s)}function io(n,t){var e,r,i,o,u,f,c;if(u=tU(fp,{6:1},-1,f=n_(n.e,t.e),1),i=ew(n),e=r=ew(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=np(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=et(u,im(r))),rt(o,u))}function is(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r4(ul[r]),b=e1(r4(c.f),e6(r)),h=iI(g=r4(c.g),l,!1),tm(a=n6(g,l),oJ)&&(s=tv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?0:nv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?-1:1,h=eY(h,e6(it(1&nB(h),(tv(a,oJ)?0:nv(a,oJ)?-1:1)*(5+s),t.c))),tn(ri(nv(h,oJ)?eQ(h):h))>=t.b&&(h=nQ(h,oX),b=e1(b,oK))),c.f=eK(ri(b)),c.e=t.b,c.g=ri(h),c.b=eX(h),c.d=null;return}f=im(r),i=r6((n.d||(n.d=eP(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rt(eH(i[1]._()),f),0!=(e=it(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&rn(i,0,iS(i[0],eZ(e6(e)))),new nL(i[0]).q()>o&&(rn(i,0,ih(i[0],(rW(),uB))),--u)),n.f=eK(u),n.e=o,tO(n,i[0])}}function ia(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u<0&&(e=eQ(e)),c<0&&(r=eQ(r)),eZ(e1(e,r));if(-1==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))h=-c,a=u==c?tJ(t.b,f,n.b,o):t6(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rW(),uA;a=tJ(n.b,o,t.b,f)}else a=t6(n.b,o,t.b,f);return tZ(s=new to(h,a.length,a)),s}function ih(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new ni(ot);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nQ(ta(e6(n.b[0]),o6),ta(e6(t.b[0]),o6)),s!=i&&(a=eQ(a)),eZ(a)):0==(e=c!=r?c>r?1:-1:eI(n.b,t.b,c))?s==i?uM:uS:-1==e?uA:(o=tU(fp,{6:1},-1,u=c-r+1,1),1==r?ii(o,n.b,c,t.b[0]):iL(o,u,n.b,c,t.b,r),tZ(f=new to(s==i?1:-1,u,o)),f)}function ib(n,t,e,r,i){var o,u;if(o=eY(ta(e6(t[0]),o6),ta(e6(r[0]),o6)),n[0]=nB(o),o=rK(o,32),e>=i){for(u=1;u0){if(i0?u=tQ(u,eo(i)):i<0&&(o=tQ(o,eo(-i))),id(o,u,e,r)}function iw(n,t){var e,r,i,o,u,f,c;if(r=ew(t),(i=ew(n))>=t.e)return t;if(u=tU(fp,{6:1},-1,f=t.e,1),rt.ab()?(c=eN(s),o=eN(t),i=tv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?0:nv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?-1:1,i=it(f.gb(0)?1:0,a*(5+i),r)):(i=rt(eH(s._()),t._()),i=it(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return eL(eY(eN(f),e6(i)),e);f=iS(f,eZ(e6(i)))}return new tM(f,e)}function ip(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;if(ix(),(u=nv(n,oJ))&&(n=eQ(n)),tv(n,oJ))switch(t){case 0:return iW;case 1:return iX;case 2:return iY;case 3:return i1;case 4:return i0;case 5:return i2;case 6:return i4;default:return s=new W,t<0?s.b.b+=i6:s.b.b+=i3,b=s.b,l=-2147483648==t?"2147483648":iV+-t,b.b+=l,s.b.b}c=tU(fK,{6:1},-1,19,1),e=18,h=n;do f=h,h=nQ(h,oX),c[--e]=65535&nB(eY(o0,e1(f,iR(h,oX))));while(tm(h,oJ))if(r=e1(e1(e1(o1,e6(e)),e6(t)),oK),0==t)return u&&(c[--e]=45),tP(c,e,18-e);if(t>0&&rN(r,oG)){if(rN(r,oJ)){for(o=17,i=e+nB(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tP(c,e,18-e+1)}for(o=2;nv(e6(o),eY(eQ(r),oK));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tP(c,e,18-e)}return(a=e+1,s=new Z,u&&(s.b.b+=iJ),18-a>=1)?(tE(s,c[e]),s.b.b+=iK,g=s.b,w=tP(c,e+1,18-e-1),g.b+=w):(d=s.b,_=tP(c,e,18-e),d.b+=_),s.b.b+=oc,rA(r,oJ)&&(s.b.b+=iz),v=s.b,m=iV+r3(r),v.b+=m,s.b.b}(r4(n.g),eo(n.f)),n.i):(i=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new W).b,u.b+=i,n.f>0&&r>=-6?r>=0?n7(o,e-eo(n.f),iK):(te(o.b,t-1,t-1,iZ),n7(o,t+1,tP(ua,0,-eo(r)-1))):(e-t>=1&&(te(o.b,t,t,iK),++e),te(o.b,e,e,oc),r>0&&n7(o,++e,iz),n7(o,++e,iV+r3(r4(r)))),n.i=o.b.b,n.i)}function i_(n,t){var e,r,i,o,u,f;if(i=ew(n),o=ew(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==iV;)--s;s1e6)throw new ni("power of ten too big");if(n<=2147483647)return uV[1].db(t).eb(t);for(i=r=uV[1].db(2147483647),e=r4(n-2147483647),t=eo(n%2147483647);rA(e,o3);)i=et(i,r),e=e1(e,o3);for(i=(i=et(i,uV[1].db(t))).eb(2147483647),e=r4(n-2147483647);rA(e,o3);)i=i.eb(2147483647),e=e1(e,o3);return i.eb(t)}function iy(){var n,t;c&&rx("com.iriscouch.gwtapp.client.BigDecimalApp"),nZ(new K),nY(new j),nX(new F),tk(new H),c&&rx("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oT)?oT:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=o$)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oF:-1!=t.indexOf(oD)&&f.documentMode>=9?"ie9":-1!=t.indexOf(oD)&&f.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tF(oF,n)||u.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),c&&rx("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=f.compatMode,n=tK(fI,{6:1},1,[oo]);e>5,this.b=tU(fp,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tZ(this)}}function iS(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u==c)?(l=nB(s=eY(e,r)),0==(b=nB(rP(s,32)))?new tV(u,l):new to(u,2,tK(fp,{6:1},-1,[l,b]))):eZ(u<0?e1(r,e):e1(e,r));if(u==c)h=u,a=o>=f?t6(n.b,o,t.b,f):t6(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))return rW(),uA;1==i?(h=u,a=tJ(n.b,o,t.b,f)):(h=c,a=tJ(t.b,f,n.b,o))}return tZ(s=new to(h,a.length,a)),s}function iM(n){var t,e,r,i;if(rF(),null==n)throw new nc("null string");if((t=t5(n)).length<27||t.length>45)throw new nu(ox);for(r=0;rfe.length)throw new q;if(o=null,i=null,67==r[0]?(i=uX,o=u5):68==r[0]?(i=uY,o=u9):70==r[0]?(i=u1,o=u7):72==r[0]?e>6&&(68==r[5]?(i=u0,o=u8):69==r[5]?(i=u2,o=fn):85==r[5]&&(i=u4,o=ft)):85==r[0]&&(80==r[1]?(i=u6,o=fr):78==r[1]&&(i=u3,o=fe)),i&&e==o.length){for(t=1;tl||r+i>s)throw new G;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tT(n,11),o=tT(e,11),nj(n)===nj(e)&&tr;)rn(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eK(e+(o>u?o:u)),s=(i=o-u)>0?(il(),i>19!=0&&(t=eQ(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?es(b):0==h&&0!=l&&0==b?es(l)+22:0!=h&&0==l&&0==b?es(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rK(n,u),c&&eT(f),e&&(o8=ty(0,0,0)),f;n=nT((eM(),uo)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eQ(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rK(g,u),w&&eT(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eT(f),o&&(r?(o8=eQ(n),i&&(o8=e1(o8,(eM(),uf)))):o8=ty(n.l,n.m,n.h)),f}(r?n:ty(n.l,n.m,n.h),t,c,o,i,e):(e&&(o8=o?eQ(n):ty(n.l,n.m,n.h)),ty(0,0,0))}function iE(n){var t=[];for(var e in n){var r=typeof n[e];r!=oQ?t[t.length]=r:n[e]instanceof Array?t[t.length]=oM:u&&u.bigdecimal&&u.bigdecimal.BigInteger&&n[e]instanceof u.bigdecimal.BigInteger?t[t.length]=on:u&&u.bigdecimal&&u.bigdecimal.BigDecimal&&n[e]instanceof u.bigdecimal.BigDecimal?t[t.length]=i9:u&&u.bigdecimal&&u.bigdecimal.RoundingMode&&n[e]instanceof u.bigdecimal.RoundingMode?t[t.length]=ow:u&&u.bigdecimal&&u.bigdecimal.MathContext&&n[e]instanceof u.bigdecimal.MathContext?t[t.length]=ob:t[t.length]=oQ}return t.join(iq)}function iR(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,ty(b,l&=4194303,g&=1048575)}function iO(n,t,e){var r,i,o,u,f,c,s,a;if(a=ri(eY(e6(e.b),oW))+(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=um.length-1,s=tK(f9,{6:1},17,[(n.d||(n.d=eP(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iN(n,t);if(a>0&&(rn(s,0,et((n.d||(n.d=eP(n.g)),n.d),im(a))),c+=a),u=(s=r6(s[0],(t.d||(t.d=eP(t.g)),t.d)))[0],0!=s[1].r())r=rt(eH(s[1]),(t.d||(t.d=eP(t.g)),t.d)),u=iS(et(u,(rW(),uB)),eZ(e6(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r6(u,um[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?n_(n.b,t.b)+1<54?new ti(n.g-t.g,n.f):new tx(ia((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f):e>0?e0?t.e:nP((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rW(),r=uA;else if(0==o)r=ih((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d));else if(o>0)u=im(o),r=ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),u)),r=et(r,u);else{for(u=im(-o),r=ih(et((n.d||(n.d=eP(n.g)),n.d),u),(t.d||(t.d=eP(t.g)),t.d));!r.gb(0);)if(0==(f=r6(r,um[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nB(m=r2(eY(rU(ta(e6(w[h]),o6),32),ta(e6(w[h-1]),o6)),c)),v=nB(rK(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iR(ta(e6(s),o6),ta(e6(d[o-2]),o6)),y=eY(rU(e6(v),32),ta(e6(w[h-2]),o6)),32>r$(nB(rP(g=eY(ta(e6(v),o6),ta(e6(c),o6)),32)))?_=!0:v=nB(g)}while(rA(tb(l,oV),tb(y,oV)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oJ,u=oJ;f0)rn(b,0,ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),im(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,rn(b,0,et(b[0],im(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r6(et((n.d||(n.d=eP(n.g)),n.d),im(u)),(t.d||(t.d=eP(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nL(b[1]).q()+u-t.q())&&(rn(b,1,ih(et(b[1],im(u)),(t.d||(t.d=eP(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new ni(of);if(0==b[0].r())return eU(o);for(w=b[0],g=(c=new nL(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r6(w,um[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new ni(of);return c.f=eK(h),tO(c,w),c}function ij(){var n;for(n=0,ij=g,uJ=tK(fp,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uK=tU(f9,{6:1},17,(uW=tK(fp,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rN(n,oJ)?(e=nQ(n,o4),r=n6(n,o4)):(e=nQ(t=rP(n,1),o2),r=eY(rU(r=n6(t,o2),1),ta(n,oK))),th(rU(r,32),ta(e,o6))}(eY(rU(y,32),ta(e6(M[c]),o6))),M[c]=nB(w),y=e6(nB(rK(w,32)));d=nB(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tP(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tP(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tP(v,e,_-e)}return(S=e+1,m=new Z,h&&(m.b.b+=iJ),_-S>=1)?(tE(m,v[e]),m.b.b+=iK,I=m.b,E=tP(v,e+1,_-e-1),I.b+=E):(R=m.b,O=tP(v,e,_-e),R.b+=O),m.b.b+=oc,o>0&&(m.b.b+=iz),D=m.b,k=iV+o,D.b+=k,m.b.b}c&&c({moduleName:"gwtapp",sessionId:s,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iH,i$,iV="",iq=" ",iG='"',iz="+",iJ="-",iK=".",iW="0",iZ="0.",iX="0.0",iY="0.00",i1="0.000",i0="0.0000",i2="0.00000",i4="0.000000",i3="0E",i6="0E+",i5=":",i9="BigDecimal",i7="BigDecimal MathContext",i8="BigDecimal;",on="BigInteger",ot="BigInteger divide by zero",oe="BigInteger not invertible.",or="BigInteger: modulus not positive",oi="BigInteger;",oo="CSS1Compat",ou="Division by zero",of="Division impossible",oc="E",os='For input string: "',oa="Infinite or NaN",oh="Invalid Operation",ob="MathContext",ol="Negative bit address",og="Rounding necessary",ow="RoundingMode",od="RoundingMode;",op="String",o_="[Lcom.iriscouch.gwtapp.client.",ov="[Ljava.lang.",om="[Ljava.math.",oy="\\.",oC="__gwtex_wrap",oS="anonymous",oM="array",ox="bad string format",oB="bigdecimal",oA="com.google.gwt.core.client.",oN="com.google.gwt.core.client.impl.",oI="com.iriscouch.gwtapp.client.",oE="java.lang.",oR="java.math.",oO="java.util.",oD="msie",ok="null",oL="number",oU="number MathContext",oP="number number",oQ="object",oT="opera",oj="org.timepedia.exporter.client.",oF="safari",oH="string",o$="undefined",oV={l:0,m:0,h:524288},oq={l:0,m:4193280,h:1048575},oG={l:4194298,m:4194303,h:1048575},oz={l:4194303,m:4194303,h:1048575},oJ={l:0,m:0,h:0},oK={l:1,m:0,h:0},oW={l:2,m:0,h:0},oZ={l:5,m:0,h:0},oX={l:10,m:0,h:0},oY={l:11,m:0,h:0},o1={l:18,m:0,h:0},o0={l:48,m:0,h:0},o2={l:877824,m:119,h:0},o4={l:1755648,m:238,h:0},o3={l:4194303,m:511,h:0},o6={l:4194303,m:1023,h:0},o5={l:0,m:1024,h:0};(i$=a.prototype={}).eQ=function(n){return this===n},i$.gC=function(){return fs},i$.hC=function(){return nF(this)},i$.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tU(fK,{6:1},-1,8,1),rv(),e=7,n>=0)for(;n>15;)t[e--]=uO[15&n],n>>=4;else for(;e>0;)t[e--]=uO[15&n],n>>=4;return t[e]=uO[15&n],t3(t,e,8)}(this.hC())},i$.toString=function(){return this.tS()},i$.tM=g,i$.cM={},(i$=h.prototype=new a).gC=function(){return fh},i$.j=function(){return this.f},i$.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},i$.cM={6:1,15:1},i$.f=null,(i$=b.prototype=new h).gC=function(){return fb},i$.cM={6:1,15:1},(i$=nr.prototype=l.prototype=new b).gC=function(){return fl},i$.cM={6:1,12:1,15:1},(i$=n0.prototype=(function(){}).prototype=new l).gC=function(){return fg},i$.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?ok:tt(e)?null==(r=t7(e))?null:r.name:nz(e,1)?op:(nH(e)?e.gC():fw).d,this.b=tt(n=this.c)?null==(i=t7(n))?null:i.message:n+iV,this.d="("+this.e+"): "+this.b+(tt(t=this.c)?function(n){var t=iV;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t7(t)):iV)),this.d},i$.cM={6:1,12:1,15:1},i$.b=null,i$.c=null,i$.d=null,i$.e=null,(i$=w.prototype=new a).gC=function(){return fd};var o9=0,o7=0;(i$=d.prototype=(function(){}).prototype=new w).gC=function(){return fm},i$.b=null,i$.c=null,(i$=_.prototype=v.prototype=new a).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i5+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oS},i$.gC=function(){return fy},i$.o=function(n){return[]},(i$=m.prototype=new v).k=function(){return tg(this.o(td()),this.p())},i$.gC=function(){return fM},i$.o=function(n){return eO(this,n)},i$.p=function(){return 2},(i$=y.prototype=(function(){}).prototype=new m).k=function(){return ea(this)},i$.n=function(n){var t,e;return 0==n.length||(0==(e=e7(n)).indexOf("at ")&&(e=n8(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oS:(-1!=(t=(e=e7(e.substr(0,t-0))).indexOf("."))&&(e=n8(e,t+1)),e.length>0?e:oS)},i$.gC=function(){return fx},i$.o=function(n){return t4(this,n)},i$.p=function(){return 3},(i$=C.prototype=new a).gC=function(){return fB},(i$=S.prototype=(function(){}).prototype=new C).gC=function(){return fA},i$.b=iV,(i$=M.prototype=(function(){}).prototype=new a).gC=function(){return this.aC},i$.aC=null,i$.qI=0;var o8=null,un=null;(i$=x.prototype=(function(){}).prototype=new a).gC=function(){return fE},i$.cM={2:1},(i$=B.prototype=new a).gC=function(){return fO},i$.cM={6:1,10:1};var ut=null;(i$=eu.prototype=ti.prototype=tx.prototype=tN.prototype=X.prototype=e_.prototype=ef.prototype=tA.prototype=tB.prototype=eJ.prototype=n4.prototype=n3.prototype=tr.prototype=tM.prototype=nL.prototype=A.prototype=new B).eQ=function(n){return e2(this,n)},i$.gC=function(){return fD},i$.hC=function(){return rm(this)},i$.q=function(){return rj(this)},i$.r=function(){return ed(this)},i$.tS=function(){return ip(this)},i$.cM={6:1,8:1,10:1,16:1},i$.b=0,i$.c=0,i$.d=null,i$.e=0,i$.f=0,i$.g=0,i$.i=null;var ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_,uv=null,um=null,uy=null;(i$=nU.prototype=nw.prototype=(function(){}).prototype=new A).s=function(n){var t,e,r;if((e=iE(n))==iV)t=0>ed(this)?ep(this):this;else if(e==ob)t=0>(r=t8(this,new iM(n[0].toString()))).r()?ep(r):r;else throw new nr("Unknown call signature for interim = super.abs: "+e);return new nU(t)},i$.t=function(n){var t,e;if((e=iE(n))==i9)t=r0(this,new X(n[0].toString()));else if(e==i7)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t8(r0(n,t),e);if((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)0?t.e:nP((t.b-1)*.3010299956639812)+1)<-r-1))return t8(r0(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nP((i.b-1)*.3010299956639812)+1)?t8(r0(n,t),e):(f=(o=i.r())==u.r()?iS(rZ((i.d||(i.d=eP(i.g)),i.d),10),eZ(e6(o))):iS(rZ(f=ia((i.d||(i.d=eP(i.g)),i.d),eZ(e6(o))),10),eZ(e6(9*o))),t8(i=new tx(f,i.f+1),e))}(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.add: "+e);return new nU(t)},i$.u=function(){return~~(nB(en(this,8))<<24)>>24},i$.v=function(n){return ic(this,n)},i$.w=function(n){var t,e,r,i;if((i=iE(n))==i9)e=el(this,new X(n[0].toString()));else if(i==i7)e=eg(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tU(fL,{6:1},3,e.length,0);t129?n*=1/0:n=t9(ip(this)),n},i$.gC=function(){return fk},i$.hC=function(){return rm(this)},i$.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nP((this.b-1)*.3010299956639812)+1)?0:(n=new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))).f*n.b[0]},i$.C=function(){return nB(en(this,32))},i$.D=function(){return nB(en(this,32))},i$.E=function(){return t9(ip(this))},i$.F=function(n){return new nU(ic(this,n)>=0?this:n)},i$.G=function(n){return new nU(0>=ic(this,n)?this:n)},i$.H=function(n){return new nU(rJ(this,this.f+n))},i$.I=function(n){return new nU(rJ(this,this.f-n))},i$.J=function(n){var t,e;if((e=iE(n))==i9)t=rk(this,new X(n[0].toString()));else if(e==i7)t=tl(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.multiply: "+e);return new nU(t)},i$.K=function(n){var t,e;if((e=iE(n))==iV)t=ep(this);else if(e==ob)t=ep(t8(this,new iM(n[0].toString())));else throw new nr("Unknown call signature for interim = super.negate: "+e);return new nU(t)},i$.L=function(n){var t,e;if((e=iE(n))==iV)t=this;else if(e==ob)t=t8(this,new iM(n[0].toString()));else throw new nr("Unknown call signature for interim = super.plus: "+e);return new nU(t)},i$.M=function(n){var t,e;if((e=iE(n))==oL)t=rd(this,n[0]);else if(e==oU)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=eo(tn(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rd(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new ni(oh);for(u>0&&(f=new eW(u+i+1,e.c)),r=t8(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tl(r,r,f),(o&c)==c&&(r=tl(r,n,f)),c>>=1;return t<0&&(r=iO(uw,r,f)),is(r,e),r}(this,n[0],new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.pow: "+e);return new nU(t)},i$.q=function(){return rj(this)},i$.N=function(n){var t,e;if((e=iE(n))==i9)t=el(this,new X(n[0].toString()))[1];else if(e==i7)t=eg(this,new X(n[0].toString()),new iM(n[1].toString()))[1];else throw new nr("Unknown call signature for interim = super.remainder: "+e);return new nU(t)},i$.O=function(n){return new nU(t8(this,new iM(eh(n.b))))},i$.P=function(){return eo(this.f)},i$.Q=function(n){var t,e;return new nU((t=this,(e=t.f-n,t.b<54)?0==t.g?eU(e):new ti(t.g,eK(e)):new tM((t.d||(t.d=eP(t.g)),t.d),eK(e))))},i$.R=function(n){var t,e;if((e=iE(n))==oL)t=r1(this,n[0],(iA(),u3));else if(e==oP)t=r1(this,n[0],rQ(n[1]));else if("number RoundingMode"==e)t=r1(this,n[0],ts(n[1].toString()));else throw new nr("Unknown call signature for interim = super.setScale: "+e);return new nU(t)},i$.S=function(){return~~(nB(en(this,16))<<16)>>16},i$.r=function(){return ed(this)},i$.T=function(){return new nU(function(n){var t,e,r,i,o;if(t=1,e=um.length-1,r=n.f,0==n.b&&-1!=n.g)return new X(iW);for(n.d||(n.d=eP(n.g)),o=n.d;!o.gb(0);)if(0==(i=r6(o,um[t]))[1].r())r-=t,t0?i.e:nP((i.b-1)*.3010299956639812)+1)0?r.e:nP((r.b-1)*.3010299956639812)+1)?(f=(c=ed(r))!=i.r()?iS(rZ((r.d||(r.d=eP(r.g)),r.d),10),eZ(e6(c))):iS(rZ(f=ia((r.d||(r.d=eP(r.g)),r.d),eZ(e6(c))),10),eZ(e6(9*c))),t8(new tx(f,r.f+1),o)):t8(iD(r,i),o);else throw new nr("Unknown call signature for interim = super.subtract: "+e);return new nU(t)},i$.V=function(){return new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))},i$.W=function(){return new n2(r5(this))},i$.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nq(u),n.f>0&&i>=-6)i>=0?n7(c,r-eo(n.f),iK):(te(c.b,t-1,t-1,iZ),n7(c,t+1,tP(ua,0,-eo(i)-1)));else{if(e=r-t,0!=(f=eo(i%3))&&(0==(n.d||(n.d=eP(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n7(c,r++,iW);r-t>=1&&(te(c.b,t,t,iK),++r),0!=i&&(te(c.b,r,r,oc),i>0&&n7(c,++r,iz),n7(c,++r,iV+r3(r4(i))))}return c.b.b}(this)},i$.Y=function(){return function(n){var t,e,r,i,o,u;if(r=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ed(n)?1:0,e=n.f,i=new Z(r.length+1+((o=eo(n.f))<0?-o:o)),1==t&&(i.b.b+=iJ),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iZ;e>ua.length;e-=ua.length)tG(i,ua);n9(i,ua,eo(e)),nE(i,n8(r,t))}else nE(i,(u=eo(e=t-e),r.substr(t,u-t))),i.b.b+=iK,nE(i,n8(r,eo(e)))}else{for(nE(i,n8(r,t));e<-ua.length;e+=ua.length)tG(i,ua);n9(i,ua,eo(-e))}return i.b.b}(this)},i$.tS=function(){return ip(this)},i$.Z=function(){return new nU(new ti(1,this.f))},i$.$=function(){return new n2((this.d||(this.d=eP(this.g)),this.d))},i$.cM={3:1,6:1,8:1,10:1,16:1,24:1},(i$=H.prototype=(function(){}).prototype=new a).gC=function(){return fU};var uC=!1;(i$=ru.prototype=ro.prototype=to.prototype=e9.prototype=tV.prototype=rh.prototype=nG.prototype=iC.prototype=N.prototype=new B)._=function(){return this.f<0?new to(1,this.e,this.b):this},i$.ab=function(){return eq(this)},i$.eQ=function(n){return eV(this,n)},i$.gC=function(){return fP},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.cb=function(){return 0==this.f?this:new to(-this.f,this.e,this.b)},i$.db=function(n){return rL(this,n)},i$.eb=function(n){return tY(this,n)},i$.fb=function(n){return t1(this,n)},i$.r=function(){return this.f},i$.gb=function(n){return rT(this,n)},i$.tS=function(){return iF(this,0)},i$.cM={6:1,8:1,10:1,17:1},i$.b=null,i$.c=-2,i$.d=0,i$.e=0,i$.f=0;var uS,uM,ux,uB,uA,uN=null;(i$=n2.prototype=nD.prototype=nk.prototype=(function(){}).prototype=new N)._=function(){return new n2(this.f<0?new to(1,this.e,this.b):this)},i$.hb=function(n){return new n2(iS(this,n))},i$.ib=function(n){return new n2(0==n.f||0==this.f?(rW(),uA):eV(n,(rW(),uS))?this:eV(this,uS)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=np(n.e,t.e),(e=n_(ew(n),ew(t)))>=i)return rW(),uA;for(r=tU(fp,{6:1},-1,i,1);e0?rz(n,this):this.e>n.e?i_(this,n):i_(n,this))},i$.jb=function(n){return new n2(0==n.f?this:0==this.f?(rW(),uA):eV(this,(rW(),uS))?new n2(r8(n)):eV(n,uS)?uA:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tU(fp,{6:1},-1,n.e,1),r=np(n.e,t.e),e=ew(n);e=n.e)return n;for(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=ew(n),o=ew(t),i>=t.e)return n;if(c=n_(n.e,t.e),r=i,o>i){for(f=tU(fp,{6:1},-1,c,1),u=np(n.e,o);r=t.e)return rW(),uA;if(u=tU(fp,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},i$.qb=function(n){return new n2(rR(this,n))},i$.gC=function(){return fQ},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.B=function(){return this.f*this.b[0]},i$.rb=function(n){return function(n,t){var e,r;if(ij(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rT(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uW,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n2(this.f<0?new to(1,this.e,this.b):this),n)},i$.sb=function(){return t9(iF(this,0))},i$.tb=function(n){return new n2(1==rt(this,n)?this:n)},i$.ub=function(n){return new n2(-1==rt(this,n)?this:n)},i$.vb=function(n){return new n2(ee(this,n))},i$.wb=function(n){return new n2(rO(this,n))},i$.xb=function(n,t){return new n2(rG(this,n,t))},i$.yb=function(n){return new n2(et(this,n))},i$.cb=function(){return new n2(0==this.f?this:new to(-this.f,this.e,this.b))},i$.zb=function(){return new n2(function(n){if(n.f<0)throw new ni("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(ij(),o=tU(fp,{6:1},-1,uW.length,1),r=tU(fv,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uW[e];++e);return uK[e]}for(f=new to(1,n.e,tU(fp,{6:1},-1,n.e+1,1)),iB(n.b,0,f.b,0,n.e),rT(n,0)?tW(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iw(this,n):n.f>0?iw(n,this):ew(n)>ew(this)?rX(n,this):rX(this,n))},i$.db=function(n){return new n2(rL(this,n))},i$.Cb=function(n){return new n2(rH(this,n))},i$.Db=function(n){return new n2(rT(this,n)?this:ie(this,n))},i$.eb=function(n){return new n2(tY(this,n))},i$.fb=function(n){return new n2(t1(this,n))},i$.r=function(){return this.f},i$.Eb=function(n){return new n2(ia(this,n))},i$.gb=function(n){return rT(this,n)},i$.Fb=function(n){var t,e;if((e=iE(n))==iV)t=iF(this,0);else if(e==oL)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(ix(),g=n.f,s=n.e,u=n.b,0==g)return iW;if(1==s)return _=ta(e6(u[0]),o6),g<0&&(_=eQ(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return iV+r3(n);if(e=tU(fK,{6:1},-1,65,1),rv(),r=64,i=e6(t),rN(n,oJ)){for(;rN(n,i);)e[r--]=uO[nB(n6(n,i))],n=iI(n,i,!1);e[r]=uO[nB(n)]}else{for(;!rA(n,eQ(i));)e[r--]=uO[nB(eQ(n6(n,i)))],n=iI(n,i,!1);e[r--]=uO[nB(eQ(n))],e[r]=45}return t3(e,r,65)}(_,t);if(10==t||t<2||t>36)return iF(n,0);if(l=tU(fK,{6:1},-1,b=eo(eq(new n2(n.f<0?new to(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(iB(u,0,w=tU(fp,{6:1},-1,s,1),0,s),d=s,r=uP[t],e=uU[t-2];;){h=ii(w,w,d,e),a=i;do l[--i]=em(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=em(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tP(l,i,b-i)}(this,n[0]);else throw new nr("Unknown call signature for result = super.toString: "+e);return t},i$.Gb=function(n){return new n2(0==n.f?this:0==this.f?n:eV(n,(rW(),uS))?new n2(r8(this)):eV(this,uS)?new n2(r8(n)):this.f>0?n.f>0?this.e>n.e?rw(this,n):rw(n,this):iU(this,n):n.f>0?iU(n,this):ew(n)>ew(this)?io(n,this):io(this,n))},i$.cM={4:1,6:1,8:1,10:1,17:1,24:1},(i$=F.prototype=(function(){}).prototype=new a).gC=function(){return fj};var uI=!1;(i$=nm.prototype=ny.prototype=(function(){}).prototype=new a).gC=function(){return fF},i$.Hb=function(){return this.b.b},i$.Ib=function(){return new nn(this.b.c)},i$.hC=function(){return nx(this.b)},i$.tS=function(){return eh(this.b)},i$.cM={24:1},i$.b=null,(i$=j.prototype=(function(){}).prototype=new a).gC=function(){return fH};var uE=!1;(i$=nn.prototype=nC.prototype=(function(){}).prototype=new a).gC=function(){return f$},i$.Jb=function(){return this.b.b},i$.tS=function(){return this.b.b},i$.cM={5:1,24:1},i$.b=null,(i$=K.prototype=(function(){}).prototype=new a).gC=function(){return fq};var uR=!1;(i$=ni.prototype=(function(){}).prototype=new l).gC=function(){return fG},i$.cM={6:1,12:1,15:1},(i$=no.prototype=V.prototype=(function(){}).prototype=new l).gC=function(){return fJ},i$.cM={6:1,12:1,15:1},(i$=I.prototype=(function(){}).prototype=new a).gC=function(){return fW},i$.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?iV:"class ")+this.d},i$.b=null,i$.c=0,i$.d=null,(i$=$.prototype=(function(){}).prototype=new l).gC=function(){return fZ},i$.cM={6:1,12:1,15:1},(i$=E.prototype=new a).eQ=function(n){return this===n},i$.gC=function(){return fa},i$.hC=function(){return nF(this)},i$.tS=function(){return this.b},i$.cM={6:1,8:1,9:1},i$.b=null,i$.c=0,(i$=nu.prototype=q.prototype=R.prototype=new l).gC=function(){return fX},i$.cM={6:1,12:1,15:1},(i$=nf.prototype=G.prototype=O.prototype=new l).gC=function(){return fz},i$.cM={6:1,12:1,15:1},(i$=nc.prototype=z.prototype=(function(){}).prototype=new l).gC=function(){return fY},i$.cM={6:1,12:1,15:1},(i$=nd.prototype=(function(){}).prototype=new R).gC=function(){return f1},i$.cM={6:1,12:1,15:1},(i$=tu.prototype=(function(){}).prototype=new a).gC=function(){return fC},i$.tS=function(){return this.b+iK+this.d+"(Unknown Source"+(this.c>=0?i5+this.c:iV)+")"},i$.cM={6:1,13:1},i$.b=null,i$.c=0,i$.d=null,(i$=String.prototype).eQ=function(n){return tF(this,n)},i$.gC=function(){return fN},i$.hC=function(){var n,t;return nK(),null!=(t=uk[n=i5+this])?t:(null==(t=uD[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;e Date: Fri, 21 Oct 2022 09:47:03 +0900 Subject: [PATCH 10/27] More work for `can_drop_op_for` --- crates/swc_ecma_minifier/src/compress/optimize/sequences.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index a99560c2785b..88b4f73e1dcd 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -2481,7 +2481,7 @@ pub(crate) fn is_trivial_lit(e: &Expr) -> bool { /// This assumes `a.left.to_id() == b.left.to_id()` fn can_drop_op_for(a: AssignOp, b: AssignOp) -> bool { if a == b { - return matches!(a, op!("+=") | op!("-=")); + return matches!(a, op!("+=") | op!("-=") | op!("*=")); } false From 7e9e17bdec5088aa90df42e2632cd19b551f7731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 09:51:38 +0900 Subject: [PATCH 11/27] Update test refs --- ...compoundArithmeticAssignmentLHSCanBeAssigned.2.minified.js | 4 ++-- ...poundArithmeticAssignmentWithInvalidOperands.2.minified.js | 4 ++-- crates/swc/tests/tsc-references/symbolType12.2.minified.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/swc/tests/tsc-references/compoundArithmeticAssignmentLHSCanBeAssigned.2.minified.js b/crates/swc/tests/tsc-references/compoundArithmeticAssignmentLHSCanBeAssigned.2.minified.js index 151a7a11605e..48114687327c 100644 --- a/crates/swc/tests/tsc-references/compoundArithmeticAssignmentLHSCanBeAssigned.2.minified.js +++ b/crates/swc/tests/tsc-references/compoundArithmeticAssignmentLHSCanBeAssigned.2.minified.js @@ -1,5 +1,5 @@ //// [compoundArithmeticAssignmentLHSCanBeAssigned.ts] -var E, a, b, c, x1, x2, x3; +var E; !function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c"; -}(E || (E = {})), x1 *= a, x1 *= b, x1 *= c, x1 *= null, x1 *= void 0, x2 *= a, x2 *= b, x2 *= c, x2 *= null, x2 *= void 0, x3 *= a, x3 *= b, x3 *= c, x3 *= null, x3 *= void 0; +}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/compoundArithmeticAssignmentWithInvalidOperands.2.minified.js b/crates/swc/tests/tsc-references/compoundArithmeticAssignmentWithInvalidOperands.2.minified.js index 3f95057d3f37..bd2c3407ae1b 100644 --- a/crates/swc/tests/tsc-references/compoundArithmeticAssignmentWithInvalidOperands.2.minified.js +++ b/crates/swc/tests/tsc-references/compoundArithmeticAssignmentWithInvalidOperands.2.minified.js @@ -1,5 +1,5 @@ //// [compoundArithmeticAssignmentWithInvalidOperands.ts] -var E, a, b, x1, x2, x3, x4, x5, x6; +var E; !function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), x1 *= a, x1 *= b, x1 *= !0, x1 *= 0, x1 *= "", x1 *= E.a, x1 *= {}, x1 *= null, x1 *= void 0, x2 *= a, x2 *= b, x2 *= !0, x2 *= 0, x2 *= "", x2 *= E.a, x2 *= {}, x2 *= null, x2 *= void 0, x3 *= a, x3 *= b, x3 *= !0, x3 *= 0, x3 *= "", x3 *= E.a, x3 *= {}, x3 *= null, x3 *= void 0, x4 *= a, x4 *= b, x4 *= !0, x4 *= 0, x4 *= "", x4 *= E.a, x4 *= {}, x4 *= null, x4 *= void 0, x5 *= b, x5 *= !0, x5 *= "", x5 *= {}, x6 *= b, x6 *= !0, x6 *= "", x6 *= {}; +}(E || (E = {})), E.a, E.a, E.a, E.a; diff --git a/crates/swc/tests/tsc-references/symbolType12.2.minified.js b/crates/swc/tests/tsc-references/symbolType12.2.minified.js index 6edefe0d09e6..e8b58eddada4 100644 --- a/crates/swc/tests/tsc-references/symbolType12.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolType12.2.minified.js @@ -1,3 +1,3 @@ //// [symbolType12.ts] var s = Symbol.for("assign"), str = ""; -s *= s, s *= 0, s /= s, s /= 0, s %= s, s %= 0, str += s = "0", s -= 0, s <<= s, s <<= 0, s >>= s, s >>= 0, s >>>= s, s >>>= 0, s &= s, s &= 0, s ^= s, s ^= 0, s |= s, s |= 0, str += s || str; +s *= 0, s /= s, s /= 0, s %= s, s %= 0, str += s = "0", s -= 0, s <<= s, s <<= 0, s >>= s, s >>= 0, s >>>= s, s >>>= 0, s &= s, s &= 0, s ^= s, s ^= 0, s |= s, s |= 0, str += s || str; From c624d48f064113b1f1d93f318faa48f0e0288bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 10:11:45 +0900 Subject: [PATCH 12/27] More op --- .../src/compress/optimize/sequences.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index 88b4f73e1dcd..7787e0ff4102 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -2290,8 +2290,15 @@ where } Expr::Assign(b) => { if let Some(b_left) = b.left.as_ident() { - if let Mergable::Expr(Expr::Assign(AssignExpr { op: a_op, .. })) = a { - if can_drop_op_for(*a_op, b.op) { + let a_op = match a { + Mergable::Var(_) => Some(op!("=")), + Mergable::Expr(Expr::Assign(AssignExpr { op: a_op, .. })) => Some(*a_op), + Mergable::FnDecl(_) => Some(op!("=")), + _ => None, + }; + + if let Some(a_op) = a_op { + if can_drop_op_for(a_op, b.op) { if b_left.to_id() == left_id.to_id() { if let Some(bin_op) = b.op.to_update() { report_change!( From 428bf1a47fdb035cdf6896c7a198b3605a6da5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 10:12:12 +0900 Subject: [PATCH 13/27] lhs == `op!("=")` --- crates/swc_ecma_minifier/src/compress/optimize/sequences.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index 7787e0ff4102..2104be3b9075 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -2487,6 +2487,10 @@ pub(crate) fn is_trivial_lit(e: &Expr) -> bool { /// This assumes `a.left.to_id() == b.left.to_id()` fn can_drop_op_for(a: AssignOp, b: AssignOp) -> bool { + if a == op!("=") { + return true; + } + if a == b { return matches!(a, op!("+=") | op!("-=") | op!("*=")); } From f2498518589ea68ee38d2f617f611a971a0db656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 10:14:41 +0900 Subject: [PATCH 14/27] Update test refs --- .../swc/tests/tsc-references/symbolType12.2.minified.js | 2 +- crates/swc_ecma_minifier/tests/benches-full/echarts.js | 8 ++++---- crates/swc_ecma_minifier/tests/benches-full/terser.js | 4 ++-- .../tests/fixture/issues/2257/full/output.js | 4 ++-- .../swc_ecma_minifier/tests/fixture/issues/5280/output.js | 3 +-- .../tests/fixture/issues/firebase-core/1/output.js | 2 +- .../tests/fixture/issues/firebase-firestore/1/output.js | 2 +- .../tests/fixture/issues/react-countup/1/output.js | 3 +-- .../tests/fixture/issues/react-countup/2/output.js | 3 +-- .../static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js | 8 ++++---- .../static/chunks/pages/index-cb36c1bf7f830e3c/output.js | 4 ++-- .../react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js | 4 ++-- .../tests/fixture/next/react-pdf-renderer/output.js | 4 ++-- .../next/syncfusion/933-e9f9a6bf671b96fc/output.js | 8 ++++---- .../tests/fixture/next/wrap-contracts/output.js | 8 ++++---- .../feedback-mapbox/2c796e83-0724e2af5f19128a/output.js | 2 ++ .../tests/full/issue-5912-bigdecimal/output.js | 1 + crates/swc_ecma_minifier/tests/pass-1/compute/1/output.js | 6 +++--- .../tests/pass-default/compute/1/output.js | 5 +---- .../tests/projects/output/angular-1.2.5.js | 2 +- .../tests/projects/output/jquery.mobile-1.4.2.js | 2 +- 21 files changed, 41 insertions(+), 44 deletions(-) diff --git a/crates/swc/tests/tsc-references/symbolType12.2.minified.js b/crates/swc/tests/tsc-references/symbolType12.2.minified.js index e8b58eddada4..4a820b8ce4bb 100644 --- a/crates/swc/tests/tsc-references/symbolType12.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolType12.2.minified.js @@ -1,3 +1,3 @@ //// [symbolType12.ts] var s = Symbol.for("assign"), str = ""; -s *= 0, s /= s, s /= 0, s %= s, s %= 0, str += s = "0", s -= 0, s <<= s, s <<= 0, s >>= s, s >>= 0, s >>>= s, s >>>= 0, s &= s, s &= 0, s ^= s, s ^= 0, s |= s, s |= 0, str += s || str; +s *= 0, s /= s, s /= 0, s %= s, s %= 0, str += s = s + 0 + "", s -= 0, s <<= s, s <<= 0, s >>= s, s >>= 0, s >>>= s, s >>>= 0, s &= s, s &= 0, s ^= s, s ^= 0, s |= s, s |= 0, str += s || str; diff --git a/crates/swc_ecma_minifier/tests/benches-full/echarts.js b/crates/swc_ecma_minifier/tests/benches-full/echarts.js index 61e060ea4ec3..9fbe8f06ab74 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/echarts.js +++ b/crates/swc_ecma_minifier/tests/benches-full/echarts.js @@ -12349,7 +12349,7 @@ function decodePolygon(coordinate, encodeOffsets, encodeScale) { for(var result = [], prevX = encodeOffsets[0], prevY = encodeOffsets[1], i = 0; i < coordinate.length; i += 2){ var x = coordinate.charCodeAt(i) - 64, y = coordinate.charCodeAt(i + 1) - 64; - x = x >> 1 ^ -(1 & x), y = y >> 1 ^ -(1 & y), x += prevX, y += prevY, prevX = x, prevY = y, result.push([ + y = y >> 1 ^ -(1 & y), x = (x >> 1 ^ -(1 & x)) + prevX, y += prevY, prevX = x, prevY = y, result.push([ x / encodeScale, y / encodeScale ]); @@ -15423,17 +15423,17 @@ case 'half-year': case 'quarter': case 'month': - approxInterval1 = approxInterval, interval = (approxInterval1 /= 2592000000) > 6 ? 6 : approxInterval1 > 3 ? 3 : approxInterval1 > 2 ? 2 : 1, getterName = monthGetterName(isUTC), setterName = monthSetterName(isUTC); + interval = (approxInterval1 = approxInterval / 2592000000) > 6 ? 6 : approxInterval1 > 3 ? 3 : approxInterval1 > 2 ? 2 : 1, getterName = monthGetterName(isUTC), setterName = monthSetterName(isUTC); break; case 'week': case 'half-week': case 'day': - approxInterval2 = approxInterval, interval = (approxInterval2 /= 86400000) > 16 ? 16 : approxInterval2 > 7.5 ? 7 : approxInterval2 > 3.5 ? 4 : approxInterval2 > 1.5 ? 2 : 1, getterName = dateGetterName(isUTC), setterName = dateSetterName(isUTC); + interval = (approxInterval2 = approxInterval / 86400000) > 16 ? 16 : approxInterval2 > 7.5 ? 7 : approxInterval2 > 3.5 ? 4 : approxInterval2 > 1.5 ? 2 : 1, getterName = dateGetterName(isUTC), setterName = dateSetterName(isUTC); break; case 'half-day': case 'quarter-day': case 'hour': - approxInterval3 = approxInterval, interval = (approxInterval3 /= 3600000) > 12 ? 12 : approxInterval3 > 6 ? 6 : approxInterval3 > 3.5 ? 4 : approxInterval3 > 2 ? 2 : 1, getterName = hoursGetterName(isUTC), setterName = hoursSetterName(isUTC); + interval = (approxInterval3 = approxInterval / 3600000) > 12 ? 12 : approxInterval3 > 6 ? 6 : approxInterval3 > 3.5 ? 4 : approxInterval3 > 2 ? 2 : 1, getterName = hoursGetterName(isUTC), setterName = hoursSetterName(isUTC); break; case 'minute': interval = getMinutesAndSecondsInterval(approxInterval, !0), getterName = minutesGetterName(isUTC), setterName = minutesSetterName(isUTC); diff --git a/crates/swc_ecma_minifier/tests/benches-full/terser.js b/crates/swc_ecma_minifier/tests/benches-full/terser.js index 0f8d8b800dae..4d1db85a4610 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/terser.js +++ b/crates/swc_ecma_minifier/tests/benches-full/terser.js @@ -1912,8 +1912,8 @@ base && base.PROPS && (props = props.concat(base.PROPS)); for(var code = "return function AST_" + type + "(props){ if (props) { ", i = props.length; --i >= 0;)code += "this." + props[i] + " = props." + props[i] + ";"; const proto = base && Object.create(base.prototype); - (proto && proto.initialize || methods && methods.initialize) && (code += "this.initialize();"), code = "}this.flags = 0;"; - var ctor = Function(code += "}")(); + (proto && proto.initialize || methods && methods.initialize) && (code += "this.initialize();"); + var ctor = Function(code = "}this.flags = 0;}")(); if (proto && (ctor.prototype = proto, ctor.BASE = base), base && base.SUBCLASSES.push(ctor), ctor.prototype.CTOR = ctor, ctor.prototype.constructor = ctor, ctor.PROPS = props || null, ctor.SELF_PROPS = self_props, ctor.SUBCLASSES = [], type && (ctor.prototype.TYPE = ctor.TYPE = type), methods) for(i in methods)HOP(methods, i) && ("$" === i[0] ? ctor[i.substr(1)] = methods[i] : ctor.prototype[i] = methods[i]); return ctor.DEFMETHOD = function(name, method) { this.prototype[name] = method; 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 a23ffaf6fe4f..395e6231ef93 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 @@ -6035,7 +6035,7 @@ if (number != number) return "NaN"; if (number <= -1000000000000000000000 || number >= 1e21) return String(number); if (number < 0 && (sign = "-", number = -number), number > 1e-21) { - if (z = (e = log(number * pow(2, 69, 1)) - 69) < 0 ? number * pow(2, -e, 1) : number / pow(2, e, 1), z *= 0x10000000000000, (e = 52 - e) > 0) { + if (z = ((e = log(number * pow(2, 69, 1)) - 69) < 0 ? number * pow(2, -e, 1) : number / pow(2, e, 1)) * 0x10000000000000, (e = 52 - e) > 0) { for(multiply(data, 0, z), j = fractDigits; j >= 7;)multiply(data, 1e7, 0), j -= 7; for(multiply(data, pow(10, j, 1), 0), j = e - 1; j >= 23;)divide(data, 8388608), j -= 23; divide(data, 1 << j), multiply(data, 1, 1), divide(data, 2), result = dataToString(data); @@ -16028,7 +16028,7 @@ }, _proto.componentWillReceiveProps = function(nextProps) { if (this.props.value !== nextProps.value) { var changedBits, oldValue = this.props.value, newValue = nextProps.value; - (oldValue === newValue ? 0 !== oldValue || 1 / oldValue == 1 / newValue : oldValue != oldValue && newValue != newValue) ? changedBits = 0 : (changedBits = "function" == typeof calculateChangedBits ? calculateChangedBits(oldValue, newValue) : 1073741823, 0 != (changedBits |= 0) && this.emitter.set(nextProps.value, changedBits)); + (oldValue === newValue ? 0 !== oldValue || 1 / oldValue == 1 / newValue : oldValue != oldValue && newValue != newValue) ? changedBits = 0 : 0 != (changedBits = ("function" == typeof calculateChangedBits ? calculateChangedBits(oldValue, newValue) : 1073741823) | 0) && this.emitter.set(nextProps.value, changedBits); } }, _proto.render = function() { return this.props.children; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/5280/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/5280/output.js index 0f7b8a6d5db0..b0173968afac 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/5280/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/5280/output.js @@ -1,4 +1,3 @@ export function source() { - let c = 0, a = 1; - console.log(a += 5, c += 1, c); + console.log(6, 1, 1); } 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 2fede38b1aec..2315adb9faa4 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 @@ -1287,7 +1287,7 @@ d = !0; } d || (b1 = "", xa(c, function(c, d) { - b1 = d + ":", b1 = c + "\r\n"; + b1 = d + ":" + c + "\r\n"; }), c = b1, "string" == typeof a ? null != c && encodeURIComponent(String(c)) : R(a, b, c)); } function Hd(a, b, c) { 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 30836716d8ad..78378fc7b17b 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 @@ -838,7 +838,7 @@ const e = t; if (null === e.A) { let t1 = e.path.canonicalString(); - null !== e.collectionGroup && (t1 += "|cg:" + e.collectionGroup), t1 = "|f:" + e.filters.map((t)=>t.field.canonicalString() + t.op.toString() + xt(t.value)).join(","), t1 = "|ob:" + e.orderBy.map((t)=>t.field.canonicalString() + t.dir).join(","), At(e.limit) || (t1 = "|l:" + e.limit), e.startAt && (t1 = "|lb:" + ce(e.startAt)), e.endAt && (t1 = "|ub:" + ce(e.endAt)), e.A = t1; + null !== e.collectionGroup && (t1 += "|cg:" + e.collectionGroup), t1 = "|f:" + e.filters.map((t)=>t.field.canonicalString() + t.op.toString() + xt(t.value)).join(",") + "|ob:" + e.orderBy.map((t)=>t.field.canonicalString() + t.dir).join(","), At(e.limit) || (t1 = "|l:" + e.limit), e.startAt && (t1 = "|lb:" + ce(e.startAt)), e.endAt && (t1 = "|ub:" + ce(e.endAt)), e.A = t1; } return e.A; } diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/1/output.js index 327d9927f784..6b218fd6d114 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/1/output.js @@ -35,8 +35,7 @@ var i = t - s.startTime; s.remaining = s.duration - i, s.useEasing ? s.countDown ? s.frameVal = s.startVal - s.easingFn(i, 0, s.startVal - s.endVal, s.duration) : s.frameVal = s.easingFn(i, s.startVal, s.endVal - s.startVal, s.duration) : s.countDown ? s.frameVal = s.startVal - (s.startVal - s.endVal) * (i / s.duration) : s.frameVal = s.startVal + (s.endVal - s.startVal) * (i / s.duration), s.countDown ? s.frameVal = s.frameVal < s.endVal ? s.endVal : s.frameVal : s.frameVal = s.frameVal > s.endVal ? s.endVal : s.frameVal, s.frameVal = Number(s.frameVal.toFixed(s.options.decimalPlaces)), s.printValue(s.frameVal), i < s.duration ? s.rAF = requestAnimationFrame(s.count) : null !== s.finalEndVal ? s.update(s.finalEndVal) : s.callback && s.callback(); }, this.formatNumber = function(t) { - i = Math.abs(t).toFixed(s.options.decimalPlaces); - var i, a, n, e, o = (i += "").split("."); + var a, n, e, o = (Math.abs(t).toFixed(s.options.decimalPlaces) + "").split("."); if (a = o[0], n = o.length > 1 ? s.options.decimal + o[1] : "", s.options.useGrouping) { e = ""; for(var l = 0, h = a.length; l < h; ++l)0 !== l && l % 3 == 0 && (e = s.options.separator + e), e = a[h - l - 1] + e; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/2/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/2/output.js index f4ae2a5f44e8..e3ee4e51fe06 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/2/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/react-countup/2/output.js @@ -1,6 +1,5 @@ export function formatNumber(t) { - i = Math.abs(t).toFixed(s.options.decimalPlaces); - var i, a, n, e, o = (i += "").split("."); + var a, n, e, o = (Math.abs(t).toFixed(s.options.decimalPlaces) + "").split("."); if (a = o[0], n = o.length > 1 ? s.options.decimal + o[1] : "", s.options.useGrouping) { e = ""; for(var l = 0, h = a.length; l < h; ++l)0 !== l && l % 3 == 0 && (e = s.options.separator + e), e = a[h - l - 1] + e; 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 ad20db0abdd3..35ef1fa43160 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 @@ -8766,7 +8766,7 @@ }, calculateTrackBaseMediaDecodeTime: function(track, keepOriginalTimestamps) { var baseMediaDecodeTime, minSegmentDts = track.minSegmentDts; - return keepOriginalTimestamps || (minSegmentDts -= track.timelineStartInfo.dts), baseMediaDecodeTime = track.timelineStartInfo.baseMediaDecodeTime, baseMediaDecodeTime += minSegmentDts, baseMediaDecodeTime = Math.max(0, baseMediaDecodeTime), "audio" === track.type && (baseMediaDecodeTime *= track.samplerate / ONE_SECOND_IN_TS$3, baseMediaDecodeTime = Math.floor(baseMediaDecodeTime)), baseMediaDecodeTime; + return keepOriginalTimestamps || (minSegmentDts -= track.timelineStartInfo.dts), baseMediaDecodeTime = Math.max(0, baseMediaDecodeTime = track.timelineStartInfo.baseMediaDecodeTime + minSegmentDts), "audio" === track.type && (baseMediaDecodeTime *= track.samplerate / ONE_SECOND_IN_TS$3, baseMediaDecodeTime = Math.floor(baseMediaDecodeTime)), baseMediaDecodeTime; }, collectDtsInfo: function(track, data) { "number" == typeof data.pts && (void 0 === track.timelineStartInfo.pts && (track.timelineStartInfo.pts = data.pts), void 0 === track.minSegmentPts ? track.minSegmentPts = data.pts : track.minSegmentPts = Math.min(track.minSegmentPts, data.pts), void 0 === track.maxSegmentPts ? track.maxSegmentPts = data.pts : track.maxSegmentPts = Math.max(track.maxSegmentPts, data.pts)), "number" == typeof data.dts && (void 0 === track.timelineStartInfo.dts && (track.timelineStartInfo.dts = data.dts), void 0 === track.minSegmentDts ? track.minSegmentDts = data.dts : track.minSegmentDts = Math.min(track.minSegmentDts, data.dts), void 0 === track.maxSegmentDts ? track.maxSegmentDts = data.dts : track.maxSegmentDts = Math.max(track.maxSegmentDts, data.dts)); @@ -9204,7 +9204,7 @@ ]), (0x10 & data) == 0x10 && (this.column_ = ((0xe & data) >> 1) * 4), this.isColorPAC(char1) && (0xe & char1) == 0xe && this.addFormatting(packet.pts, [ "i" ]); - } else this.isNormalChar(char0) && (0x00 === char1 && (char1 = null), text = getCharFromCode(char0), text += getCharFromCode(char1), this[this.mode_](packet.pts, text), this.column_ += text.length); + } else this.isNormalChar(char0) && (0x00 === char1 && (char1 = null), text = getCharFromCode(char0) + getCharFromCode(char1), this[this.mode_](packet.pts, text), this.column_ += text.length); } }; }; @@ -9357,7 +9357,7 @@ }); return; } - if (buffer.push(chunk), bufferSize += chunk.data.byteLength, 1 === buffer.length && (tagSize = parseSyncSafeInteger$1(chunk.data.subarray(6, 10)), tagSize += 10), !(bufferSize < tagSize)) { + if (buffer.push(chunk), bufferSize += chunk.data.byteLength, 1 === buffer.length && (tagSize = parseSyncSafeInteger$1(chunk.data.subarray(6, 10)) + 10), !(bufferSize < tagSize)) { for(i = 0, tag = { data: new Uint8Array(tagSize), frames: [], @@ -10248,7 +10248,7 @@ return result += String.fromCharCode(buffer[0]), result += String.fromCharCode(buffer[1]), result += String.fromCharCode(buffer[2]), result += String.fromCharCode(buffer[3]); }, toUnsigned$2 = bin.toUnsigned, findBox_1 = function findBox(data, path) { }, parseType$1 = function(buffer) { - return String.fromCharCode(buffer[0]), String.fromCharCode(buffer[1]), String.fromCharCode(buffer[2]) + String.fromCharCode(buffer[3]); + return String.fromCharCode(buffer[0]) + String.fromCharCode(buffer[1]) + String.fromCharCode(buffer[2]) + String.fromCharCode(buffer[3]); }, toUnsigned$2 = bin.toUnsigned, findBox = function findBox(data, path) { var i, size, type, end, subresults, results = []; if (!path.length) return null; 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 44fcab2173bb..e7b0858a363d 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 @@ -68,7 +68,7 @@ }, BigInt(0)); if (void 0 !== _ref$signed && _ref$signed) { var max = BYTE_TABLE[bytes.length] / BigInt(2) - BigInt(1); - (number = BigInt(number)) > max && (number = max - max, number -= BigInt(2)); + (number = BigInt(number)) > max && (number = max - max - BigInt(2)); } return Number(number); }, numberToBytes = function(number, _temp2) { @@ -4557,7 +4557,7 @@ ], size = "width"; } var size, step = boxPosition.lineHeight, position = step * Math.round(linePos), maxPosition = containerBox[size] + step, initialAxis = axis[0]; - Math.abs(position) > maxPosition && (position = position < 0 ? -1 : 1, position *= Math.ceil(maxPosition / step) * step), linePos < 0 && (position += "" === cue.vertical ? containerBox.height : containerBox.width, axis = axis.reverse()), boxPosition.move(initialAxis, position); + Math.abs(position) > maxPosition && (position = (position < 0 ? -1 : 1) * (Math.ceil(maxPosition / step) * step)), linePos < 0 && (position += "" === cue.vertical ? containerBox.height : containerBox.width, axis = axis.reverse()), boxPosition.move(initialAxis, position); } else { var calculatedPercentage = boxPosition.lineHeight / containerBox.height * 100; switch(cue.lineAlign){ 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 cf17b6fca85a..a774c401756f 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 @@ -826,7 +826,7 @@ selectionStart = range.start.row < row - 1 ? 0 : selectionStart, selectionEnd += prevLine.length + 1, line = prevLine + "\n" + line; } else if (range.end.row != row) { var nextLine = host.session.getLine(row + 1); - selectionEnd = range.end.row > row + 1 ? nextLine.length : selectionEnd, selectionEnd += line.length + 1, line = line + "\n" + nextLine; + selectionEnd = (range.end.row > row + 1 ? nextLine.length : selectionEnd) + (line.length + 1), line = line + "\n" + nextLine; } else isMobile && row > 0 && (line = "\n" + line, selectionEnd += 1, selectionStart += 1); line.length > 400 && (selectionStart < 400 && selectionEnd < 400 ? line = line.slice(0, 400) : (line = "\n", selectionStart == selectionEnd ? selectionStart = selectionEnd = 0 : (selectionStart = 0, selectionEnd = 1))); } @@ -9025,7 +9025,7 @@ function stringifyDelta(d) { if (Array.isArray(d = d || this)) return d.map(stringifyDelta).join("\n"); var type = ""; - return d.action ? (type = "insert" == d.action ? "+" : "-", type += "[" + d.lines + "]") : d.value && (type = Array.isArray(d.value) ? d.value.map(stringifyRange).join("\n") : stringifyRange(d.value)), d.start && (type += stringifyRange(d)), (d.id || d.rev) && (type += "\t(" + (d.id || d.rev) + ")"), type; + return d.action ? type = ("insert" == d.action ? "+" : "-") + "[" + d.lines + "]" : d.value && (type = Array.isArray(d.value) ? d.value.map(stringifyRange).join("\n") : stringifyRange(d.value)), d.start && (type += stringifyRange(d)), (d.id || d.rev) && (type += "\t(" + (d.id || d.rev) + ")"), type; } function stringifyRange(r) { return r.start.row + ":" + r.start.column + "=>" + r.end.row + ":" + r.end.column; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js index 59fb776550d9..49ee3f86efac 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js @@ -9241,12 +9241,12 @@ var n = r(7507); e.exports = function(e, t, r) { var i, o, a, u; - return e = function(e) { + return "#" + n(e = function(e) { var t, r; for(e = (r = e = (t = e) > 1e7 ? 1e7 : t) < -10000000 ? -10000000 : r; e < 0;)e += 360; for(; e > 359;)e -= 360; return e; - }(e), t = (o = (i = t) > 100 ? 100 : i) < 0 ? 0 : o, r = (u = (a = r) > 100 ? 100 : a) < 0 ? 0 : u, "#" + n(e, t /= 100, r /= 100).map(function(e) { + }(e), t = ((o = (i = t) > 100 ? 100 : i) < 0 ? 0 : o) / 100, r = ((u = (a = r) > 100 ? 100 : a) < 0 ? 0 : u) / 100).map(function(e) { return (256 + e).toString(16).substr(-2); }).join(""); }; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js b/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js index db3c61384752..caa7b287097e 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/syncfusion/933-e9f9a6bf671b96fc/output.js @@ -2637,7 +2637,7 @@ else if ('timeZone' !== prop || util_isUndefined(matchString)) matchString = 'month' !== prop || parseOptions.isIslamic || 'en' !== parseOptions.culture && 'en-GB' !== parseOptions.culture && 'en-US' !== parseOptions.culture ? matchString : matchString[0].toUpperCase() + matchString.substring(1).toLowerCase(), retOptions[prop] = parseOptions[prop][matchString]; else { var pos = curObject.pos, val = void 0, tmatch = matches[pos + 1], flag = !util_isUndefined(tmatch); - curObject.hourOnly ? val = 60 * this.getZoneValue(flag, tmatch, matches[pos + 4], num) : (val = 60 * this.getZoneValue(flag, tmatch, matches[pos + 7], num), val += this.getZoneValue(flag, matches[pos + 4], matches[pos + 10], num)), util_isNullOrUndefined(val) || (retOptions[prop] = val); + util_isNullOrUndefined(val = curObject.hourOnly ? 60 * this.getZoneValue(flag, tmatch, matches[pos + 4], num) : 60 * this.getZoneValue(flag, tmatch, matches[pos + 7], num) + this.getZoneValue(flag, matches[pos + 4], matches[pos + 10], num)) || (retOptions[prop] = val); } } return parseOptions.hour12 && (retOptions.hour12 = !0), retOptions; @@ -16092,7 +16092,7 @@ svg.style.width = svg.style.height = radius + 'px'; for(var startArc = 90, item = 0; item <= 7; item++){ var start = defineArcPoints(0, 0, 24, startArc), circleEle = svg.querySelector('.' + CLS_SPINCIRCLE + '_' + item); - circleEle.setAttribute('cx', start.x + ''), circleEle.setAttribute('cy', start.y + ''), startArc = startArc >= 360 ? 0 : startArc, startArc += 45; + circleEle.setAttribute('cx', start.x + ''), circleEle.setAttribute('cy', start.y + ''), startArc = (startArc >= 360 ? 0 : startArc) + 45; } }(innerContainer, radius); break; @@ -19185,7 +19185,7 @@ }, Toolbar.prototype.itemWidthCal = function(items) { var style, _this = this, width = 0; return [].slice.call((0, ej2_base.td)('.' + CLS_ITEM, items)).forEach(function(el) { - (0, ej2_base.pn)(el) && (style = window.getComputedStyle(el), width = (_this.isVertical ? el.offsetHeight : el.offsetWidth) + parseFloat(_this.isVertical ? style.marginTop : style.marginRight), width += parseFloat(_this.isVertical ? style.marginBottom : style.marginLeft)); + (0, ej2_base.pn)(el) && (style = window.getComputedStyle(el), width = (_this.isVertical ? el.offsetHeight : el.offsetWidth) + parseFloat(_this.isVertical ? style.marginTop : style.marginRight) + parseFloat(_this.isVertical ? style.marginBottom : style.marginLeft)); }), width; }, Toolbar.prototype.getScrollCntEle = function(innerItem) { var trgClass = this.isVertical ? '.e-vscroll-content' : '.e-hscroll-content'; @@ -19368,7 +19368,7 @@ }), rVal; }, i = len - 1; i >= 0; i--){ var mrgn = void 0, compuStyle = window.getComputedStyle(inEle[i]); - this.isVertical ? (mrgn = parseFloat(compuStyle.marginTop), mrgn += parseFloat(compuStyle.marginBottom)) : (mrgn = parseFloat(compuStyle.marginRight), mrgn += parseFloat(compuStyle.marginLeft)); + mrgn = this.isVertical ? parseFloat(compuStyle.marginTop) + parseFloat(compuStyle.marginBottom) : parseFloat(compuStyle.marginRight) + parseFloat(compuStyle.marginLeft); var fstEleCheck = inEle[i] === this.tbarEle[0]; fstEleCheck && (this.tbarEleMrgn = mrgn), eleOffset = this.isVertical ? inEle[i].offsetHeight : inEle[i].offsetWidth; var eleWid_1 = fstEleCheck ? eleOffset + mrgn : eleOffset; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js b/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js index 0bce540d2d44..4d11a0c9fb7d 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js @@ -13605,15 +13605,15 @@ return al + bl >>> 0; } function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { - var carry = 0, lo = al; - return carry = ((lo = lo + bl >>> 0) < al ? 1 : 0) + ((lo = lo + cl >>> 0) < cl ? 1 : 0), ah + bh + ch + dh + (carry += (lo = lo + dl >>> 0) < dl ? 1 : 0) >>> 0; + var carry, lo = al; + return ah + bh + ch + dh + (carry = 0 + ((lo = lo + bl >>> 0) < al ? 1 : 0) + ((lo = lo + cl >>> 0) < cl ? 1 : 0) + ((lo = lo + dl >>> 0) < dl ? 1 : 0)) >>> 0; } function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { return al + bl + cl + dl >>> 0; } function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { - var carry = 0, lo = al; - return carry = ((lo = lo + bl >>> 0) < al ? 1 : 0) + ((lo = lo + cl >>> 0) < cl ? 1 : 0), ah + bh + ch + dh + eh + (carry = ((lo = lo + dl >>> 0) < dl ? 1 : 0) + ((lo = lo + el >>> 0) < el ? 1 : 0)) >>> 0; + var carry, lo = al; + return ah + bh + ch + dh + eh + (carry = 0 + ((lo = lo + bl >>> 0) < al ? 1 : 0) + ((lo = lo + cl >>> 0) < cl ? 1 : 0) + ((lo = lo + dl >>> 0) < dl ? 1 : 0) + ((lo = lo + el >>> 0) < el ? 1 : 0)) >>> 0; } function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { return al + bl + cl + dl + el >>> 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 a8399ed602eb..7c23436ed0fc 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 @@ -6,6 +6,8 @@ Filter Expression: ${JSON.stringify(n,null,2)} `)}const a=tr[`filter_${r}`],l=i9(o,a);let c=null;if("error"===l.result)throw Error(l.value.map(i=>`${i.key}: ${i.message}`).join(", "));c=(i,r,n)=>l.value.evaluate(i,r,{},n);let h=null,u=null;if(o!==n){const d=i9(n,a);if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));h=(i,r,n,o,s)=>d.value.evaluate(i,r,{},n,void 0,void 0,o,s),u=!t8(d.value.expression)}return{filter:c,dynamicFilter:h||void 0,needGeometry:function i(r){if(!Array.isArray(r))return!1;if("within"===r[0])return!0;for(let n=1;n",">=","<","<=","to-boolean"]);function rp(i,r){return ir?1:0}function rf(i,r,n){switch(i){case"$type":return[`filter-type-${n}`,r];case"$id":return[`filter-id-${n}`,r];default:return[`filter-${n}`,i,r]}}function rm(i,r){if(0===r.length)return!1;switch(i){case"$type":return["filter-type-in",["literal",r]];case"$id":return["filter-id-in",["literal",r]];default:return r.length>200&&!r.some(i=>typeof i!=typeof r[0])?["filter-in-large",i,["literal",r.sort(rp)]]:["filter-in-small",i,["literal",r]]}}function r_(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function rg(i){return["!",i]}function ry(i){if(rc(tl(i.value))){const r=tl(i.layerType);return ra(ts({},i,{expressionContext:"filter",valueSpec:i.styleSpec[`filter_${r||"fill"}`]}))}return function i(r){const n=r.value,o=r.key;if("array"!==iJ(n))return[new tn(o,n,`array expected, ${iJ(n)} found`)];const s=r.styleSpec;let a,l=[];if(n.length<1)return[new tn(o,n,"filter array must have at least 1 element")];switch(l=l.concat(rl({key:`${o}[0]`,value:n[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),ta(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===ta(n[1])&&l.push(new tn(o,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":3!==n.length&&l.push(new tn(o,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&"string"!==(a=iJ(n[1]))&&l.push(new tn(`${o}[1]`,n[1],`string expected, ${a} found`));for(let c=2;c{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[3*i+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=n?-(i*N)+Math.PI:i*N,s*=.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),s(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` +Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i,d=3*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[d+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=n?-(i*N)+Math.PI:i*N,s*=.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),o(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` +Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,H({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return eo(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:eo(r))}getTransition(i){return eo(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=eo(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=Z(Math.floor(i),0,255))+Z(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i,d=3*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[d+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return ei(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(ei(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),en(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&ea(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(q(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const c=1<{const n=o8((r.x+i.x/s)/c),o=o9((r.y+i.y/s)/c),a=p.project(n,o);i.x=(a.x*h-u)*s,i.y=(a.y*h-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,c,m,u,d),i(r,p,f,s,a,m,h,u,d)):r.push(h)}(c,o,s,u,d,a,h,r,1):c.push(h),o=u,s=d,a=h}return c}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=Z(n,se,16383),i.y=Z(o,se,16383),(ni.x+1||oi.y+1)&&ea("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const c=[new l(r,n),new l(r,s),new l(o,s),new l(o,n)];if(i.length>2){for(const h of c)if(su(i,h))return!0}for(let u=0;us.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=el(i,r,n[0]);return a!==el(i,r,n[1])||a!==el(i,r,n[2])||a!==el(i,r,n[3])}(i[u],i[u+1],c))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=l.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const c=[];for(let h=0;h{var a,l;const c=D([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=A([],z([],E([],a[i[0]],a[i[1]]),E([],a[i[2]],a[i[1]]))),n=-C(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=I([],T([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=v(this.min),o=v(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,c,h,u){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(u*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(h),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=D([],[i.x,i.y,r,1],n);return new l(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=x();return sw[2]=r,i.intersectsPlane(sw,sT,n),new l(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,v=D([],[p.x,p.y,_,1],o);if(!c&&a?u*=v[3]/n.cameraToCenterDistance:c&&!a&&(u*=n.cameraToCenterDistance/v[3]),f=u,su(y,g)||sl(g,y,f))return!0}return!1}const sw=w(0,0,0),sT=w(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,c=0,h=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),c+=i.readSVarint(),1===o&&(r&&h.push(r),r=[]),r.push(new l(a,c));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&h.push(r),h},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new l(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new l(i.x,i.y),this.max=new l(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new l(0,0)}span(){return new l(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=H({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),h&&p.equals(h[h.length-1])||(h=[p],a.push(h)),h.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,c=a.pixelRatio,h=a.paddedRect.w-2,u=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,h]],m=a.stretchY||[[0,u]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=h-g,v=u-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,h,u)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(h.stretch-b)/w*d+i.left,C=h.fixed-S-I*h.stretch/g,z=(u.stretch-T)/E*p+i.top,k=u.fixed-M-A*u.stretch/y,P=new l(f,_),D=new l(v,_),L=new l(v,z),B=new l(f,z),R=new l(m/c,x/c),F=new l(C/c,k/c),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:h.stretch+h.fixed-j,h:u.stretch+u.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/c/d,minFontScaleY:A/c/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new l(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,c,h,u,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,c,h){const u=[];if(0===r.positionedLines.length)return u;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=c[b.imageName];if(!k)continue;if(k.sdf){ea("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||h)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;h&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new l(-D,D-j),Z=-Math.PI/2,$=new l(...O);(w=new l(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new l(w.x,w.y-V),E=new l(w.x+N,w.y),S=new l(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new l(W,H),T=new l(K,H),E=new l(W,Y),S=new l(K,Y)}if(d){let J;J=s?new l(0,0):U?new l(p[0],p[1]):new l(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new l(0,0),ee=new l(0,0);u.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return u}(0,o,u,a,c,h,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(h,{},x)])[0]>32640&&ea(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(h,{},x),128*g.compositeTextSizes[1].evaluate(h,{},x)])[0]>32640||w[1]>32640)&&ea(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,u,c,h,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,c,h,u,d){let p=c.top,f=c.bottom,m=c.left,_=c.right;const g=c.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),u){const y=new l(m,p),x=new l(_,p),v=new l(m,f),b=new l(_,f),w=u*O;let T=new l(0,0);d&&(T=new l(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,h,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=p([]),this.placementViewportMatrix=p([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=w(0,0,1),f=B(L());return o=f,s=(n?-(i*O)+Math.PI:i*O)*.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,R(f,f,-(r*O)),P(p,p,f),A(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,h){const u=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,c,h,!0,!0,new l(0,0),u)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,h,u){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=h&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=u+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var c,h;if(i.queryGeometry.isAboveHorizon)return!1;const u=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(c=this.paint.get("line-width").evaluate(r,n),(h=this.paint.get("line-gap-width").evaluate(r,n))>0?h+2*c:c),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new l(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return ea("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=h.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],et(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ec(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ec();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return W(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new l(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new l(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ex.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ex.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ex.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;X(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=H({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return er(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new l(0,0),new l(8193,0),new l(8193,8193),new l(0,8193),new l(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=Y(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,c,h,u;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&ea(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=er(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(c&&h&&u){const i=new c9(c),r=new a4(h,u);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,c,h,u,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),h),f["text-size"].possiblyEvaluate(new nk(g),h)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),h),f["icon-size"].possiblyEvaluate(new nk(x),h)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(u+1),h),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(u+1),h),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),h);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},h).join(","),E=b.evaluate(w,{},h),S=m.layoutTextSize.evaluate(w,{},h),I=(m.layoutIconSize.evaluate(w,{},h),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},h),P=24*p.get("text-line-height").evaluate(w,{},h),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},h),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},h);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},h).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},h);const U=p.get("symbol-placement"),V="point"===U,N="point"===U?24*p.get("text-max-width").evaluate(w,{},h):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,N,P,L,o,D,C,a6.vertical,!0,U,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,N,P,L,F,D,C,a6.horizontal,!1,U,S,E);W&&(I.horizontal[F]=W)}j("point"===U?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},h),p.get("icon-anchor").evaluate(w,{},h)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&ea("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,c,h,u,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=c);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=c/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*O,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,h)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,h),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&ea(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&ea(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&ea("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,u,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const U of s1(r.geometry,0)){const V=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,c=-1/0;const h=i[0];for(let u=0;ua)&&(a=d.x),(!u||d.y>c)&&(c=d.y)}const p=Math.min(a-o,c-s);let f=p/2;const m=new lb([],lT);if(0===p)return new l(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(U,16);P(U[0],new lc(V.x,V.y,0,0,void 0),f)}else if("LineString"===r.type)for(const N of r.geometry)P(N,new lc(N[0].x,N[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,c,h,d)}a&&i.generateCollisionDebugBuffers(u,i.collisionBoxArray)}(d,c,i.positions,h,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:W(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?c:null,iconMap:this.returnDependencies?h:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,u=r,L.call(this))},void 0,!1,z):u={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=p(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=p(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,_(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return m(a,a,[n,o,0]),_(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new l(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*O,hc=85.051129*O,hh={albers:{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&&F(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*O),r=(i+Math.sin(this.parallels[1]*O))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*O,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*O))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*O*n;l=q(l,-Math.PI-c,Math.PI-c);const h=l/n*U+this.center[0],u=Math.asin(Z((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=Z(u*U,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=Z(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=Z(180*h/Math.PI,-180,180),p=Z(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=Z(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&F(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*O,r=this.parallels[1]*O,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=O,i=(i-this.center[0])*O;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=Z(c/n*U+this.center[0],-180,180),u=Z((2*Math.atan(Math.pow(o/l,1/n))-hs)*U,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=O)*r,o=n*n;return{x:.5*((i*=O)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=Z(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=Z(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*U,-180,180),h=n*U;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=O,i*=O;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=Z(n-a,-Math.PI,Math.PI),o=Z(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*U,o*U)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=u,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},et(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ec()?i:h,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=eg(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ec()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=eg(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return I(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eT.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${ev.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${ev.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||ev.ACCESS_TOKEN;return ev.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${ev.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${ev.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(ev.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!ev.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||ev.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,H({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=T,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=X,i.bezier=j,i.bindAll=et,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=Z(i.center.lat,-85.051129,85.051129),o=new l(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,c=r/(s/i.pixelsPerMeter),h=p(new Float64Array(16));return m(h,h,[o.x,o.y,0]),_(h,h,[c,c,a]),h},i.clamp=Z,i.clearTileCache=function(i){const r=h.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new u(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=eo,i.collisionCircleLayout=az,i.config=ev,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new u(16);return u!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=d,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=z,i.degToRad=function(i){return i*O},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=C,i.ease=G,i.easeCubicInOut=N,i.emitValidationErrors=rU,i.endsWith=ei,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*O)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*O)/r;return{x:i*O*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=Z((i-.5)/n*U/r,-180,180),a=Math.asin(Z(-(o-.5)/n*r,-1,1)),l=Z(a*U,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return H({},i,r,n)}return H({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new l(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return w(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=h.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),o(["./shared"],function(i){function r(i){var o;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===n[o=i&&i.failIfMajorPerformanceCaveat]&&(n[o]=function(i){var n,o,s,a=(n=document.createElement("canvas"),(o=Object.create(r.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,n.getContext("webgl",o)||n.getContext("experimental-webgl",o));if(!a)return!1;try{s=a.createShader(a.VERTEX_SHADER)}catch(l){return!1}return!(!s||a.isContextLost())&&(a.shaderSource(s,"void main() {}"),a.compileShader(s),!0===a.getShaderParameter(s,a.COMPILE_STATUS))}(o)),!!n[o]&&!document.documentMode)}var n={};function o(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function s(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",h,!0)},0)},a.mousePos=function(i,r){const n=i.getBoundingClientRect();return u(i,n,r)},a.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class d extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function S(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}E.Actor=i.Actor;class I{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const M={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class A{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new ep(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=S(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ef(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class em{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new em(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eg(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ey extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eg(0,0,r,0,0,n,r,n),f=eg(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const ex={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ef(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new em(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:e_,"raster-dem":class extends e_{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function s(i,o){i&&(r.state="errored",n(i)),o&&(r.dem=o,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",n(null))}r.request=i.getImage(this.map._requestManager.transformRequest(o,i.ResourceType.Tile),(function(o,a,l,c){if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(a){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:l,expires:c});const h=i.window.ImageBitmap&&a instanceof i.window.ImageBitmap&&(null==rB&&(rB=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),rB),u=1-(a.width-i.prevPowerOfTwo(a.width))/2;u<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const d=h?a:i.exported.getImageData(a,u),p={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:d,encoding:this.encoding,padding:u};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",p,s.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ey{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ey,canvas:class extends ey{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},ev=function(r,n,o,s){const a=new ex[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eb(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function ew(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eT="mapboxgl_preloaded_worker_pool";class eE{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eT]}numActive(){return Object.keys(this.active).length}}function eS(){return rR||(rR=new eE),rR}function eI(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eE.workerCount=2;const eM={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eA(i,r,n){n.push({command:eM.addSource,args:[i,r[i]]})}function eC(i,r,n){r.push({command:eM.removeSource,args:[i]}),n[i]=!0}function ez(i,r,n,o,a,l){let c;for(c in r=r||{},i=i||{})i.hasOwnProperty(c)&&(s(i[c],r[c])||n.push({command:l,args:[o,c,r[c],a]}));for(c in r)r.hasOwnProperty(c)&&!i.hasOwnProperty(c)&&(s(i[c],r[c])||n.push({command:l,args:[o,c,r[c],a]}))}function ek(i){return i.id}function eP(i,r){return i[r.id]=r,i}class eD{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eL{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eB=Math.tan(85*Math.PI/180);function eR(r,n,s,a,l,c){let h=i.create();if(s){if("globe"===l.projection.name)h=i.calculateGlobeMatrix(l,l.worldSize/l._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=o([],c);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}a||i.rotateZ(h,h,l.angle)}else i.multiply$1(h,l.labelPlaneMatrix,r);return h}function eF(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eR(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function eO(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eW(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eU(i,r){return Math.min(.5+i/r*.5,1.5)}function eV(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=e$(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=e$(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function eN(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeB}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function ej(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eV(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=eO(M.first.point,c).point,C=eO(M.last.point,c).point;if(s&&!o){const z=eN(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eZ(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=e$(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eG(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return eO(l,o,l.z);const c=a(r);return eO(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eZ(i,r,n,o,s,a,l,c){const h=eG(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function e$(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eZ(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eG(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eq=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eX(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=eO(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eV(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eD,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(reO(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),x(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eW(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e2(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e3(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e5{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eH(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e1(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eR(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eF(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e0(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e2(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e3(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e3(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new eJ(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new eJ(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e3(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new eQ);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new eY(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new eY(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new eY(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new eY(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new eY(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=e6(T.text);_(r.text,v,M?e8:C),_(r.text,b,A?e8:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=e6(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?e8:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?e8:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e2(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e4(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e4(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e4(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e4(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e4(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function e6(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const e8=0;class e9{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new e9(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const te=512/i.EXTENT/2;class tt{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const to=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),ts=i.pick(eM,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),ta=i.pick(eM,["setCenter","setZoom","setBearing","setPitch"]),tl=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tc={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class th extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new E(eS(),this),this.imageManager=new d,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tn,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=th.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(tl,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&to(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=eI(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tc[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),to(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=eI(r.layers);const n=(function(i,r){if(!i)return[{command:eM.setStyle,args:[r]}];let n=[];try{if(!s(i.version,r.version))return[{command:eM.setStyle,args:[r]}];s(i.center,r.center)||n.push({command:eM.setCenter,args:[r.center]}),s(i.zoom,r.zoom)||n.push({command:eM.setZoom,args:[r.zoom]}),s(i.bearing,r.bearing)||n.push({command:eM.setBearing,args:[r.bearing]}),s(i.pitch,r.pitch)||n.push({command:eM.setPitch,args:[r.pitch]}),s(i.sprite,r.sprite)||n.push({command:eM.setSprite,args:[r.sprite]}),s(i.glyphs,r.glyphs)||n.push({command:eM.setGlyphs,args:[r.glyphs]}),s(i.transition,r.transition)||n.push({command:eM.setTransition,args:[r.transition]}),s(i.light,r.light)||n.push({command:eM.setLight,args:[r.light]}),s(i.fog,r.fog)||n.push({command:eM.setFog,args:[r.fog]}),s(i.projection,r.projection)||n.push({command:eM.setProjection,args:[r.projection]});const o={},a=[];!function(i,r,n,o){let a;for(a in r=r||{},i=i||{})i.hasOwnProperty(a)&&(r.hasOwnProperty(a)||eC(a,n,o));for(a in r){var l,c;r.hasOwnProperty(a)&&(i.hasOwnProperty(a)?s(i[a],r[a])||("geojson"===i[a].type&&"geojson"===r[a].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!s(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!s(i[n][o],r[n][o]))return!1;return!0}(i,r,a)?n.push({command:eM.setGeoJSONSourceData,args:[a,r[a].data]}):(l=a,c=r,eC(l,n,o),eA(l,c,n))):eA(a,r,n))}}(i.sources,r.sources,a,o);const l=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:eM.removeLayer,args:[i.id]}):l.push(i)});let c=i.terrain;c&&o[c.source]&&(n.push({command:eM.setTerrain,args:[void 0]}),c=void 0),n=n.concat(a),s(c,r.terrain)||n.push({command:eM.setTerrain,args:[r.terrain]}),function(i,r,n){let o,a,l,c,h,u,d;r=r||[];const p=(i=i||[]).map(ek),f=r.map(ek),m=i.reduce(eP,{}),_=r.reduce(eP,{}),g=p.slice(),y=Object.create(null);for(o=0,a=0;o!(i.command in ta));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in ts));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=ev(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(to(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const a=this.getLayer(r);if(a){if(!s(a.filter,n))return null==n?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(i.validateStyle.filter,`layers.${a.id}.filter`,n,{layerType:a.type},o)||(a.filter=i.clone$1(n),this._updateLayer(a)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,a={}){this._checkLoaded();const l=this.getLayer(r);l?s(l.getLayoutProperty(n),o)||(l.setLayoutProperty(n,o,a),this._updateLayer(l)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,a={}){this._checkLoaded();const l=this.getLayer(r);l?s(l.getPaintProperty(n),o)||(l.setPaintProperty(n,o,a)&&this._updateLayer(l),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=ep.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eb);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eb),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const a in r)if(!s(r[a],o[a])){n.set(r),this.stylesheet.fog=r;const l={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(l);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new y(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&to(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new e7(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}th.getSourceType=function(i){return ex[i]},th.setSourceType=function(i,r){ex[i]=r},th.registerForPluginStateChange=i.registerForPluginStateChange;var tu="\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",td="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 tp={},tf={};tp=tg("","\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),tf=tg("#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 tm=tg("\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.");var t_={background:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("#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:tg("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:tg("#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:tg("\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}",td),skyboxGradient:tg("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}",td),skyboxCapture:tg("\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:tg("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:tg("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 tg(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tu.match(s);let u=c?c.concat(l):l;n||(tp.staticUniforms&&(u=tp.staticUniforms.concat(u)),tf.staticUniforms&&(u=tf.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` #ifndef HAS_UNIFORM_u_${s} varying ${n} ${o} ${s}; #else diff --git a/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js b/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js index 9a7bc4c9eb55..7d0e57ce736f 100644 --- a/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js +++ b/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js @@ -1,2 +1,3 @@ !function(n){if(void 0===t)var t={};if(void 0===e)var e={};if(e.document||(e.document=t),void 0===r)var r={};function i(){}function o(t){var r=e.bigdecimal[t],i=r;if(r.__init__){for(var o in(i=function(){var n=Array.prototype.slice.call(arguments);return r.__init__(n)}).prototype=r.prototype,r)if(r.hasOwnProperty(o)){if("function"==typeof r[o]&&o.match(/_va$/)){var u=o.replace(/_va$/,"");i[u]=function n(){var t=Array.prototype.slice.call(arguments);return n.inner_method(t)},i[u].inner_method=r[o]}else i[o]=r[o]}}var f=i.prototype;for(var o in f)if(f.hasOwnProperty(o)&&"function"==typeof f[o]&&o.match(/_va$/)){var u=o.replace(/_va$/,"");f[u]=function n(){var t=Array.prototype.slice.call(arguments);return n.inner_method.apply(this,[t])},f[u].inner_method=f[o],delete f[o]}n[t]=i}r.userAgent||(r.userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22"),function(){var n,t,o=e,u=o.document,f=o.__gwtStatsEvent?function(n){return o.__gwtStatsEvent(n)}:null,c=o.__gwtStatsSessionId?o.__gwtStatsSessionId:null;function s(){}function a(){}function h(){}function b(){}function l(){}function g(){}function w(){}function d(){}function _(){}function v(){}function m(){}function y(){}function C(){}function S(){}function M(){}function x(){}function B(){}function A(){}function N(){}function I(){}function E(){}function R(){}function O(){}function D(){}function k(){}function L(){}function U(){}function P(){}function Q(){}function T(){nX()}function j(){nZ()}function F(){tD()}function H(){ej()}function $(){ej()}function V(){ej()}function q(){ej()}function G(){ej()}function z(){ej()}function J(){nW()}function K(){nc(this)}function W(){nc(this)}function Z(n){iP(this,n)}function X(n){this.c=n}function Y(n){this.b=n}function nn(n){this.b=n}function nt(n){this.b=n}function ne(n){ej(),this.f=n}function nr(n){ne.call(this,n)}function ni(n){ne.call(this,n)}function no(n){ne.call(this,n)}function nu(n){ne.call(this,n)}function nf(n){ne.call(this,n)}function nc(n){n.b=new C}function ns(){this.b=new C}function na(){na=l,ut=new w}function nh(){nh=l,t=new nY}function nb(n,t){nh(),n[oy]=t}function nl(n,t){nh(),function(n,t){var e,r,i,u,f,c,s,a,h,b;for(f=0,s=i_(n,om,0),c=o;ft?n:t}function n_(n,t){return!rA(n,t)}function nv(n){this.b=new iS(n)}function nm(){this.b=(rj(),uj)}function ny(){this.b=(iB(),u2)}function nC(n,e){var r;nh(),r=t.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tg(n){return nG(n,15)?n:new n1(n)}function tw(){try{null.a()}catch(n){return n}}function td(n){var t;return(t=new N).d=i$+n,t.c=1,t}function tp(n,t){return nF(n)?n.eQ(t):n===t}function t_(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tv(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function tm(n,t,e){return(iH=new M).l=n,iH.m=t,iH.h=e,iH}function ty(n,t){return nT(n)===nT(t)||null!=n&&tp(n,t)}function tC(n,t){throw new nu("Index: "+n+", Size: "+t)}function tS(n,t){if(!n)throw new G;this.f=t,tR(this,n)}function tM(n,t){if(!n)throw new G;this.f=t,tR(this,n)}function tx(n,t,e,r){ez.call(this,n,t,e),ic(this,r)}function tB(n,t){ez.call(this,n,0,n.length),ic(this,t)}function tA(n,t){ez.call(this,t6(n),0,n.length),ic(this,t)}function tN(n){ne.call(this,"String index out of range: "+n)}function tI(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tE(n,t){ry(n.b,n.b,n.e,t.b,t.e),tW(n),n.c=-2}function tR(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=rr(eA(t)))}function tO(){tO=l,ue=[],ur=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new S,ue,ur)}function tD(){uy||(uy=!0,new T,new j,function(){if(nl(ox,i$),o.bigdecimal.BigDecimal)var n=o.bigdecimal.BigDecimal;o.bigdecimal.BigDecimal=ff(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fD?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new ng,nb(this.__gwt_instance,this))});var t=o.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)o.bigdecimal.BigDecimal[p]=n[p];o.bigdecimal.BigDecimal.ROUND_CEILING=2,o.bigdecimal.BigDecimal.ROUND_DOWN=1,o.bigdecimal.BigDecimal.ROUND_FLOOR=3,o.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,o.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,o.bigdecimal.BigDecimal.ROUND_HALF_UP=4,o.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,o.bigdecimal.BigDecimal.ROUND_UP=0,o.bigdecimal.BigDecimal.__init__=ff(function(n){var t=function(n){var t,e;if(iU(),(e=iI(n))==i8)t=new nk(new nq(n[0].toString()));else if("BigInteger number"==e)t=new tS(new nq(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new te(new nq(n[0].toString()),n[1],new iS(n[2].toString()));else if("BigInteger MathContext"==e)t=new n4(new nq(n[0].toString()),new iS(n[1].toString()));else if(e==oS)t=new n2(t6(n[0].toString()));else if("array number number"==e)t=new ez(t6(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tx(t6(n[0].toString()),n[1],n[2],new iS(n[3].toString()));else if("array MathContext"==e)t=new tB(t6(n[0].toString()),new iS(n[1].toString()));else if(e==ok)t=new eu(n[0]);else if(e==oL)t=new ep(n[0],new iS(n[1].toString()));else if(e==oF)t=new Z(n[0].toString());else if("string MathContext"==e)t=new tA(n[0].toString(),new iS(n[1].toString()));else throw new ne("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nL(t)}(n);return nE(t)}),t.abs_va=ff(function(n){return nE(this.__gwt_instance.s(n))}),t.add_va=ff(function(n){return nE(this.__gwt_instance.t(n))}),t.byteValueExact=ff(function(){return this.__gwt_instance.u()}),t.compareTo=ff(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=ff(function(n){return nE(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=ff(function(n){return nE(this.__gwt_instance.x(n))}),t.doubleValue=ff(function(){return this.__gwt_instance.z()}),t.equals=ff(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=ff(function(){return this.__gwt_instance.A()}),t.hashCode=ff(function(){return this.__gwt_instance.hC()}),t.intValue=ff(function(){return this.__gwt_instance.B()}),t.intValueExact=ff(function(){return this.__gwt_instance.C()}),t.max=ff(function(n){return nE(this.__gwt_instance.F(n.__gwt_instance))}),t.min=ff(function(n){return nE(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=ff(function(n){return nE(this.__gwt_instance.H(n))}),t.movePointRight=ff(function(n){return nE(this.__gwt_instance.I(n))}),t.multiply_va=ff(function(n){return nE(this.__gwt_instance.J(n))}),t.negate_va=ff(function(n){return nE(this.__gwt_instance.K(n))}),t.plus_va=ff(function(n){return nE(this.__gwt_instance.L(n))}),t.pow_va=ff(function(n){return nE(this.__gwt_instance.M(n))}),t.precision=ff(function(){return this.__gwt_instance.q()}),t.remainder_va=ff(function(n){return nE(this.__gwt_instance.N(n))}),t.round=ff(function(n){return nE(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=ff(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=ff(function(n){return nE(this.__gwt_instance.Q(n))}),t.setScale_va=ff(function(n){return nE(this.__gwt_instance.R(n))}),t.shortValueExact=ff(function(){return this.__gwt_instance.S()}),t.signum=ff(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=ff(function(){return nE(this.__gwt_instance.T())}),t.subtract_va=ff(function(n){return nE(this.__gwt_instance.U(n))}),t.toBigInteger=ff(function(){return nE(this.__gwt_instance.V())}),t.toBigIntegerExact=ff(function(){return nE(this.__gwt_instance.W())}),t.toEngineeringString=ff(function(){return this.__gwt_instance.X()}),t.toPlainString=ff(function(){return this.__gwt_instance.Y()}),t.toString=ff(function(){return this.__gwt_instance.tS()}),t.ulp=ff(function(){return nE(this.__gwt_instance.Z())}),t.unscaledValue=ff(function(){return nE(this.__gwt_instance.$())}),t.divideAndRemainder_va=ff(function(n){return nR(this.__gwt_instance.w(n))}),t.longValue=ff(function(){return this.__gwt_instance.E()}),t.longValueExact=ff(function(){return this.__gwt_instance.D()}),o.bigdecimal.BigDecimal.valueOf_va=ff(function(n){var t=function(n){var t,e;if(iU(),(e=iI(n))==ok)t=function(n){if(!isFinite(n)||isNaN(n))throw new nw(os);return new Z(i$+n)}(n[0]);else if(e==ok)t=tZ(e3(n[0]));else if(e==oU)t=ek(e3(n[0]),n[1]);else throw new ne("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nL(t)}(n);return nE(t)}),o.bigdecimal.BigDecimal.log=ff(function(n){iU(),typeof console!==oH&&console.log&&console.log(n)}),o.bigdecimal.BigDecimal.logObj=ff(function(n){iU(),typeof console!==oH&&console.log&&typeof JSON!==oH&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),o.bigdecimal.BigDecimal.ONE=ff(function(){var n=(iU(),new nL(ug));return nE(n)}),o.bigdecimal.BigDecimal.TEN=ff(function(){var n=(iU(),new nL(uw));return nE(n)}),o.bigdecimal.BigDecimal.ZERO=ff(function(){var n=(iU(),new nL(ud));return nE(n)}),nC(fD,o.bigdecimal.BigDecimal)}())}function tk(n,t,e){var r;return(r=new N).d=n+t,r.c=4,r.b=e,r}function tL(n,t,e,r,i){var o;return tJ(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tN(e)}(n.length,t,r),t4(n,t,r)}function tP(n,t){return ib(),t=n.c.c)throw new z;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tC(r,i),t.b[e]}function tj(n,t){return!!nG(t,1)&&String(n)==t}function tF(){ne.call(this,"Add not supported on this collection")}function tH(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function t$(n,t){rK(),this.f=n,this.e=1,this.b=tJ(fd,{6:1},-1,[t])}function tV(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tq(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tG(n,t,e,r){var i,o;return null==t&&(t=oD),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tz(n,t,e,r){var i;return ry(i=tL(fd,{6:1},-1,t,1),n,t,e,r),i}function tJ(n,t,e,r){return tO(),function(n,t,e){tO();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tZ(n){return rA(n,oz)&&n_(n,oX)?uc[nx(n)]:new eo(n,0)}function tX(n,t){return 0==t||0==n.f?n:t>0?e4(n,t):rX(n,-t)}function tY(n,t){return 0==t||0==n.f?n:t>0?rX(n,t):e4(n,-t)}function t1(n){var t;return 0==n.f?-1:((t=eg(n))<<5)+ec(n.b[t])}function t0(n){var t;return 0!=(t=nx(n))?ec(t):ec(nx(rJ(n,32)))+32}function t2(n,t){var e;return 0==(e=eR(n,t)).length?(new d).o(t):tl(e,1)}function t4(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t3(n,t,e,r){var i;return ih(i=tL(fd,{6:1},-1,t+1,1),n,t,e,r),i}function t6(n){var t,e;return t=tL(fJ,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nx(y=iE(ts(e3(b.b[0]),o3),ts(e3(l.b[0]),o3))),0==(C=nx(rU(y,32)))?new t$(v,S):new ti(v,2,tJ(fd,{6:1},-1,[S,C]))):(eq(b.b,g,l.b,w,d=tL(fd,{6:1},-1,_,1)),tW(m=new ti(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=is(t,a.eb(f)),o=is(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iC(iC(u=n(is(a,i),is(o,h)),s),r)).eb(f),iC(iC(s=s.eb(f<<1),u),r))}(n,t))}function et(n,t){var e;if(t.f<=0)throw new nr(oe);return(e=rF(n,t)).f<0?iC(e,t):e}function ee(n){var t;t=new nz,n.d&&n6(t,new nt(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nB(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eU(n.g)),n.d).r()}function ed(n){return n.b<54?new tr(-n.g,n.f):new tM((n.d||(n.d=eU(n.g)),n.d).cb(),n.f)}function ep(n,t){if(!isFinite(n)||isNaN(n))throw new nw(os);iP(this,n.toPrecision(20)),ic(this,t)}function e_(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function ev(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function em(n,t){var e,r;return t?((e=t[oy])||(e=new(r=t.gC(),t9(er(n.b,r)))(t),t[oy]=e),e):null}function ey(n){var t,e;return 32==(e=rH(n.h))?32==(t=rH(n.m))?rH(n.l)+32:t+20-10:e-12}function eC(n){return tm(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eS(){eS=l,ui=tm(4194303,4194303,524287),uo=tm(0,0,524288),uu=e3(1),e3(2),uf=e3(0)}function eM(n,t){ih(n.b,n.b,n.e,t.b,t.e),n.e=nd(np(n.e,t.e)+1,n.b.length),tW(n),n.c=-2}function ex(n,t){var e;e=~~t>>5,n.e+=e+(rH(n.b[n.e-1])-(31&t)>=0?0:1),rC(n.b,n.b,e,31&t),tW(n),n.c=-2}function eB(n,t){var e,r;e=~~t>>5,n.e>>r:0,tW(n))}function eA(n){var t;return t=n.e>1?ta(rL(e3(n.b[1]),32),ts(e3(n.b[0]),o3)):ts(e3(n.b[0]),o3),iE(e3(n.f),t)}function eN(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:n_(ts(e3(n[r]),o3),ts(e3(t[r]),o3))?-1:1}function eI(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eE(n,t,e,r){if(iF=t,n)try{ff(im)()}catch(i){n(t)}else ff(im)()}function eR(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eo(oz,2147483647):new eo(oz,-2147483648)}function eU(n){return(rK(),n<0)?-1!=n?new ro(-1,-n):uC:n<=10?uM[ei(n)]:new ro(1,n)}function eP(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,tm(t,e,r)}function eQ(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function eT(n){var t,e,r;for(r=0,e=tL(fC,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rB(ts(e3(n[r]),o3),ts(e3(i[r]),o3));break}}return u=new ti(1,o+1,n),e&&tE(u,t),tW(u),u}(o,e)}function e$(n,t){var e;return n===t||!!nG(t,17)&&(e=tQ(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eV(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&eg(n)==n.e-1&&(e=~~(e-1)),t-=rH(e))}function eq(n,t,e,r,i){ib(),0!=t&&0!=r&&(1==t?i[r]=rf(i,e,r,n[0]):1==r?i[t]=rf(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nT(n)===nT(t)&&r==i){io(n,r,e);return}for(f=0;f2147483647))return ei(n);throw new nr("Underflow")}function eK(n,t){if(rj(),n<0)throw new no("Digits < 0");if(!t)throw new nf("null RoundingMode");this.b=n,this.c=t}function eW(n){return(rK(),n_(n,oz))?tv(n,oG)?new ri(-1,eP(n)):uC:rB(n,oZ)?new ri(1,n):uM[nx(n)]}function eZ(n){var t;return n_(n,oz)&&(n=tm(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nx(rJ(n,32)))?rH(t):rH(nx(n))+32)}function eX(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),tm(4194303&e,4194303&r,1048575&i)}function eY(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),tm(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-np(e,n.bb())}function e0(n,t){var e;return n===t||!!nG(t,16)&&(e=tQ(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e2(n,t,e){var r,i,o;for(o=oz,r=t-1;r>=0;--r)i=r0(eX(rL(o,32),ts(e3(n[r]),o3)),e),o=e3(nx(rJ(i,32)));return nx(o)}function e4(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rC(r=tL(fd,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tW(o=new ti(n.f,i,r)),o}function e3(n){var t,e;return n>-129&&n<128?(t=n+128,null==o8&&(o8=tL(fE,{6:1},2,256,0)),(e=o8[t])||(e=o8[t]=eC(n)),e):eC(n)}function e6(n){var t,e;return(rK(),n>5)+1,1))[t]=1<<(31&n),new ti(1,t+1,e))}function e5(n){rK(),0==n.length?(this.f=0,this.e=1,this.b=tJ(fd,{6:1},-1,[0])):(this.f=1,this.e=n.length,this.b=n,tW(this))}function e9(n){return 0==n.length||n[0]>iV&&n[n.length-1]>iV?n:n.replace(/^(\s*)/,i$).replace(/\s*$/,i$)}function e7(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function e8(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==l||nH(e,1)))throw new $}return n[t]=e}function rn(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=eH(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=eH(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tL(f5,{6:1},17,8,0),a=n,e8(s,0,t),h=eH(t,t,r,i),u=1;u<=7;++u)e8(s,u,eH(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=eH(a,a,r,i);return a}(f,r,t,e,o),eH(u,(rK(),uS),e,o)}function rs(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nw("Radix out of range");if(0==n.length)throw new nw("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(iM(),uU)[e])),0!=(d=l%u)&&++o,c=tL(fd,{6:1},-1,o,1),r=uL[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:n_(ts(e3(n[i]),o3),ts(e3(t[i]),o3))?-1:1}function rl(n,t){var e,r,i;for(r=tL(fd,{6:1},-1,i=n.e,1),nd(eg(n),eg(t)),e=0;e999999999)throw new nr(oa);return e=n.f*t,0==n.b&&-1!=n.g?eL(e):new tS((n.d||(n.d=eU(n.g)),n.d).db(t),eJ(e))}function rd(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fo[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fi[n]=t,t*=.5}function r_(){r_=l,uR=tJ(fJ,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rv(n){var t;return 0!=n.c?n.c:n.b<54?(t=r2(n.g),n.c=nx(ts(t,oG)),n.c=33*n.c+nx(ts(rJ(t,32),oG)),n.c=17*n.c+ei(n.f),n.c):(n.c=17*n.d.hC()+ei(n.f),n.c)}function rm(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=e_(n*t,0),0!=u&&(i=e_((u<=0?0-u:u)*2,t<=0?0-t:t),o+=r8(1&ei(o),f*(5+i),r)),new tr(o,e)}function ry(n,t,e,r,i){var o,u;for(u=0,o=oz;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rO(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=ei(nU(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eZ(r2(n))}function rE(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eW(rN(eA(e),eA(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rx(n,e),rx(t,r),1==rn(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eW(rN(eA(n),eA(t)));break}if(t.e>1.2*n.e)0!=(t=rF(t,n)).r()&&rx(t,t.bb());else do tE(t,n),rx(t,t.bb());while(rn(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?ex(f,i):(rx(c,r-e0&&ex(f,i-r+e)),e+=i),0!=(i=e1(h,u))&&(ex(h,i),r>=e?ex(c,i):(rx(f,e-r0&&ex(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)):e<=r?(r$(s,h),r$(f,c)):(r$(h,s),r$(c,f)),0==h.r()||0==s.r())throw new nr(ot);return eO(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():is(t,f)),0>f.r()&&(f=iC(f,t)),f}(n,t);for(o=32*t.e,h=eh(t),u=np((b=eh(n)).e,h.e),c=new ti(1,1,tL(fd,{6:1},-1,u+1,1)),(s=new ti(1,1,tL(fd,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rx(h,r),rx(b,i),ex(c,i),e+=r-i):(rx(h,r),rx(b,i),ex(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rn(h,b)>0;)tE(h,b),a=h.bb(),rx(h,a),eM(c,s),ex(s,a),e+=a;for(;0>=rn(h,b)&&(tE(b,h),0!=b.r());)a=b.bb(),rx(b,a),eM(s,c),ex(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new nr(ot);return rn(c,t)>=0&&tE(c,t),c=is(t,c),f=ru(t),e>o&&(c=eH(c,(rK(),uS),t,f),e-=o),c=eH(c,e6(o-e),t,f)}(et(n._(),t),t)).f)throw new nr(ot);return n.f<0?is(t,e):e}function rO(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rD(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eL(e):n.b+t.b<54?new tr(n.g*t.g,eJ(e)):new tS(en((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),eJ(e))}function rk(n,t){var e;if(t<0)throw new nr("Negative exponent");if(0==t)return uS;if(1==t||n.eQ(uS)||n.eQ(uB))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return en(e6(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(ib(),rK(),r=uS,e=n;t>1;t>>=1)(1&t)!=0&&(r=en(r,e)),e=1==e.e?en(e,e):new e5(io(e.b,e.e,tL(fd,{6:1},-1,e.e<<1,1)));return en(r,e)}(n,t)}function rL(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),tm(4194303&r,4194303&i,1048575&o)}function rP(n){switch(iB(),n){case 2:return uZ;case 1:return uX;case 3:return uY;case 5:return u1;case 6:return u0;case 4:return u2;case 7:return u4;case 0:return u3;default:throw new no("Invalid rounding mode")}}function rQ(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new nr(ob);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=eg(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rT(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ia((n.d||(n.d=eU(n.g)),n.d),iv(t)).r()&&++t),n.e=ei(t)),n.e}function rj(){rj=l,uP=new eK(34,(iB(),u0)),uQ=new eK(7,u0),uT=new eK(16,u0),uj=new eK(0,u2),uF=tJ(fJ,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),uH=tJ(fJ,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rF(n,t){var e,r,i,o;if(0==t.f)throw new nr(on);return((o=n.e)!=(e=t.e)?o>e?1:-1:eN(n.b,t.b,o))==-1?n:(r=tL(fd,{6:1},-1,e,1),1==e?r[0]=e2(n.b,o,t.b[0]):r=ik(null,o-e+1,n.b,o,t.b,e),tW(i=new ti(n.f,e,r)),i)}function rH(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16),e+=t=~~(r=(n=~~n>>t)-256)>>16&8,n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function r$(n,t){if(0==n.f)ix(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ih(n.b,n.b,n.e,t.b,t.e):rb(n.b,t.b,n.e,t.e)>0?ry(n.b,n.b,n.e,t.b,t.e):(r5(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=np(n.e,t.e)+1,tW(n),n.c=-2}function rV(n,t){var e;e=rn(n,t),0==n.f?(ix(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ih(n.b,n.b,n.e,t.b,t.e),n.f=e):rb(n.b,t.b,n.e,t.e)>0?ry(n.b,n.b,n.e,t.b,t.e):(r5(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=np(n.e,t.e)+1,tW(n),n.c=-2}function rq(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new nr(oe);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uB:0==r.f&&0==t.f?uS:(t.f<0&&(r=rR(n,e),t=t.cb()),i=e.gb(0)?rc(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rc(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rK(),u=uS,i=eh(t),r=eh(n),n.gb(0)&&eB(i,e-1),eB(r,e),o=i.ab()-1;o>=0;--o)eB(f=eh(u),e),u=en(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eB(u=en(u,r),e);return eB(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e5(tL(fd,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eB(b=en(is(h,a),s),f),b.f<0&&(b=iC(b,e6(f))),iC(a,en(c,b))),r.f<0&&t.gb(0)&&(i=et(en(is(e,uS),i),e)),i)}function rG(n,t){var e,r,i,o,u,f,c;if(i=eg(n),(r=eg(t))>=n.e)return rK(),uB;for(u=tL(fd,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=nd(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new tr(n.g,eJ(t)):new tS((n.d||(n.d=eU(n.g)),n.d),eJ(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),tm(4194303&i,4194303&o,1048575&u)}function rK(){var n;for(n=0,rK=l,uS=new t$(1,1),ux=new t$(1,10),uB=new t$(0,0),uC=new t$(-1,1),uM=tJ(f5,{6:1},17,[uB,uS,new t$(1,2),new t$(1,3),new t$(1,4),new t$(1,5),new t$(1,6),new t$(1,7),new t$(1,8),new t$(1,9),ux]),uA=tL(f5,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tL(fd,{6:1},-1,u=nd(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rK(),uC):(rK(),uB);if(rO(i=tL(fd,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rS(n,t,e):rS(t,n,-e):np(n.b,t.b)+1<54?new tr(n.g+t.g,n.f):new tM(iC((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),n.f)}function r0(n,t){var e,r,i,o,u;return(r=ts(e3(t),o3),rA(n,oz))?(o=iN(n,r,!1),u=n3(n,r)):(o=iN(e=rU(n,1),i=e3(~~t>>>1),!1),u=eX(rL(u=n3(e,i),1),ts(n,oJ)),(1&t)!=0&&(rB(o,u)?rB(eY(o,u),r)?(u=eX(u,eY(rL(r,1),o)),o=eY(o,oK)):(u=eX(u,eY(r,o)),o=eY(o,oJ)):u=eY(u,o))),ta(rL(u,32),ts(o,o3))}function r2(n){var t,e,r,i;return isNaN(n)?(eS(),uf):n<-0x8000000000000000?(eS(),uo):n>=0x7fffffffffffffff?(eS(),ui):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=ei(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=ei(n/4194304),n-=4194304*t),i=tm(ei(n),t,e),r&&eQ(i),i)}function r4(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iK;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iz+r4(eP(n));for(e=n,r=i$;!(0==e.l&&0==e.m&&0==e.h);){if(e=iN(e,e3(1e9),!0),t=i$+nx(o7),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iK+t;r=t+r}return r}function r3(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new nr(on);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iN(g=ts(e3(S[0]),o3),w=ts(e3(l),o3),!1),v=n3(g,w),x!=i&&(d=eP(d)),x<0&&(v=eP(v)),tJ(f5,{6:1},17,[eW(d),eW(v)])):(_=tL(fd,{6:1},-1,M,1),m=tJ(fd,{6:1},-1,[ir(_,S,M,l)]),y=new ti(x==i?1:-1,M,_),C=new ti(x,1,m),tW(y),tW(C),tJ(f5,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eN(a,e,h))<0)?tJ(f5,{6:1},17,[uB,n]):(b=n.f,f=ik(o=tL(fd,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new ti(b==i?1:-1,u,o),s=new ti(b,r,f),tW(c),tW(s),tJ(f5,{6:1},17,[c,s]))}function r6(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eU(n.g)),n.d;if(n.f<0)return en((n.d||(n.d=eU(n.g)),n.d),iv(-n.f));if(n.f>(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eU(n.g)),n.d).bb()||0!=(t=r3((n.d||(n.d=eU(n.g)),n.d),iv(n.f)))[1].r())throw new nr(ol);return t[0]}function r5(n,t,e,r,i){var o,u;if(o=oz,e36)throw new nw("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nw(oc+n+iq);return i}function r7(n){var t,e;if(0==n.f)return rK(),uC;if(e$(n,(rK(),uC)))return uB;if(e=tL(fd,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function it(n,t){var e,r,i,o,u,f,c,s;if(c=0==n.f?1:n.f,u=tL(fd,{6:1},-1,f=np((o=~~t>>5)+1,n.e)+1,1),e=1<<(31&t),ix(n.b,0,u,0,n.e),n.f<0){if(o>=n.e)u[o]=e;else if(o>(r=eg(n)))u[o]^=e;else if(o=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rq(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rA(a=ta(rL(s,32),ts(e3(t[f]),o3)),oz)?(c=iN(a,o,!1),s=n3(a,o)):(c=iN(i=rU(a,1),u=e3(~~r>>>1),!1),s=eX(rL(s=n3(i,u),1),ts(a,oJ)),(1&r)!=0&&(rB(c,s)?rB(eY(c,s),o)?(s=eX(s,eY(rL(o,1),c)),c=eY(c,oK)):(s=eX(s,eY(o,c)),c=eY(c,oJ)):s=eY(s,c))),n[f]=nx(ts(c,o3));return nx(s)}function ii(n,t){var e,r,i,o,u,f,c;if(u=tL(fd,{6:1},-1,f=np(n.e,t.e),1),i=eg(n),e=r=eg(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=nd(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nU((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=en(u,iv(r))),rn(o,u))}function ic(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r2(ub[r]),b=eY(r2(c.f),e3(r)),h=iN(g=r2(c.g),l,!1),tv(a=n3(g,l),oz)&&(s=t_(eY(rL(n_(a,oz)?eP(a):a,1),l),oz)?0:n_(eY(rL(n_(a,oz)?eP(a):a,1),l),oz)?-1:1,h=eX(h,e3(r8(1&nx(h),(t_(a,oz)?0:n_(a,oz)?-1:1)*(5+s),t.c))),n8(rr(n_(h,oz)?eP(h):h))>=t.b&&(h=nP(h,oZ),b=eY(b,oJ))),c.f=eJ(rr(b)),c.e=t.b,c.g=rr(h),c.b=eZ(h),c.d=null;return}f=iv(r),i=r3((n.d||(n.d=eU(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rn(eF(i[1]._()),f),0!=(e=r8(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&e8(i,0,iC(i[0],eW(e3(e)))),new nk(i[0]).q()>o&&(e8(i,0,ia(i[0],(rK(),ux))),--u)),n.f=eJ(u),n.e=o,tR(n,i[0])}}function is(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ts(e3(n.b[0]),o3),r=ts(e3(t.b[0]),o3),u<0&&(e=eP(e)),c<0&&(r=eP(r)),eW(eY(e,r));if(-1==(i=o!=f?o>f?1:-1:eN(n.b,t.b,o)))h=-c,a=u==c?tz(t.b,f,n.b,o):t3(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rK(),uB;a=tz(n.b,o,t.b,f)}else a=t3(n.b,o,t.b,f);return tW(s=new ti(h,a.length,a)),s}function ia(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new nr(on);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nP(ts(e3(n.b[0]),o3),ts(e3(t.b[0]),o3)),s!=i&&(a=eP(a)),eW(a)):0==(e=c!=r?c>r?1:-1:eN(n.b,t.b,c))?s==i?uS:uC:-1==e?uB:(o=tL(fd,{6:1},-1,u=c-r+1,1),1==r?ir(o,n.b,c,t.b[0]):ik(o,u,n.b,c,t.b,r),tW(f=new ti(s==i?1:-1,u,o)),f)}function ih(n,t,e,r,i){var o,u;if(o=eX(ts(e3(t[0]),o3),ts(e3(r[0]),o3)),n[0]=nx(o),o=rJ(o,32),e>=i){for(u=1;u0){if(i0?u=tP(u,ei(i)):i<0&&(o=tP(o,ei(-i))),iw(o,u,e,r)}function ig(n,t){var e,r,i,o,u,f,c;if(r=eg(t),(i=eg(n))>=t.e)return t;if(u=tL(fd,{6:1},-1,f=t.e,1),rt.ab()?(c=eA(s),o=eA(t),i=t_(eY(rL(n_(c,oz)?eP(c):c,1),n_(o,oz)?eP(o):o),oz)?0:n_(eY(rL(n_(c,oz)?eP(c):c,1),n_(o,oz)?eP(o):o),oz)?-1:1,i=r8(f.gb(0)?1:0,a*(5+i),r)):(i=rn(eF(s._()),t._()),i=r8(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return ek(eX(eA(f),e3(i)),e);f=iC(f,eW(e3(i)))}return new tS(f,e)}function id(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v;if(iM(),(u=n_(n,oz))&&(n=eP(n)),t_(n,oz))switch(t){case 0:return iK;case 1:return iZ;case 2:return iX;case 3:return iY;case 4:return i1;case 5:return i0;case 6:return i2;default:return s=new K,t<0?s.b.b+=i3:s.b.b+=i4,b=s.b,b.b+=-2147483648==t?"2147483648":i$+-t,s.b.b}c=tL(fJ,{6:1},-1,19,1),e=18,h=n;do f=h,h=nP(h,oZ),c[--e]=65535&nx(eX(o1,eY(f,iE(h,oZ))));while(tv(h,oz))if(r=eY(eY(eY(oY,e3(e)),e3(t)),oJ),0==t)return u&&(c[--e]=45),tU(c,e,18-e);if(t>0&&rA(r,oq)){if(rA(r,oz)){for(o=17,i=e+nx(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tU(c,e,18-e+1)}for(o=2;n_(e3(o),eX(eP(r),oJ));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tU(c,e,18-e)}return(a=e+1,s=new W,u&&(s.b.b+=iz),18-a>=1)?(tI(s,c[e]),s.b.b+=iJ,l=s.b,g=tU(c,e+1,18-e-1),l.b+=g):(w=s.b,d=tU(c,e,18-e),w.b+=d),s.b.b+=of,rB(r,oz)&&(s.b.b+=iG),_=s.b,v=i$+r4(r),_.b+=v,s.b.b}(r2(n.g),ei(n.f)),n.i):(i=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eU(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new K).b,u.b+=i,n.f>0&&r>=-6?r>=0?n9(o,e-ei(n.f),iJ):(tt(o.b,t-1,t-1,iW),n9(o,t+1,tU(us,0,-ei(r)-1))):(e-t>=1&&(tt(o.b,t,t,iJ),++e),tt(o.b,e,e,of),r>0&&n9(o,++e,iG),n9(o,++e,i$+r4(r2(r)))),n.i=o.b.b,n.i)}function ip(n,t){var e,r,i,o,u,f;if(i=eg(n),o=eg(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==i$;)--s;s1e6)throw new nr("power of ten too big");if(n<=2147483647)return u$[1].db(t).eb(t);for(i=r=u$[1].db(2147483647),e=r2(n-2147483647),t=ei(n%2147483647);rB(e,o4);)i=en(i,r),e=eY(e,o4);for(i=(i=en(i,u$[1].db(t))).eb(2147483647),e=r2(n-2147483647);rB(e,o4);)i=i.eb(2147483647),e=eY(e,o4);return i.eb(t)}function im(){var n,t;f&&rM("com.iriscouch.gwtapp.client.BigDecimalApp"),nW(new J),nX(new T),nZ(new j),tD(new F),f&&rM("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oQ)?oQ:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=oH)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oj:-1!=t.indexOf(oO)&&u.documentMode>=9?"ie9":-1!=t.indexOf(oO)&&u.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tj(oj,n)||o.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),f&&rM("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=u.compatMode,n=tJ(fN,{6:1},1,[oi]);e>5,this.b=tL(fd,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tW(this)}}function iC(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ts(e3(n.b[0]),o3),r=ts(e3(t.b[0]),o3),u==c)?(l=nx(s=eX(e,r)),0==(b=nx(rU(s,32)))?new t$(u,l):new ti(u,2,tJ(fd,{6:1},-1,[l,b]))):eW(u<0?eY(r,e):eY(e,r));if(u==c)h=u,a=o>=f?t3(n.b,o,t.b,f):t3(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eN(n.b,t.b,o)))return rK(),uB;1==i?(h=u,a=tz(n.b,o,t.b,f)):(h=c,a=tz(t.b,f,n.b,o))}return tW(s=new ti(h,a.length,a)),s}function iS(n){var t,e,r,i;if(rj(),null==n)throw new nf("null string");if((t=t6(n)).length<27||t.length>45)throw new no(oM);for(r=0;rft.length)throw new V;if(o=null,i=null,67==r[0]?(i=uZ,o=u6):68==r[0]?(i=uX,o=u5):70==r[0]?(i=uY,o=u9):72==r[0]?e>6&&(68==r[5]?(i=u1,o=u7):69==r[5]?(i=u0,o=u8):85==r[5]&&(i=u2,o=fn)):85==r[0]&&(80==r[1]?(i=u3,o=fe):78==r[1]&&(i=u4,o=ft)),i&&e==o.length){for(t=1;tl||r+i>s)throw new q;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tQ(n,11),o=tQ(e,11),nT(n)===nT(e)&&tr;)e8(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eJ(e+(o>u?o:u)),s=(i=o-u)>0?(ib(),i>19!=0&&(t=eP(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?ec(b):0==h&&0!=l&&0==b?ec(l)+22:0!=h&&0==l&&0==b?ec(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rJ(n,u),c&&eQ(f),e&&(o7=tm(0,0,0)),f;n=nQ((eS(),ui)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eP(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rJ(g,u),w&&eQ(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eQ(f),o&&(r?(o7=eP(n),i&&(o7=eY(o7,(eS(),uu)))):o7=tm(n.l,n.m,n.h)),f}(r?n:tm(n.l,n.m,n.h),t,c,o,i,e):(e&&(o7=o?eP(n):tm(n.l,n.m,n.h)),tm(0,0,0))}function iI(n){var t=[];for(var e in n){var r=typeof n[e];r!=oP?t[t.length]=r:n[e]instanceof Array?t[t.length]=oS:o&&o.bigdecimal&&o.bigdecimal.BigInteger&&n[e]instanceof o.bigdecimal.BigInteger?t[t.length]=i8:o&&o.bigdecimal&&o.bigdecimal.BigDecimal&&n[e]instanceof o.bigdecimal.BigDecimal?t[t.length]=i5:o&&o.bigdecimal&&o.bigdecimal.RoundingMode&&n[e]instanceof o.bigdecimal.RoundingMode?t[t.length]=og:o&&o.bigdecimal&&o.bigdecimal.MathContext&&n[e]instanceof o.bigdecimal.MathContext?t[t.length]=oh:t[t.length]=oP}return t.join(iV)}function iE(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,tm(b,l&=4194303,g&=1048575)}function iR(n,t,e){var r,i,o,u,f,c,s,a;if(a=rr(eX(e3(e.b),oK))+(t.e>0?t.e:nU((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=uv.length-1,s=tJ(f5,{6:1},17,[(n.d||(n.d=eU(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iA(n,t);if(a>0&&(e8(s,0,en((n.d||(n.d=eU(n.g)),n.d),iv(a))),c+=a),u=(s=r3(s[0],(t.d||(t.d=eU(t.g)),t.d)))[0],0!=s[1].r())r=rn(eF(s[1]),(t.d||(t.d=eU(t.g)),t.d)),u=iC(en(u,(rK(),ux)),eW(e3(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r3(u,uv[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?np(n.b,t.b)+1<54?new tr(n.g-t.g,n.f):new tM(is((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),n.f):e>0?e0?t.e:nU((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rK(),r=uB;else if(0==o)r=ia((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d));else if(o>0)u=iv(o),r=ia((n.d||(n.d=eU(n.g)),n.d),en((t.d||(t.d=eU(t.g)),t.d),u)),r=en(r,u);else{for(u=iv(-o),r=ia(en((n.d||(n.d=eU(n.g)),n.d),u),(t.d||(t.d=eU(t.g)),t.d));!r.gb(0);)if(0==(f=r3(r,uv[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nx(m=r0(eX(rL(ts(e3(w[h]),o3),32),ts(e3(w[h-1]),o3)),c)),v=nx(rJ(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iE(ts(e3(s),o3),ts(e3(d[o-2]),o3)),y=eX(rL(e3(v),32),ts(e3(w[h-2]),o3)),32>rH(nx(rU(g=eX(ts(e3(v),o3),ts(e3(c),o3)),32)))?_=!0:v=nx(g)}while(rB(th(l,o$),th(y,o$)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oz,u=oz;f0)e8(b,0,ia((n.d||(n.d=eU(n.g)),n.d),en((t.d||(t.d=eU(t.g)),t.d),iv(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,e8(b,0,en(b[0],iv(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r3(en((n.d||(n.d=eU(n.g)),n.d),iv(u)),(t.d||(t.d=eU(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nk(b[1]).q()+u-t.q())&&(e8(b,1,ia(en(b[1],iv(u)),(t.d||(t.d=eU(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new nr(ou);if(0==b[0].r())return eL(o);for(w=b[0],g=(c=new nk(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r3(w,uv[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new nr(ou);return c.f=eJ(h),tR(c,w),c}function iT(){var n;for(n=0,iT=l,uz=tJ(fd,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uJ=tL(f5,{6:1},17,(uK=tJ(fd,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rA(n,oz)?(e=nP(n,o2),r=n3(n,o2)):(e=nP(t=rU(n,1),o0),r=eX(rL(r=n3(t,o0),1),ts(n,oJ))),ta(rL(r,32),ts(e,o3))}(eX(rL(y,32),ts(e3(M[c]),o3))),M[c]=nx(w),y=e3(nx(rJ(w,32)));d=nx(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tU(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tU(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tU(v,e,_-e)}return(S=e+1,m=new W,h&&(m.b.b+=iz),_-S>=1)?(tI(m,v[e]),m.b.b+=iJ,N=m.b,I=tU(v,e+1,_-e-1),N.b+=I):(E=m.b,R=tU(v,e,_-e),E.b+=R),m.b.b+=of,o>0&&(m.b.b+=iG),O=m.b,O.b+=i$+o,m.b.b}f&&f({moduleName:"gwtapp",sessionId:c,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iF,iH,i$="",iV=" ",iq='"',iG="+",iz="-",iJ=".",iK="0",iW="0.",iZ="0.0",iX="0.00",iY="0.000",i1="0.0000",i0="0.00000",i2="0.000000",i4="0E",i3="0E+",i6=":",i5="BigDecimal",i9="BigDecimal MathContext",i7="BigDecimal;",i8="BigInteger",on="BigInteger divide by zero",ot="BigInteger not invertible.",oe="BigInteger: modulus not positive",or="BigInteger;",oi="CSS1Compat",oo="Division by zero",ou="Division impossible",of="E",oc='For input string: "',os="Infinite or NaN",oa="Invalid Operation",oh="MathContext",ob="Negative bit address",ol="Rounding necessary",og="RoundingMode",ow="RoundingMode;",od="String",op="[Lcom.iriscouch.gwtapp.client.",o_="[Ljava.lang.",ov="[Ljava.math.",om="\\.",oy="__gwtex_wrap",oC="anonymous",oS="array",oM="bad string format",ox="bigdecimal",oB="com.google.gwt.core.client.",oA="com.google.gwt.core.client.impl.",oN="com.iriscouch.gwtapp.client.",oI="java.lang.",oE="java.math.",oR="java.util.",oO="msie",oD="null",ok="number",oL="number MathContext",oU="number number",oP="object",oQ="opera",oT="org.timepedia.exporter.client.",oj="safari",oF="string",oH="undefined",o$={l:0,m:0,h:524288},oV={l:0,m:4193280,h:1048575},oq={l:4194298,m:4194303,h:1048575},oG={l:4194303,m:4194303,h:1048575},oz={l:0,m:0,h:0},oJ={l:1,m:0,h:0},oK={l:2,m:0,h:0},oW={l:5,m:0,h:0},oZ={l:10,m:0,h:0},oX={l:11,m:0,h:0},oY={l:18,m:0,h:0},o1={l:48,m:0,h:0},o0={l:877824,m:119,h:0},o2={l:1755648,m:238,h:0},o4={l:4194303,m:511,h:0},o3={l:4194303,m:1023,h:0},o6={l:0,m:1024,h:0};(iH=s.prototype={}).eQ=function(n){return this===n},iH.gC=function(){return fc},iH.hC=function(){return nj(this)},iH.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tL(fJ,{6:1},-1,8,1),r_(),e=7,n>=0)for(;n>15;)t[e--]=uR[15&n],n>>=4;else for(;e>0;)t[e--]=uR[15&n],n>>=4;return t[e]=uR[15&n],t4(t,e,8)}(this.hC())},iH.toString=function(){return this.tS()},iH.tM=l,iH.cM={},(iH=a.prototype=new s).gC=function(){return fa},iH.j=function(){return this.f},iH.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},iH.cM={6:1,15:1},iH.f=null,(iH=h.prototype=new a).gC=function(){return fh},iH.cM={6:1,15:1},(iH=ne.prototype=b.prototype=new h).gC=function(){return fb},iH.cM={6:1,12:1,15:1},(iH=n1.prototype=(function(){}).prototype=new b).gC=function(){return fl},iH.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?oD:tn(e)?null==(r=t9(e))?null:r.name:nG(e,1)?od:(nF(e)?e.gC():fg).d,this.b=tn(n=this.c)?null==(i=t9(n))?null:i.message:n+i$,this.d="("+this.e+"): "+this.b+(tn(t=this.c)?function(n){var t=i$;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t9(t)):i$)),this.d},iH.cM={6:1,12:1,15:1},iH.b=null,iH.c=null,iH.d=null,iH.e=null,(iH=g.prototype=new s).gC=function(){return fw};var o5=0,o9=0;(iH=w.prototype=(function(){}).prototype=new g).gC=function(){return fv},iH.b=null,iH.c=null,(iH=d.prototype=_.prototype=new s).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i6+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oC},iH.gC=function(){return fm},iH.o=function(n){return[]},(iH=v.prototype=new _).k=function(){return tl(this.o(tw()),this.p())},iH.gC=function(){return fS},iH.o=function(n){return eR(this,n)},iH.p=function(){return 2},(iH=m.prototype=(function(){}).prototype=new v).k=function(){return es(this)},iH.n=function(n){var t,e;return 0==n.length||(0==(e=e9(n)).indexOf("at ")&&(e=n7(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oC:(-1!=(t=(e=e9(e.substr(0,t-0))).indexOf("."))&&(e=n7(e,t+1)),e.length>0?e:oC)},iH.gC=function(){return fM},iH.o=function(n){return t2(this,n)},iH.p=function(){return 3},(iH=y.prototype=new s).gC=function(){return fx},(iH=C.prototype=(function(){}).prototype=new y).gC=function(){return fB},iH.b=i$,(iH=S.prototype=(function(){}).prototype=new s).gC=function(){return this.aC},iH.aC=null,iH.qI=0;var o7=null,o8=null;(iH=M.prototype=(function(){}).prototype=new s).gC=function(){return fI},iH.cM={2:1},(iH=x.prototype=new s).gC=function(){return fR},iH.cM={6:1,10:1};var un=null;(iH=eo.prototype=tr.prototype=tM.prototype=tA.prototype=Z.prototype=ep.prototype=eu.prototype=tB.prototype=tx.prototype=ez.prototype=n2.prototype=n4.prototype=te.prototype=tS.prototype=nk.prototype=B.prototype=new x).eQ=function(n){return e0(this,n)},iH.gC=function(){return fO},iH.hC=function(){return rv(this)},iH.q=function(){return rT(this)},iH.r=function(){return ew(this)},iH.tS=function(){return id(this)},iH.cM={6:1,8:1,10:1,16:1},iH.b=0,iH.c=0,iH.d=null,iH.e=0,iH.f=0,iH.g=0,iH.i=null;var ut,ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_=null,uv=null,um=null;(iH=nL.prototype=ng.prototype=(function(){}).prototype=new B).s=function(n){var t,e,r;if((e=iI(n))==i$)t=0>ew(this)?ed(this):this;else if(e==oh)t=0>(r=t7(this,new iS(n[0].toString()))).r()?ed(r):r;else throw new ne("Unknown call signature for interim = super.abs: "+e);return new nL(t)},iH.t=function(n){var t,e;if((e=iI(n))==i5)t=r1(this,new Z(n[0].toString()));else if(e==i9)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t7(r1(n,t),e);if((n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)0?t.e:nU((t.b-1)*.3010299956639812)+1)<-r-1))return t7(r1(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nU((i.b-1)*.3010299956639812)+1)?t7(r1(n,t),e):(f=(o=i.r())==u.r()?iC(rW((i.d||(i.d=eU(i.g)),i.d),10),eW(e3(o))):iC(rW(f=is((i.d||(i.d=eU(i.g)),i.d),eW(e3(o))),10),eW(e3(9*o))),t7(i=new tM(f,i.f+1),e))}(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.add: "+e);return new nL(t)},iH.u=function(){return~~(nx(t8(this,8))<<24)>>24},iH.v=function(n){return iu(this,n)},iH.w=function(n){var t,e,r,i;if((i=iI(n))==i5)e=eb(this,new Z(n[0].toString()));else if(i==i9)e=el(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tL(fk,{6:1},3,e.length,0);t129?n*=1/0:n=t5(id(this)),n},iH.gC=function(){return fD},iH.hC=function(){return rv(this)},iH.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nU((this.b-1)*.3010299956639812)+1)?0:(n=new n0(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eU(this.g)),this.d):this.f<0?en((this.d||(this.d=eU(this.g)),this.d),iv(-this.f)):ia((this.d||(this.d=eU(this.g)),this.d),iv(this.f)))).f*n.b[0]},iH.C=function(){return nx(t8(this,32))},iH.D=function(){return nx(t8(this,32))},iH.E=function(){return t5(id(this))},iH.F=function(n){return new nL(iu(this,n)>=0?this:n)},iH.G=function(n){return new nL(0>=iu(this,n)?this:n)},iH.H=function(n){return new nL(rz(this,this.f+n))},iH.I=function(n){return new nL(rz(this,this.f-n))},iH.J=function(n){var t,e;if((e=iI(n))==i5)t=rD(this,new Z(n[0].toString()));else if(e==i9)t=tb(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.multiply: "+e);return new nL(t)},iH.K=function(n){var t,e;if((e=iI(n))==i$)t=ed(this);else if(e==oh)t=ed(t7(this,new iS(n[0].toString())));else throw new ne("Unknown call signature for interim = super.negate: "+e);return new nL(t)},iH.L=function(n){var t,e;if((e=iI(n))==i$)t=this;else if(e==oh)t=t7(this,new iS(n[0].toString()));else throw new ne("Unknown call signature for interim = super.plus: "+e);return new nL(t)},iH.M=function(n){var t,e;if((e=iI(n))==ok)t=rw(this,n[0]);else if(e==oL)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=ei(n8(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rw(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new nr(oa);for(u>0&&(f=new eK(u+i+1,e.c)),r=t7(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tb(r,r,f),(o&c)==c&&(r=tb(r,n,f)),c>>=1;return t<0&&(r=iR(ug,r,f)),ic(r,e),r}(this,n[0],new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.pow: "+e);return new nL(t)},iH.q=function(){return rT(this)},iH.N=function(n){var t,e;if((e=iI(n))==i5)t=eb(this,new Z(n[0].toString()))[1];else if(e==i9)t=el(this,new Z(n[0].toString()),new iS(n[1].toString()))[1];else throw new ne("Unknown call signature for interim = super.remainder: "+e);return new nL(t)},iH.O=function(n){return new nL(t7(this,new iS(ea(n.b))))},iH.P=function(){return ei(this.f)},iH.Q=function(n){var t,e;return new nL((t=this,(e=t.f-n,t.b<54)?0==t.g?eL(e):new tr(t.g,eJ(e)):new tS((t.d||(t.d=eU(t.g)),t.d),eJ(e))))},iH.R=function(n){var t,e;if((e=iI(n))==ok)t=rY(this,n[0],(iB(),u4));else if(e==oU)t=rY(this,n[0],rP(n[1]));else if("number RoundingMode"==e)t=rY(this,n[0],tc(n[1].toString()));else throw new ne("Unknown call signature for interim = super.setScale: "+e);return new nL(t)},iH.S=function(){return~~(nx(t8(this,16))<<16)>>16},iH.r=function(){return ew(this)},iH.T=function(){return new nL(function(n){var t,e,r,i,o;if(t=1,e=uv.length-1,r=n.f,0==n.b&&-1!=n.g)return new Z(iK);for(n.d||(n.d=eU(n.g)),o=n.d;!o.gb(0);)if(0==(i=r3(o,uv[t]))[1].r())r-=t,t0?i.e:nU((i.b-1)*.3010299956639812)+1)0?r.e:nU((r.b-1)*.3010299956639812)+1)?(f=(c=ew(r))!=i.r()?iC(rW((r.d||(r.d=eU(r.g)),r.d),10),eW(e3(c))):iC(rW(f=is((r.d||(r.d=eU(r.g)),r.d),eW(e3(c))),10),eW(e3(9*c))),t7(new tM(f,r.f+1),o)):t7(iO(r,i),o);else throw new ne("Unknown call signature for interim = super.subtract: "+e);return new nL(t)},iH.V=function(){return new n0(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eU(this.g)),this.d):this.f<0?en((this.d||(this.d=eU(this.g)),this.d),iv(-this.f)):ia((this.d||(this.d=eU(this.g)),this.d),iv(this.f)))},iH.W=function(){return new n0(r6(this))},iH.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eU(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nV(u),n.f>0&&i>=-6)i>=0?n9(c,r-ei(n.f),iJ):(tt(c.b,t-1,t-1,iW),n9(c,t+1,tU(us,0,-ei(i)-1)));else{if(e=r-t,0!=(f=ei(i%3))&&(0==(n.d||(n.d=eU(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n9(c,r++,iK);r-t>=1&&(tt(c.b,t,t,iJ),++r),0!=i&&(tt(c.b,r,r,of),i>0&&n9(c,++r,iG),n9(c,++r,i$+r4(r2(i))))}return c.b.b}(this)},iH.Y=function(){return function(n){var t,e,r,i,o,u;if(r=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ew(n)?1:0,e=n.f,i=new W(r.length+1+((o=ei(n.f))<0?-o:o)),1==t&&(i.b.b+=iz),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iW;e>us.length;e-=us.length)tq(i,us);n5(i,us,ei(e)),nI(i,n7(r,t))}else nI(i,(u=ei(e=t-e),r.substr(t,u-t))),i.b.b+=iJ,nI(i,n7(r,ei(e)))}else{for(nI(i,n7(r,t));e<-us.length;e+=us.length)tq(i,us);n5(i,us,ei(-e))}return i.b.b}(this)},iH.tS=function(){return id(this)},iH.Z=function(){return new nL(new tr(1,this.f))},iH.$=function(){return new n0((this.d||(this.d=eU(this.g)),this.d))},iH.cM={3:1,6:1,8:1,10:1,16:1,24:1},(iH=F.prototype=(function(){}).prototype=new s).gC=function(){return fL};var uy=!1;(iH=ro.prototype=ri.prototype=ti.prototype=e5.prototype=t$.prototype=ra.prototype=nq.prototype=iy.prototype=A.prototype=new x)._=function(){return this.f<0?new ti(1,this.e,this.b):this},iH.ab=function(){return eV(this)},iH.eQ=function(n){return e$(this,n)},iH.gC=function(){return fU},iH.bb=function(){return t1(this)},iH.hC=function(){return eD(this)},iH.cb=function(){return 0==this.f?this:new ti(-this.f,this.e,this.b)},iH.db=function(n){return rk(this,n)},iH.eb=function(n){return tX(this,n)},iH.fb=function(n){return tY(this,n)},iH.r=function(){return this.f},iH.gb=function(n){return rQ(this,n)},iH.tS=function(){return ij(this,0)},iH.cM={6:1,8:1,10:1,17:1},iH.b=null,iH.c=-2,iH.d=0,iH.e=0,iH.f=0;var uC,uS,uM,ux,uB,uA=null;(iH=n0.prototype=nO.prototype=nD.prototype=(function(){}).prototype=new A)._=function(){return new n0(this.f<0?new ti(1,this.e,this.b):this)},iH.hb=function(n){return new n0(iC(this,n))},iH.ib=function(n){return new n0(0==n.f||0==this.f?(rK(),uB):e$(n,(rK(),uC))?this:e$(this,uC)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=nd(n.e,t.e),(e=np(eg(n),eg(t)))>=i)return rK(),uB;for(r=tL(fd,{6:1},-1,i,1);e0?rG(n,this):this.e>n.e?ip(this,n):ip(n,this))},iH.jb=function(n){return new n0(0==n.f?this:0==this.f?(rK(),uB):e$(this,(rK(),uC))?new n0(r7(n)):e$(n,uC)?uB:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tL(fd,{6:1},-1,n.e,1),r=nd(n.e,t.e),e=eg(n);e=n.e)return n;for(o=tL(fd,{6:1},-1,u=nd(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=eg(n),o=eg(t),i>=t.e)return n;if(c=np(n.e,t.e),r=i,o>i){for(f=tL(fd,{6:1},-1,c,1),u=nd(n.e,o);r=t.e)return rK(),uB;if(u=tL(fd,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},iH.qb=function(n){return new n0(rE(this,n))},iH.gC=function(){return fP},iH.bb=function(){return t1(this)},iH.hC=function(){return eD(this)},iH.B=function(){return this.f*this.b[0]},iH.rb=function(n){return function(n,t){var e,r;if(iT(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rQ(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uK,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n0(this.f<0?new ti(1,this.e,this.b):this),n)},iH.sb=function(){return t5(ij(this,0))},iH.tb=function(n){return new n0(1==rn(this,n)?this:n)},iH.ub=function(n){return new n0(-1==rn(this,n)?this:n)},iH.vb=function(n){return new n0(et(this,n))},iH.wb=function(n){return new n0(rR(this,n))},iH.xb=function(n,t){return new n0(rq(this,n,t))},iH.yb=function(n){return new n0(en(this,n))},iH.cb=function(){return new n0(0==this.f?this:new ti(-this.f,this.e,this.b))},iH.zb=function(){return new n0(function(n){if(n.f<0)throw new nr("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(iT(),o=tL(fd,{6:1},-1,uK.length,1),r=tL(f_,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uK[e];++e);return uJ[e]}for(f=new ti(1,n.e,tL(fd,{6:1},-1,n.e+1,1)),ix(n.b,0,f.b,0,n.e),rQ(n,0)?tK(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rl(this,n):rl(n,this):ig(this,n):n.f>0?ig(n,this):eg(n)>eg(this)?rZ(n,this):rZ(this,n))},iH.db=function(n){return new n0(rk(this,n))},iH.Cb=function(n){return new n0(rF(this,n))},iH.Db=function(n){return new n0(rQ(this,n)?this:it(this,n))},iH.eb=function(n){return new n0(tX(this,n))},iH.fb=function(n){return new n0(tY(this,n))},iH.r=function(){return this.f},iH.Eb=function(n){return new n0(is(this,n))},iH.gb=function(n){return rQ(this,n)},iH.Fb=function(n){var t,e;if((e=iI(n))==i$)t=ij(this,0);else if(e==ok)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(iM(),g=n.f,s=n.e,u=n.b,0==g)return iK;if(1==s)return _=ts(e3(u[0]),o3),g<0&&(_=eP(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return i$+r4(n);if(e=tL(fJ,{6:1},-1,65,1),r_(),r=64,i=e3(t),rA(n,oz)){for(;rA(n,i);)e[r--]=uR[nx(n3(n,i))],n=iN(n,i,!1);e[r]=uR[nx(n)]}else{for(;!rB(n,eP(i));)e[r--]=uR[nx(eP(n3(n,i)))],n=iN(n,i,!1);e[r--]=uR[nx(eP(n))],e[r]=45}return t4(e,r,65)}(_,t);if(10==t||t<2||t>36)return ij(n,0);if(l=tL(fJ,{6:1},-1,b=ei(eV(new n0(n.f<0?new ti(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(ix(u,0,w=tL(fd,{6:1},-1,s,1),0,s),d=s,r=uU[t],e=uL[t-2];;){h=ir(w,w,d,e),a=i;do l[--i]=ev(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=ev(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tU(l,i,b-i)}(this,n[0]);else throw new ne("Unknown call signature for result = super.toString: "+e);return t},iH.Gb=function(n){return new n0(0==n.f?this:0==this.f?n:e$(n,(rK(),uC))?new n0(r7(this)):e$(this,uC)?new n0(r7(n)):this.f>0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iL(this,n):n.f>0?iL(n,this):eg(n)>eg(this)?ii(n,this):ii(this,n))},iH.cM={4:1,6:1,8:1,10:1,17:1,24:1},(iH=j.prototype=(function(){}).prototype=new s).gC=function(){return fT};var uN=!1;(iH=nv.prototype=nm.prototype=(function(){}).prototype=new s).gC=function(){return fj},iH.Hb=function(){return this.b.b},iH.Ib=function(){return new Y(this.b.c)},iH.hC=function(){return nM(this.b)},iH.tS=function(){return ea(this.b)},iH.cM={24:1},iH.b=null,(iH=T.prototype=(function(){}).prototype=new s).gC=function(){return fF};var uI=!1;(iH=Y.prototype=ny.prototype=(function(){}).prototype=new s).gC=function(){return fH},iH.Jb=function(){return this.b.b},iH.tS=function(){return this.b.b},iH.cM={5:1,24:1},iH.b=null,(iH=J.prototype=(function(){}).prototype=new s).gC=function(){return fV};var uE=!1;(iH=nr.prototype=(function(){}).prototype=new b).gC=function(){return fq},iH.cM={6:1,12:1,15:1},(iH=ni.prototype=$.prototype=(function(){}).prototype=new b).gC=function(){return fz},iH.cM={6:1,12:1,15:1},(iH=N.prototype=(function(){}).prototype=new s).gC=function(){return fK},iH.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?i$:"class ")+this.d},iH.b=null,iH.c=0,iH.d=null,(iH=H.prototype=(function(){}).prototype=new b).gC=function(){return fW},iH.cM={6:1,12:1,15:1},(iH=I.prototype=new s).eQ=function(n){return this===n},iH.gC=function(){return fs},iH.hC=function(){return nj(this)},iH.tS=function(){return this.b},iH.cM={6:1,8:1,9:1},iH.b=null,iH.c=0,(iH=no.prototype=V.prototype=E.prototype=new b).gC=function(){return fZ},iH.cM={6:1,12:1,15:1},(iH=nu.prototype=q.prototype=R.prototype=new b).gC=function(){return fG},iH.cM={6:1,12:1,15:1},(iH=nf.prototype=G.prototype=(function(){}).prototype=new b).gC=function(){return fX},iH.cM={6:1,12:1,15:1},(iH=nw.prototype=(function(){}).prototype=new E).gC=function(){return fY},iH.cM={6:1,12:1,15:1},(iH=to.prototype=(function(){}).prototype=new s).gC=function(){return fy},iH.tS=function(){return this.b+iJ+this.d+"(Unknown Source"+(this.c>=0?i6+this.c:i$)+")"},iH.cM={6:1,13:1},iH.b=null,iH.c=0,iH.d=null,(iH=String.prototype).eQ=function(n){return tj(this,n)},iH.gC=function(){return fA},iH.hC=function(){var n,t;return nJ(),null!=(t=uD[n=i6+this])?t:(null==(t=uO[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;et?n:t}function nv(n,t){return!rN(n,t)}function nm(n){this.b=new iM(n)}function ny(){this.b=(rF(),uF)}function nC(){this.b=(iA(),u4)}function nS(n,t){var e;nb(),e=o.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tw(n){return nz(n,15)?n:new n0(n)}function td(){try{null.a()}catch(n){return n}}function tp(n){var t;return(t=new I).d=iV+n,t.c=1,t}function t_(n,t){return nH(n)?n.eQ(t):n===t}function tv(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tm(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function ty(n,t,e){return(i$=new x).l=n,i$.m=t,i$.h=e,i$}function tC(n,t){return nj(n)===nj(t)||null!=n&&t_(n,t)}function tS(n,t){throw new nf("Index: "+n+", Size: "+t)}function tM(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tx(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tB(n,t,e,r){eJ.call(this,n,t,e),is(this,r)}function tA(n,t){eJ.call(this,n,0,n.length),is(this,t)}function tN(n,t){eJ.call(this,t5(n),0,n.length),is(this,t)}function tI(n){nr.call(this,"String index out of range: "+n)}function tE(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tR(n,t){rC(n.b,n.b,n.e,t.b,t.e),tZ(n),n.c=-2}function tO(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=ri(eN(t)))}function tD(){tD=g,ur=[],ui=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new M,ur,ui)}function tk(){uC||(uC=!0,new j,new F,function(){if(ng(oB,iV),u.bigdecimal.BigDecimal)var n=u.bigdecimal.BigDecimal;u.bigdecimal.BigDecimal=fc(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fk?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new nw,nl(this.__gwt_instance,this))});var t=u.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)u.bigdecimal.BigDecimal[p]=n[p];u.bigdecimal.BigDecimal.ROUND_CEILING=2,u.bigdecimal.BigDecimal.ROUND_DOWN=1,u.bigdecimal.BigDecimal.ROUND_FLOOR=3,u.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,u.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,u.bigdecimal.BigDecimal.ROUND_HALF_UP=4,u.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,u.bigdecimal.BigDecimal.ROUND_UP=0,u.bigdecimal.BigDecimal.__init__=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==on)t=new nL(new nG(n[0].toString()));else if("BigInteger number"==e)t=new tM(new nG(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new tr(new nG(n[0].toString()),n[1],new iM(n[2].toString()));else if("BigInteger MathContext"==e)t=new n3(new nG(n[0].toString()),new iM(n[1].toString()));else if(e==oM)t=new n4(t5(n[0].toString()));else if("array number number"==e)t=new eJ(t5(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tB(t5(n[0].toString()),n[1],n[2],new iM(n[3].toString()));else if("array MathContext"==e)t=new tA(t5(n[0].toString()),new iM(n[1].toString()));else if(e==oL)t=new ef(n[0]);else if(e==oU)t=new e_(n[0],new iM(n[1].toString()));else if(e==oH)t=new X(n[0].toString());else if("string MathContext"==e)t=new tN(n[0].toString(),new iM(n[1].toString()));else throw new nr("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nU(t)}(n);return nR(t)}),t.abs_va=fc(function(n){return nR(this.__gwt_instance.s(n))}),t.add_va=fc(function(n){return nR(this.__gwt_instance.t(n))}),t.byteValueExact=fc(function(){return this.__gwt_instance.u()}),t.compareTo=fc(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=fc(function(n){return nR(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=fc(function(n){return nR(this.__gwt_instance.x(n))}),t.doubleValue=fc(function(){return this.__gwt_instance.z()}),t.equals=fc(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=fc(function(){return this.__gwt_instance.A()}),t.hashCode=fc(function(){return this.__gwt_instance.hC()}),t.intValue=fc(function(){return this.__gwt_instance.B()}),t.intValueExact=fc(function(){return this.__gwt_instance.C()}),t.max=fc(function(n){return nR(this.__gwt_instance.F(n.__gwt_instance))}),t.min=fc(function(n){return nR(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=fc(function(n){return nR(this.__gwt_instance.H(n))}),t.movePointRight=fc(function(n){return nR(this.__gwt_instance.I(n))}),t.multiply_va=fc(function(n){return nR(this.__gwt_instance.J(n))}),t.negate_va=fc(function(n){return nR(this.__gwt_instance.K(n))}),t.plus_va=fc(function(n){return nR(this.__gwt_instance.L(n))}),t.pow_va=fc(function(n){return nR(this.__gwt_instance.M(n))}),t.precision=fc(function(){return this.__gwt_instance.q()}),t.remainder_va=fc(function(n){return nR(this.__gwt_instance.N(n))}),t.round=fc(function(n){return nR(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=fc(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=fc(function(n){return nR(this.__gwt_instance.Q(n))}),t.setScale_va=fc(function(n){return nR(this.__gwt_instance.R(n))}),t.shortValueExact=fc(function(){return this.__gwt_instance.S()}),t.signum=fc(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=fc(function(){return nR(this.__gwt_instance.T())}),t.subtract_va=fc(function(n){return nR(this.__gwt_instance.U(n))}),t.toBigInteger=fc(function(){return nR(this.__gwt_instance.V())}),t.toBigIntegerExact=fc(function(){return nR(this.__gwt_instance.W())}),t.toEngineeringString=fc(function(){return this.__gwt_instance.X()}),t.toPlainString=fc(function(){return this.__gwt_instance.Y()}),t.toString=fc(function(){return this.__gwt_instance.tS()}),t.ulp=fc(function(){return nR(this.__gwt_instance.Z())}),t.unscaledValue=fc(function(){return nR(this.__gwt_instance.$())}),t.divideAndRemainder_va=fc(function(n){return nO(this.__gwt_instance.w(n))}),t.longValue=fc(function(){return this.__gwt_instance.E()}),t.longValueExact=fc(function(){return this.__gwt_instance.D()}),u.bigdecimal.BigDecimal.valueOf_va=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==oL)t=function(n){if(!isFinite(n)||isNaN(n))throw new nd(oa);return new X(iV+n)}(n[0]);else if(e==oL)t=tX(e6(n[0]));else if(e==oP)t=eL(e6(n[0]),n[1]);else throw new nr("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nU(t)}(n);return nR(t)}),u.bigdecimal.BigDecimal.log=fc(function(n){iP(),typeof console!==o$&&console.log&&console.log(n)}),u.bigdecimal.BigDecimal.logObj=fc(function(n){iP(),typeof console!==o$&&console.log&&typeof JSON!==o$&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),u.bigdecimal.BigDecimal.ONE=fc(function(){var n=(iP(),new nU(uw));return nR(n)}),u.bigdecimal.BigDecimal.TEN=fc(function(){var n=(iP(),new nU(ud));return nR(n)}),u.bigdecimal.BigDecimal.ZERO=fc(function(){var n=(iP(),new nU(up));return nR(n)}),nS(fk,u.bigdecimal.BigDecimal)}())}function tL(n,t,e){var r;return(r=new I).d=n+t,r.c=4,r.b=e,r}function tU(n,t,e,r,i){var o;return tK(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tI(e)}(n.length,t,r),t3(n,t,r)}function tQ(n,t){return il(),t=n.c.c)throw new J;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tS(r,i),t.b[e]}function tF(n,t){return!!nz(t,1)&&String(n)==t}function tH(){nr.call(this,"Add not supported on this collection")}function t$(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function tV(n,t){rW(),this.f=n,this.e=1,this.b=tK(fp,{6:1},-1,[t])}function tq(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tG(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tz(n,t,e,r){var i,o;return null==t&&(t=ok),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tJ(n,t,e,r){var i;return rC(i=tU(fp,{6:1},-1,t,1),n,t,e,r),i}function tK(n,t,e,r){return tD(),function(n,t,e){tD();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tX(n){return rN(n,oJ)&&nv(n,oY)?us[nB(n)]:new eu(n,0)}function tY(n,t){return 0==t||0==n.f?n:t>0?e3(n,t):rY(n,-t)}function t1(n,t){return 0==t||0==n.f?n:t>0?rY(n,t):e3(n,-t)}function t0(n){var t;return 0==n.f?-1:((t=ew(n))<<5)+es(n.b[t])}function t2(n){var t;return 0!=(t=nB(n))?es(t):es(nB(rK(n,32)))+32}function t4(n,t){var e;return 0==(e=eO(n,t)).length?(new _).o(t):tg(e,1)}function t3(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t6(n,t,e,r){var i;return ib(i=tU(fp,{6:1},-1,t+1,1),n,t,e,r),i}function t5(n){var t,e;return t=tU(fK,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nB(y=iR(ta(e6(b.b[0]),o6),ta(e6(l.b[0]),o6))),0==(C=nB(rP(y,32)))?new tV(v,S):new to(v,2,tK(fp,{6:1},-1,[S,C]))):(eG(b.b,g,l.b,w,d=tU(fp,{6:1},-1,_,1)),tZ(m=new to(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=ia(t,a.eb(f)),o=ia(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iS(iS(u=n(ia(a,i),ia(o,h)),s),r)).eb(f),iS(iS(s=s.eb(f<<1),u),r))}(n,t))}function ee(n,t){var e;if(t.f<=0)throw new ni(or);return(e=rH(n,t)).f<0?iS(e,t):e}function er(n){var t;t=new nJ,n.d&&n5(t,new ne(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nA(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eP(n.g)),n.d).r()}function ep(n){return n.b<54?new ti(-n.g,n.f):new tx((n.d||(n.d=eP(n.g)),n.d).cb(),n.f)}function e_(n,t){if(!isFinite(n)||isNaN(n))throw new nd(oa);iQ(this,n.toPrecision(20)),is(this,t)}function ev(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function em(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function ey(n,t){var e,r;return t?((e=t[oC])||(e=new(r=t.gC(),t7(ei(n.b,r)))(t),t[oC]=e),e):null}function eC(n){var t,e;return 32==(e=r$(n.h))?32==(t=r$(n.m))?r$(n.l)+32:t+20-10:e-12}function eS(n){return ty(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eM(){eM=g,uo=ty(4194303,4194303,524287),uu=ty(0,0,524288),uf=e6(1),e6(2),uc=e6(0)}function ex(n,t){ib(n.b,n.b,n.e,t.b,t.e),n.e=np(n_(n.e,t.e)+1,n.b.length),tZ(n),n.c=-2}function eB(n,t){var e;e=~~t>>5,n.e+=e+(r$(n.b[n.e-1])-(31&t)>=0?0:1),rS(n.b,n.b,e,31&t),tZ(n),n.c=-2}function eA(n,t){var e,r;e=~~t>>5,n.e>>r:0,tZ(n))}function eN(n){var t;return t=n.e>1?th(rU(e6(n.b[1]),32),ta(e6(n.b[0]),o6)):ta(e6(n.b[0]),o6),iR(e6(n.f),t)}function eI(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:nv(ta(e6(n[r]),o6),ta(e6(t[r]),o6))?-1:1}function eE(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eR(n,t,e,r){if(iH=t,n)try{fc(iy)()}catch(i){n(t)}else fc(iy)()}function eO(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eu(oJ,2147483647):new eu(oJ,-2147483648)}function eP(n){return(rW(),n<0)?-1!=n?new ru(-1,-n):uS:n<=10?ux[eo(n)]:new ru(1,n)}function eQ(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,ty(t,e,r)}function eT(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function ej(n){var t,e,r;for(r=0,e=tU(fS,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rA(ta(e6(n[r]),o6),ta(e6(i[r]),o6));break}}return u=new to(1,o+1,n),e&&tR(u,t),tZ(u),u}(o,e)}function eV(n,t){var e;return n===t||!!nz(t,17)&&(e=tT(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eq(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&ew(n)==n.e-1&&(e=~~(e-1)),t-=r$(e))}function eG(n,t,e,r,i){il(),0!=t&&0!=r&&(1==t?i[r]=rc(i,e,r,n[0]):1==r?i[t]=rc(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nj(n)===nj(t)&&r==i){iu(n,r,e);return}for(f=0;f2147483647))return eo(n);throw new ni("Underflow")}function eW(n,t){if(rF(),n<0)throw new nu("Digits < 0");if(!t)throw new nc("null RoundingMode");this.b=n,this.c=t}function eZ(n){return(rW(),nv(n,oJ))?tm(n,oz)?new ro(-1,eQ(n)):uS:rA(n,oX)?new ro(1,n):ux[nB(n)]}function eX(n){var t;return nv(n,oJ)&&(n=ty(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nB(rK(n,32)))?r$(t):r$(nB(n))+32)}function eY(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e0(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-n_(e,n.bb())}function e2(n,t){var e;return n===t||!!nz(t,16)&&(e=tT(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e4(n,t,e){var r,i,o;for(o=oJ,r=t-1;r>=0;--r)i=r2(eY(rU(o,32),ta(e6(n[r]),o6)),e),o=e6(nB(rK(i,32)));return nB(o)}function e3(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rS(r=tU(fp,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tZ(o=new to(n.f,i,r)),o}function e6(n){var t,e;return n>-129&&n<128?(t=n+128,null==un&&(un=tU(fR,{6:1},2,256,0)),(e=un[t])||(e=un[t]=eS(n)),e):eS(n)}function e5(n){var t,e,r;return(rW(),n>5,t=31&n,(r=tU(fp,{6:1},-1,e+1,1))[e]=1<iq&&n[n.length-1]>iq?n:n.replace(/^(\s*)/,iV).replace(/\s*$/,iV)}function e8(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function rn(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==g||n$(e,1)))throw new V}return n[t]=e}function rt(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=e$(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=e$(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tU(f9,{6:1},17,8,0),a=n,rn(s,0,t),h=e$(t,t,r,i),u=1;u<=7;++u)rn(s,u,e$(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=e$(a,a,r,i);return a}(f,r,t,e,o),e$(u,(rW(),uM),e,o)}function ra(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nd("Radix out of range");if(0==n.length)throw new nd("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(ix(),uP)[e])),0!=(d=l%u)&&++o,c=tU(fp,{6:1},-1,o,1),r=uU[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:nv(ta(e6(n[i]),o6),ta(e6(t[i]),o6))?-1:1}function rg(n,t){var e,r,i;for(r=tU(fp,{6:1},-1,i=n.e,1),np(ew(n),ew(t)),e=0;e999999999)throw new ni(oh);return e=n.f*t,0==n.b&&-1!=n.g?eU(e):new tM((n.d||(n.d=eP(n.g)),n.d).db(t),eK(e))}function rp(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fu[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fo[n]=t,t*=.5}function rv(){rv=g,uO=tK(fK,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rm(n){var t;return 0!=n.c?n.c:n.b<54?(t=r4(n.g),n.c=nB(ta(t,oz)),n.c=33*n.c+nB(ta(rK(t,32),oz)),n.c=17*n.c+eo(n.f),n.c):(n.c=17*n.d.hC()+eo(n.f),n.c)}function ry(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=ev(n*t,0),0!=u&&(i=ev((u<=0?0-u:u)*2,t<=0?0-t:t),o+=it(1&eo(o),f*(5+i),r)),new ti(o,e)}function rC(n,t,e,r,i){var o,u;for(u=0,o=oJ;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rD(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=eo(nP(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eX(r4(n))}function rR(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eZ(rI(eN(e),eN(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rB(n,e),rB(t,r),1==rt(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eZ(rI(eN(n),eN(t)));break}if(t.e>1.2*n.e)0!=(t=rH(t,n)).r()&&rB(t,t.bb());else do tR(t,n),rB(t,t.bb());while(rt(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?eB(f,i):(rB(c,r-e0&&eB(f,i-r+e)),e+=i),0!=(i=e0(h,u))&&(eB(h,i),r>=e?eB(c,i):(rB(f,e-r0&&eB(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rq(s,h),rq(f,c)):(rq(h,s),rq(c,f)):e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)),0==h.r()||0==s.r())throw new ni(oe);return eD(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():ia(t,f)),0>f.r()&&(f=iS(f,t)),f}(n,t);for(o=32*t.e,h=eb(t),u=n_((b=eb(n)).e,h.e),c=new to(1,1,tU(fp,{6:1},-1,u+1,1)),(s=new to(1,1,tU(fp,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rB(h,r),rB(b,i),eB(c,i),e+=r-i):(rB(h,r),rB(b,i),eB(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rt(h,b)>0;)tR(h,b),a=h.bb(),rB(h,a),ex(c,s),eB(s,a),e+=a;for(;0>=rt(h,b)&&(tR(b,h),0!=b.r());)a=b.bb(),rB(b,a),ex(s,c),eB(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new ni(oe);return rt(c,t)>=0&&tR(c,t),c=ia(t,c),f=rf(t),e>o&&(c=e$(c,(rW(),uM),t,f),e-=o),c=e$(c,e5(o-e),t,f)}(ee(n._(),t),t)).f)throw new ni(oe);return n.f<0?ia(t,e):e}function rD(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rk(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eU(e):n.b+t.b<54?new ti(n.g*t.g,eK(e)):new tM(et((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),eK(e))}function rL(n,t){var e;if(t<0)throw new ni("Negative exponent");if(0==t)return uM;if(1==t||n.eQ(uM)||n.eQ(uA))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return et(e5(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(il(),rW(),r=uM,e=n;t>1;t>>=1)(1&t)!=0&&(r=et(r,e)),e=1==e.e?et(e,e):new e9(iu(e.b,e.e,tU(fp,{6:1},-1,e.e<<1,1)));return et(r,e)}(n,t)}function rU(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),ty(4194303&r,4194303&i,1048575&o)}function rQ(n){switch(iA(),n){case 2:return uX;case 1:return uY;case 3:return u1;case 5:return u0;case 6:return u2;case 4:return u4;case 7:return u3;case 0:return u6;default:throw new nu("Invalid rounding mode")}}function rT(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new ni(ol);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=ew(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rj(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ih((n.d||(n.d=eP(n.g)),n.d),im(t)).r()&&++t),n.e=eo(t)),n.e}function rF(){rF=g,uQ=new eW(34,(iA(),u2)),uT=new eW(7,u2),uj=new eW(16,u2),uF=new eW(0,u4),uH=tK(fK,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),u$=tK(fK,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rH(n,t){var e,r,i,o;if(0==t.f)throw new ni(ot);return((o=n.e)!=(e=t.e)?o>e?1:-1:eI(n.b,t.b,o))==-1?n:(r=tU(fp,{6:1},-1,e,1),1==e?r[0]=e4(n.b,o,t.b[0]):r=iL(null,o-e+1,n.b,o,t.b,e),tZ(i=new to(n.f,e,r)),i)}function r$(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16),e+=t=~~(r=(n=~~n>>t)-256)>>16&8,n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function rV(n,t){if(0==n.f)iB(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ib(n.b,n.b,n.e,t.b,t.e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rq(n,t){var e;e=rt(n,t),0==n.f?(iB(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ib(n.b,n.b,n.e,t.b,t.e),n.f=e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rG(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new ni(or);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uA:0==r.f&&0==t.f?uM:(t.f<0&&(r=rO(n,e),t=t.cb()),i=e.gb(0)?rs(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rs(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rW(),u=uM,i=eb(t),r=eb(n),n.gb(0)&&eA(i,e-1),eA(r,e),o=i.ab()-1;o>=0;--o)eA(f=eb(u),e),u=et(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eA(u=et(u,r),e);return eA(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e9(tU(fp,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eA(b=et(ia(h,a),s),f),b.f<0&&(b=iS(b,e5(f))),iS(a,et(c,b))),r.f<0&&t.gb(0)&&(i=ee(et(ia(e,uM),i),e)),i)}function rz(n,t){var e,r,i,o,u,f,c;if(i=ew(n),(r=ew(t))>=n.e)return rW(),uA;for(u=tU(fp,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=np(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new ti(n.g,eK(t)):new tM((n.d||(n.d=eP(n.g)),n.d),eK(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),ty(4194303&i,4194303&o,1048575&u)}function rW(){var n;for(n=0,rW=g,uM=new tV(1,1),uB=new tV(1,10),uA=new tV(0,0),uS=new tV(-1,1),ux=tK(f9,{6:1},17,[uA,uM,new tV(1,2),new tV(1,3),new tV(1,4),new tV(1,5),new tV(1,6),new tV(1,7),new tV(1,8),new tV(1,9),uB]),uN=tU(f9,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rW(),uS):(rW(),uA);if(rD(i=tU(fp,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rM(n,t,e):rM(t,n,-e):n_(n.b,t.b)+1<54?new ti(n.g+t.g,n.f):new tx(iS((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f)}function r2(n,t){var e,r,i,o,u;return(r=ta(e6(t),o6),rN(n,oJ))?(o=iI(n,r,!1),u=n6(n,r)):(o=iI(e=rP(n,1),i=e6(~~t>>>1),!1),u=eY(rU(u=n6(e,i),1),ta(n,oK)),(1&t)!=0&&(rA(o,u)?rA(e1(o,u),r)?(u=eY(u,e1(rU(r,1),o)),o=e1(o,oW)):(u=eY(u,e1(r,o)),o=e1(o,oK)):u=e1(u,o))),th(rU(u,32),ta(o,o6))}function r4(n){var t,e,r,i;return isNaN(n)?(eM(),uc):n<-0x8000000000000000?(eM(),uu):n>=0x7fffffffffffffff?(eM(),uo):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=eo(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=eo(n/4194304),n-=4194304*t),i=ty(eo(n),t,e),r&&eT(i),i)}function r3(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iW;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iJ+r3(eQ(n));for(e=n,r=iV;!(0==e.l&&0==e.m&&0==e.h);){if(e=iI(e,e6(1e9),!0),t=iV+nB(o8),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iW+t;r=t+r}return r}function r6(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new ni(ot);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iI(g=ta(e6(S[0]),o6),w=ta(e6(l),o6),!1),v=n6(g,w),x!=i&&(d=eQ(d)),x<0&&(v=eQ(v)),tK(f9,{6:1},17,[eZ(d),eZ(v)])):(_=tU(fp,{6:1},-1,M,1),m=tK(fp,{6:1},-1,[ii(_,S,M,l)]),y=new to(x==i?1:-1,M,_),C=new to(x,1,m),tZ(y),tZ(C),tK(f9,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eI(a,e,h))<0)?tK(f9,{6:1},17,[uA,n]):(b=n.f,f=iL(o=tU(fp,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new to(b==i?1:-1,u,o),s=new to(b,r,f),tZ(c),tZ(s),tK(f9,{6:1},17,[c,s]))}function r5(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eP(n.g)),n.d;if(n.f<0)return et((n.d||(n.d=eP(n.g)),n.d),im(-n.f));if(n.f>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eP(n.g)),n.d).bb()||0!=(t=r6((n.d||(n.d=eP(n.g)),n.d),im(n.f)))[1].r())throw new ni(og);return t[0]}function r9(n,t,e,r,i){var o,u;if(o=oJ,e36)throw new nd("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nd(os+n+iG);return i}function r8(n){var t,e;if(0==n.f)return rW(),uS;if(eV(n,(rW(),uS)))return uA;if(e=tU(fp,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function ie(n,t){var e,r,i,o,u,f,c,s,a;if(s=0==n.f?1:n.f,u=~~t>>5,e=31&t,f=tU(fp,{6:1},-1,c=n_(u+1,n.e)+1,1),r=1<=n.e)f[u]=r;else if(u>(i=ew(n)))f[u]^=r;else if(u=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rG(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rN(a=th(rU(s,32),ta(e6(t[f]),o6)),oJ)?(c=iI(a,o,!1),s=n6(a,o)):(c=iI(i=rP(a,1),u=e6(~~r>>>1),!1),s=eY(rU(s=n6(i,u),1),ta(a,oK)),(1&r)!=0&&(rA(c,s)?rA(e1(c,s),o)?(s=eY(s,e1(rU(o,1),c)),c=e1(c,oW)):(s=eY(s,e1(o,c)),c=e1(c,oK)):s=e1(s,c))),n[f]=nB(ta(c,o6));return nB(s)}function io(n,t){var e,r,i,o,u,f,c;if(u=tU(fp,{6:1},-1,f=n_(n.e,t.e),1),i=ew(n),e=r=ew(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=np(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=et(u,im(r))),rt(o,u))}function is(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r4(ul[r]),b=e1(r4(c.f),e6(r)),h=iI(g=r4(c.g),l,!1),tm(a=n6(g,l),oJ)&&(s=tv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?0:nv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?-1:1,h=eY(h,e6(it(1&nB(h),(tv(a,oJ)?0:nv(a,oJ)?-1:1)*(5+s),t.c))),tn(ri(nv(h,oJ)?eQ(h):h))>=t.b&&(h=nQ(h,oX),b=e1(b,oK))),c.f=eK(ri(b)),c.e=t.b,c.g=ri(h),c.b=eX(h),c.d=null;return}f=im(r),i=r6((n.d||(n.d=eP(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rt(eH(i[1]._()),f),0!=(e=it(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&rn(i,0,iS(i[0],eZ(e6(e)))),new nL(i[0]).q()>o&&(rn(i,0,ih(i[0],(rW(),uB))),--u)),n.f=eK(u),n.e=o,tO(n,i[0])}}function ia(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u<0&&(e=eQ(e)),c<0&&(r=eQ(r)),eZ(e1(e,r));if(-1==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))h=-c,a=u==c?tJ(t.b,f,n.b,o):t6(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rW(),uA;a=tJ(n.b,o,t.b,f)}else a=t6(n.b,o,t.b,f);return tZ(s=new to(h,a.length,a)),s}function ih(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new ni(ot);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nQ(ta(e6(n.b[0]),o6),ta(e6(t.b[0]),o6)),s!=i&&(a=eQ(a)),eZ(a)):0==(e=c!=r?c>r?1:-1:eI(n.b,t.b,c))?s==i?uM:uS:-1==e?uA:(o=tU(fp,{6:1},-1,u=c-r+1,1),1==r?ii(o,n.b,c,t.b[0]):iL(o,u,n.b,c,t.b,r),tZ(f=new to(s==i?1:-1,u,o)),f)}function ib(n,t,e,r,i){var o,u;if(o=eY(ta(e6(t[0]),o6),ta(e6(r[0]),o6)),n[0]=nB(o),o=rK(o,32),e>=i){for(u=1;u0){if(i0?u=tQ(u,eo(i)):i<0&&(o=tQ(o,eo(-i))),id(o,u,e,r)}function iw(n,t){var e,r,i,o,u,f,c;if(r=ew(t),(i=ew(n))>=t.e)return t;if(u=tU(fp,{6:1},-1,f=t.e,1),rt.ab()?(c=eN(s),o=eN(t),i=tv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?0:nv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?-1:1,i=it(f.gb(0)?1:0,a*(5+i),r)):(i=rt(eH(s._()),t._()),i=it(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return eL(eY(eN(f),e6(i)),e);f=iS(f,eZ(e6(i)))}return new tM(f,e)}function ip(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;if(ix(),(u=nv(n,oJ))&&(n=eQ(n)),tv(n,oJ))switch(t){case 0:return iW;case 1:return iX;case 2:return iY;case 3:return i1;case 4:return i0;case 5:return i2;case 6:return i4;default:return s=new W,t<0?s.b.b+=i6:s.b.b+=i3,b=s.b,l=-2147483648==t?"2147483648":iV+-t,b.b+=l,s.b.b}c=tU(fK,{6:1},-1,19,1),e=18,h=n;do f=h,h=nQ(h,oX),c[--e]=65535&nB(eY(o0,e1(f,iR(h,oX))));while(tm(h,oJ))if(r=e1(e1(e1(o1,e6(e)),e6(t)),oK),0==t)return u&&(c[--e]=45),tP(c,e,18-e);if(t>0&&rN(r,oG)){if(rN(r,oJ)){for(o=17,i=e+nB(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tP(c,e,18-e+1)}for(o=2;nv(e6(o),eY(eQ(r),oK));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tP(c,e,18-e)}return(a=e+1,s=new Z,u&&(s.b.b+=iJ),18-a>=1)?(tE(s,c[e]),s.b.b+=iK,g=s.b,w=tP(c,e+1,18-e-1),g.b+=w):(d=s.b,_=tP(c,e,18-e),d.b+=_),s.b.b+=oc,rA(r,oJ)&&(s.b.b+=iz),v=s.b,m=iV+r3(r),v.b+=m,s.b.b}(r4(n.g),eo(n.f)),n.i):(i=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new W).b,u.b+=i,n.f>0&&r>=-6?r>=0?n7(o,e-eo(n.f),iK):(te(o.b,t-1,t-1,iZ),n7(o,t+1,tP(ua,0,-eo(r)-1))):(e-t>=1&&(te(o.b,t,t,iK),++e),te(o.b,e,e,oc),r>0&&n7(o,++e,iz),n7(o,++e,iV+r3(r4(r)))),n.i=o.b.b,n.i)}function i_(n,t){var e,r,i,o,u,f;if(i=ew(n),o=ew(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==iV;)--s;s1e6)throw new ni("power of ten too big");if(n<=2147483647)return uV[1].db(t).eb(t);for(i=r=uV[1].db(2147483647),e=r4(n-2147483647),t=eo(n%2147483647);rA(e,o3);)i=et(i,r),e=e1(e,o3);for(i=(i=et(i,uV[1].db(t))).eb(2147483647),e=r4(n-2147483647);rA(e,o3);)i=i.eb(2147483647),e=e1(e,o3);return i.eb(t)}function iy(){var n,t;c&&rx("com.iriscouch.gwtapp.client.BigDecimalApp"),nZ(new K),nY(new j),nX(new F),tk(new H),c&&rx("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oT)?oT:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=o$)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oF:-1!=t.indexOf(oD)&&f.documentMode>=9?"ie9":-1!=t.indexOf(oD)&&f.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tF(oF,n)||u.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),c&&rx("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=f.compatMode,n=tK(fI,{6:1},1,[oo]);e>5,this.b=tU(fp,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tZ(this)}}function iS(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u==c)?(l=nB(s=eY(e,r)),0==(b=nB(rP(s,32)))?new tV(u,l):new to(u,2,tK(fp,{6:1},-1,[l,b]))):eZ(u<0?e1(r,e):e1(e,r));if(u==c)h=u,a=o>=f?t6(n.b,o,t.b,f):t6(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))return rW(),uA;1==i?(h=u,a=tJ(n.b,o,t.b,f)):(h=c,a=tJ(t.b,f,n.b,o))}return tZ(s=new to(h,a.length,a)),s}function iM(n){var t,e,r,i;if(rF(),null==n)throw new nc("null string");if((t=t5(n)).length<27||t.length>45)throw new nu(ox);for(r=0;rfe.length)throw new q;if(o=null,i=null,67==r[0]?(i=uX,o=u5):68==r[0]?(i=uY,o=u9):70==r[0]?(i=u1,o=u7):72==r[0]?e>6&&(68==r[5]?(i=u0,o=u8):69==r[5]?(i=u2,o=fn):85==r[5]&&(i=u4,o=ft)):85==r[0]&&(80==r[1]?(i=u6,o=fr):78==r[1]&&(i=u3,o=fe)),i&&e==o.length){for(t=1;tl||r+i>s)throw new G;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tT(n,11),o=tT(e,11),nj(n)===nj(e)&&tr;)rn(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eK(e+(o>u?o:u)),s=(i=o-u)>0?(il(),i>19!=0&&(t=eQ(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?es(b):0==h&&0!=l&&0==b?es(l)+22:0!=h&&0==l&&0==b?es(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rK(n,u),c&&eT(f),e&&(o8=ty(0,0,0)),f;n=nT((eM(),uo)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eQ(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rK(g,u),w&&eT(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eT(f),o&&(r?(o8=eQ(n),i&&(o8=e1(o8,(eM(),uf)))):o8=ty(n.l,n.m,n.h)),f}(r?n:ty(n.l,n.m,n.h),t,c,o,i,e):(e&&(o8=o?eQ(n):ty(n.l,n.m,n.h)),ty(0,0,0))}function iE(n){var t=[];for(var e in n){var r=typeof n[e];r!=oQ?t[t.length]=r:n[e]instanceof Array?t[t.length]=oM:u&&u.bigdecimal&&u.bigdecimal.BigInteger&&n[e]instanceof u.bigdecimal.BigInteger?t[t.length]=on:u&&u.bigdecimal&&u.bigdecimal.BigDecimal&&n[e]instanceof u.bigdecimal.BigDecimal?t[t.length]=i9:u&&u.bigdecimal&&u.bigdecimal.RoundingMode&&n[e]instanceof u.bigdecimal.RoundingMode?t[t.length]=ow:u&&u.bigdecimal&&u.bigdecimal.MathContext&&n[e]instanceof u.bigdecimal.MathContext?t[t.length]=ob:t[t.length]=oQ}return t.join(iq)}function iR(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,ty(b,l&=4194303,g&=1048575)}function iO(n,t,e){var r,i,o,u,f,c,s,a;if(a=ri(eY(e6(e.b),oW))+(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=um.length-1,s=tK(f9,{6:1},17,[(n.d||(n.d=eP(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iN(n,t);if(a>0&&(rn(s,0,et((n.d||(n.d=eP(n.g)),n.d),im(a))),c+=a),u=(s=r6(s[0],(t.d||(t.d=eP(t.g)),t.d)))[0],0!=s[1].r())r=rt(eH(s[1]),(t.d||(t.d=eP(t.g)),t.d)),u=iS(et(u,(rW(),uB)),eZ(e6(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r6(u,um[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?n_(n.b,t.b)+1<54?new ti(n.g-t.g,n.f):new tx(ia((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f):e>0?e0?t.e:nP((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rW(),r=uA;else if(0==o)r=ih((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d));else if(o>0)u=im(o),r=ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),u)),r=et(r,u);else{for(u=im(-o),r=ih(et((n.d||(n.d=eP(n.g)),n.d),u),(t.d||(t.d=eP(t.g)),t.d));!r.gb(0);)if(0==(f=r6(r,um[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nB(m=r2(eY(rU(ta(e6(w[h]),o6),32),ta(e6(w[h-1]),o6)),c)),v=nB(rK(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iR(ta(e6(s),o6),ta(e6(d[o-2]),o6)),y=eY(rU(e6(v),32),ta(e6(w[h-2]),o6)),32>r$(nB(rP(g=eY(ta(e6(v),o6),ta(e6(c),o6)),32)))?_=!0:v=nB(g)}while(rA(tb(l,oV),tb(y,oV)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oJ,u=oJ;f0)rn(b,0,ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),im(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,rn(b,0,et(b[0],im(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r6(et((n.d||(n.d=eP(n.g)),n.d),im(u)),(t.d||(t.d=eP(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nL(b[1]).q()+u-t.q())&&(rn(b,1,ih(et(b[1],im(u)),(t.d||(t.d=eP(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new ni(of);if(0==b[0].r())return eU(o);for(w=b[0],g=(c=new nL(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r6(w,um[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new ni(of);return c.f=eK(h),tO(c,w),c}function ij(){var n;for(n=0,ij=g,uJ=tK(fp,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uK=tU(f9,{6:1},17,(uW=tK(fp,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rN(n,oJ)?(e=nQ(n,o4),r=n6(n,o4)):(e=nQ(t=rP(n,1),o2),r=eY(rU(r=n6(t,o2),1),ta(n,oK))),th(rU(r,32),ta(e,o6))}(eY(rU(y,32),ta(e6(M[c]),o6))),M[c]=nB(w),y=e6(nB(rK(w,32)));d=nB(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tP(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tP(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tP(v,e,_-e)}return(S=e+1,m=new Z,h&&(m.b.b+=iJ),_-S>=1)?(tE(m,v[e]),m.b.b+=iK,I=m.b,E=tP(v,e+1,_-e-1),I.b+=E):(R=m.b,O=tP(v,e,_-e),R.b+=O),m.b.b+=oc,o>0&&(m.b.b+=iz),D=m.b,k=iV+o,D.b+=k,m.b.b}c&&c({moduleName:"gwtapp",sessionId:s,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iH,i$,iV="",iq=" ",iG='"',iz="+",iJ="-",iK=".",iW="0",iZ="0.",iX="0.0",iY="0.00",i1="0.000",i0="0.0000",i2="0.00000",i4="0.000000",i3="0E",i6="0E+",i5=":",i9="BigDecimal",i7="BigDecimal MathContext",i8="BigDecimal;",on="BigInteger",ot="BigInteger divide by zero",oe="BigInteger not invertible.",or="BigInteger: modulus not positive",oi="BigInteger;",oo="CSS1Compat",ou="Division by zero",of="Division impossible",oc="E",os='For input string: "',oa="Infinite or NaN",oh="Invalid Operation",ob="MathContext",ol="Negative bit address",og="Rounding necessary",ow="RoundingMode",od="RoundingMode;",op="String",o_="[Lcom.iriscouch.gwtapp.client.",ov="[Ljava.lang.",om="[Ljava.math.",oy="\\.",oC="__gwtex_wrap",oS="anonymous",oM="array",ox="bad string format",oB="bigdecimal",oA="com.google.gwt.core.client.",oN="com.google.gwt.core.client.impl.",oI="com.iriscouch.gwtapp.client.",oE="java.lang.",oR="java.math.",oO="java.util.",oD="msie",ok="null",oL="number",oU="number MathContext",oP="number number",oQ="object",oT="opera",oj="org.timepedia.exporter.client.",oF="safari",oH="string",o$="undefined",oV={l:0,m:0,h:524288},oq={l:0,m:4193280,h:1048575},oG={l:4194298,m:4194303,h:1048575},oz={l:4194303,m:4194303,h:1048575},oJ={l:0,m:0,h:0},oK={l:1,m:0,h:0},oW={l:2,m:0,h:0},oZ={l:5,m:0,h:0},oX={l:10,m:0,h:0},oY={l:11,m:0,h:0},o1={l:18,m:0,h:0},o0={l:48,m:0,h:0},o2={l:877824,m:119,h:0},o4={l:1755648,m:238,h:0},o3={l:4194303,m:511,h:0},o6={l:4194303,m:1023,h:0},o5={l:0,m:1024,h:0};(i$=a.prototype={}).eQ=function(n){return this===n},i$.gC=function(){return fs},i$.hC=function(){return nF(this)},i$.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tU(fK,{6:1},-1,8,1),rv(),e=7,n>=0)for(;n>15;)t[e--]=uO[15&n],n>>=4;else for(;e>0;)t[e--]=uO[15&n],n>>=4;return t[e]=uO[15&n],t3(t,e,8)}(this.hC())},i$.toString=function(){return this.tS()},i$.tM=g,i$.cM={},(i$=h.prototype=new a).gC=function(){return fh},i$.j=function(){return this.f},i$.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},i$.cM={6:1,15:1},i$.f=null,(i$=b.prototype=new h).gC=function(){return fb},i$.cM={6:1,15:1},(i$=nr.prototype=l.prototype=new b).gC=function(){return fl},i$.cM={6:1,12:1,15:1},(i$=n0.prototype=(function(){}).prototype=new l).gC=function(){return fg},i$.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?ok:tt(e)?null==(r=t7(e))?null:r.name:nz(e,1)?op:(nH(e)?e.gC():fw).d,this.b=tt(n=this.c)?null==(i=t7(n))?null:i.message:n+iV,this.d="("+this.e+"): "+this.b+(tt(t=this.c)?function(n){var t=iV;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t7(t)):iV)),this.d},i$.cM={6:1,12:1,15:1},i$.b=null,i$.c=null,i$.d=null,i$.e=null,(i$=w.prototype=new a).gC=function(){return fd};var o9=0,o7=0;(i$=d.prototype=(function(){}).prototype=new w).gC=function(){return fm},i$.b=null,i$.c=null,(i$=_.prototype=v.prototype=new a).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i5+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oS},i$.gC=function(){return fy},i$.o=function(n){return[]},(i$=m.prototype=new v).k=function(){return tg(this.o(td()),this.p())},i$.gC=function(){return fM},i$.o=function(n){return eO(this,n)},i$.p=function(){return 2},(i$=y.prototype=(function(){}).prototype=new m).k=function(){return ea(this)},i$.n=function(n){var t,e;return 0==n.length||(0==(e=e7(n)).indexOf("at ")&&(e=n8(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oS:(-1!=(t=(e=e7(e.substr(0,t-0))).indexOf("."))&&(e=n8(e,t+1)),e.length>0?e:oS)},i$.gC=function(){return fx},i$.o=function(n){return t4(this,n)},i$.p=function(){return 3},(i$=C.prototype=new a).gC=function(){return fB},(i$=S.prototype=(function(){}).prototype=new C).gC=function(){return fA},i$.b=iV,(i$=M.prototype=(function(){}).prototype=new a).gC=function(){return this.aC},i$.aC=null,i$.qI=0;var o8=null,un=null;(i$=x.prototype=(function(){}).prototype=new a).gC=function(){return fE},i$.cM={2:1},(i$=B.prototype=new a).gC=function(){return fO},i$.cM={6:1,10:1};var ut=null;(i$=eu.prototype=ti.prototype=tx.prototype=tN.prototype=X.prototype=e_.prototype=ef.prototype=tA.prototype=tB.prototype=eJ.prototype=n4.prototype=n3.prototype=tr.prototype=tM.prototype=nL.prototype=A.prototype=new B).eQ=function(n){return e2(this,n)},i$.gC=function(){return fD},i$.hC=function(){return rm(this)},i$.q=function(){return rj(this)},i$.r=function(){return ed(this)},i$.tS=function(){return ip(this)},i$.cM={6:1,8:1,10:1,16:1},i$.b=0,i$.c=0,i$.d=null,i$.e=0,i$.f=0,i$.g=0,i$.i=null;var ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_,uv=null,um=null,uy=null;(i$=nU.prototype=nw.prototype=(function(){}).prototype=new A).s=function(n){var t,e,r;if((e=iE(n))==iV)t=0>ed(this)?ep(this):this;else if(e==ob)t=0>(r=t8(this,new iM(n[0].toString()))).r()?ep(r):r;else throw new nr("Unknown call signature for interim = super.abs: "+e);return new nU(t)},i$.t=function(n){var t,e;if((e=iE(n))==i9)t=r0(this,new X(n[0].toString()));else if(e==i7)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t8(r0(n,t),e);if((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)0?t.e:nP((t.b-1)*.3010299956639812)+1)<-r-1))return t8(r0(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nP((i.b-1)*.3010299956639812)+1)?t8(r0(n,t),e):(f=(o=i.r())==u.r()?iS(rZ((i.d||(i.d=eP(i.g)),i.d),10),eZ(e6(o))):iS(rZ(f=ia((i.d||(i.d=eP(i.g)),i.d),eZ(e6(o))),10),eZ(e6(9*o))),t8(i=new tx(f,i.f+1),e))}(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.add: "+e);return new nU(t)},i$.u=function(){return~~(nB(en(this,8))<<24)>>24},i$.v=function(n){return ic(this,n)},i$.w=function(n){var t,e,r,i;if((i=iE(n))==i9)e=el(this,new X(n[0].toString()));else if(i==i7)e=eg(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tU(fL,{6:1},3,e.length,0);t129?n*=1/0:n=t9(ip(this)),n},i$.gC=function(){return fk},i$.hC=function(){return rm(this)},i$.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nP((this.b-1)*.3010299956639812)+1)?0:(n=new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))).f*n.b[0]},i$.C=function(){return nB(en(this,32))},i$.D=function(){return nB(en(this,32))},i$.E=function(){return t9(ip(this))},i$.F=function(n){return new nU(ic(this,n)>=0?this:n)},i$.G=function(n){return new nU(0>=ic(this,n)?this:n)},i$.H=function(n){return new nU(rJ(this,this.f+n))},i$.I=function(n){return new nU(rJ(this,this.f-n))},i$.J=function(n){var t,e;if((e=iE(n))==i9)t=rk(this,new X(n[0].toString()));else if(e==i7)t=tl(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.multiply: "+e);return new nU(t)},i$.K=function(n){var t,e;if((e=iE(n))==iV)t=ep(this);else if(e==ob)t=ep(t8(this,new iM(n[0].toString())));else throw new nr("Unknown call signature for interim = super.negate: "+e);return new nU(t)},i$.L=function(n){var t,e;if((e=iE(n))==iV)t=this;else if(e==ob)t=t8(this,new iM(n[0].toString()));else throw new nr("Unknown call signature for interim = super.plus: "+e);return new nU(t)},i$.M=function(n){var t,e;if((e=iE(n))==oL)t=rd(this,n[0]);else if(e==oU)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=eo(tn(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rd(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new ni(oh);for(u>0&&(f=new eW(u+i+1,e.c)),r=t8(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tl(r,r,f),(o&c)==c&&(r=tl(r,n,f)),c>>=1;return t<0&&(r=iO(uw,r,f)),is(r,e),r}(this,n[0],new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.pow: "+e);return new nU(t)},i$.q=function(){return rj(this)},i$.N=function(n){var t,e;if((e=iE(n))==i9)t=el(this,new X(n[0].toString()))[1];else if(e==i7)t=eg(this,new X(n[0].toString()),new iM(n[1].toString()))[1];else throw new nr("Unknown call signature for interim = super.remainder: "+e);return new nU(t)},i$.O=function(n){return new nU(t8(this,new iM(eh(n.b))))},i$.P=function(){return eo(this.f)},i$.Q=function(n){var t,e;return new nU((t=this,(e=t.f-n,t.b<54)?0==t.g?eU(e):new ti(t.g,eK(e)):new tM((t.d||(t.d=eP(t.g)),t.d),eK(e))))},i$.R=function(n){var t,e;if((e=iE(n))==oL)t=r1(this,n[0],(iA(),u3));else if(e==oP)t=r1(this,n[0],rQ(n[1]));else if("number RoundingMode"==e)t=r1(this,n[0],ts(n[1].toString()));else throw new nr("Unknown call signature for interim = super.setScale: "+e);return new nU(t)},i$.S=function(){return~~(nB(en(this,16))<<16)>>16},i$.r=function(){return ed(this)},i$.T=function(){return new nU(function(n){var t,e,r,i,o;if(t=1,e=um.length-1,r=n.f,0==n.b&&-1!=n.g)return new X(iW);for(n.d||(n.d=eP(n.g)),o=n.d;!o.gb(0);)if(0==(i=r6(o,um[t]))[1].r())r-=t,t0?i.e:nP((i.b-1)*.3010299956639812)+1)0?r.e:nP((r.b-1)*.3010299956639812)+1)?(f=(c=ed(r))!=i.r()?iS(rZ((r.d||(r.d=eP(r.g)),r.d),10),eZ(e6(c))):iS(rZ(f=ia((r.d||(r.d=eP(r.g)),r.d),eZ(e6(c))),10),eZ(e6(9*c))),t8(new tx(f,r.f+1),o)):t8(iD(r,i),o);else throw new nr("Unknown call signature for interim = super.subtract: "+e);return new nU(t)},i$.V=function(){return new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))},i$.W=function(){return new n2(r5(this))},i$.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nq(u),n.f>0&&i>=-6)i>=0?n7(c,r-eo(n.f),iK):(te(c.b,t-1,t-1,iZ),n7(c,t+1,tP(ua,0,-eo(i)-1)));else{if(e=r-t,0!=(f=eo(i%3))&&(0==(n.d||(n.d=eP(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n7(c,r++,iW);r-t>=1&&(te(c.b,t,t,iK),++r),0!=i&&(te(c.b,r,r,oc),i>0&&n7(c,++r,iz),n7(c,++r,iV+r3(r4(i))))}return c.b.b}(this)},i$.Y=function(){return function(n){var t,e,r,i,o,u;if(r=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ed(n)?1:0,e=n.f,i=new Z(r.length+1+((o=eo(n.f))<0?-o:o)),1==t&&(i.b.b+=iJ),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iZ;e>ua.length;e-=ua.length)tG(i,ua);n9(i,ua,eo(e)),nE(i,n8(r,t))}else nE(i,(u=eo(e=t-e),r.substr(t,u-t))),i.b.b+=iK,nE(i,n8(r,eo(e)))}else{for(nE(i,n8(r,t));e<-ua.length;e+=ua.length)tG(i,ua);n9(i,ua,eo(-e))}return i.b.b}(this)},i$.tS=function(){return ip(this)},i$.Z=function(){return new nU(new ti(1,this.f))},i$.$=function(){return new n2((this.d||(this.d=eP(this.g)),this.d))},i$.cM={3:1,6:1,8:1,10:1,16:1,24:1},(i$=H.prototype=(function(){}).prototype=new a).gC=function(){return fU};var uC=!1;(i$=ru.prototype=ro.prototype=to.prototype=e9.prototype=tV.prototype=rh.prototype=nG.prototype=iC.prototype=N.prototype=new B)._=function(){return this.f<0?new to(1,this.e,this.b):this},i$.ab=function(){return eq(this)},i$.eQ=function(n){return eV(this,n)},i$.gC=function(){return fP},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.cb=function(){return 0==this.f?this:new to(-this.f,this.e,this.b)},i$.db=function(n){return rL(this,n)},i$.eb=function(n){return tY(this,n)},i$.fb=function(n){return t1(this,n)},i$.r=function(){return this.f},i$.gb=function(n){return rT(this,n)},i$.tS=function(){return iF(this,0)},i$.cM={6:1,8:1,10:1,17:1},i$.b=null,i$.c=-2,i$.d=0,i$.e=0,i$.f=0;var uS,uM,ux,uB,uA,uN=null;(i$=n2.prototype=nD.prototype=nk.prototype=(function(){}).prototype=new N)._=function(){return new n2(this.f<0?new to(1,this.e,this.b):this)},i$.hb=function(n){return new n2(iS(this,n))},i$.ib=function(n){return new n2(0==n.f||0==this.f?(rW(),uA):eV(n,(rW(),uS))?this:eV(this,uS)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=np(n.e,t.e),(e=n_(ew(n),ew(t)))>=i)return rW(),uA;for(r=tU(fp,{6:1},-1,i,1);e0?rz(n,this):this.e>n.e?i_(this,n):i_(n,this))},i$.jb=function(n){return new n2(0==n.f?this:0==this.f?(rW(),uA):eV(this,(rW(),uS))?new n2(r8(n)):eV(n,uS)?uA:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tU(fp,{6:1},-1,n.e,1),r=np(n.e,t.e),e=ew(n);e=n.e)return n;for(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=ew(n),o=ew(t),i>=t.e)return n;if(c=n_(n.e,t.e),r=i,o>i){for(f=tU(fp,{6:1},-1,c,1),u=np(n.e,o);r=t.e)return rW(),uA;if(u=tU(fp,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},i$.qb=function(n){return new n2(rR(this,n))},i$.gC=function(){return fQ},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.B=function(){return this.f*this.b[0]},i$.rb=function(n){return function(n,t){var e,r;if(ij(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rT(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uW,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n2(this.f<0?new to(1,this.e,this.b):this),n)},i$.sb=function(){return t9(iF(this,0))},i$.tb=function(n){return new n2(1==rt(this,n)?this:n)},i$.ub=function(n){return new n2(-1==rt(this,n)?this:n)},i$.vb=function(n){return new n2(ee(this,n))},i$.wb=function(n){return new n2(rO(this,n))},i$.xb=function(n,t){return new n2(rG(this,n,t))},i$.yb=function(n){return new n2(et(this,n))},i$.cb=function(){return new n2(0==this.f?this:new to(-this.f,this.e,this.b))},i$.zb=function(){return new n2(function(n){if(n.f<0)throw new ni("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(ij(),o=tU(fp,{6:1},-1,uW.length,1),r=tU(fv,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uW[e];++e);return uK[e]}for(f=new to(1,n.e,tU(fp,{6:1},-1,n.e+1,1)),iB(n.b,0,f.b,0,n.e),rT(n,0)?tW(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iw(this,n):n.f>0?iw(n,this):ew(n)>ew(this)?rX(n,this):rX(this,n))},i$.db=function(n){return new n2(rL(this,n))},i$.Cb=function(n){return new n2(rH(this,n))},i$.Db=function(n){return new n2(rT(this,n)?this:ie(this,n))},i$.eb=function(n){return new n2(tY(this,n))},i$.fb=function(n){return new n2(t1(this,n))},i$.r=function(){return this.f},i$.Eb=function(n){return new n2(ia(this,n))},i$.gb=function(n){return rT(this,n)},i$.Fb=function(n){var t,e;if((e=iE(n))==iV)t=iF(this,0);else if(e==oL)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(ix(),g=n.f,s=n.e,u=n.b,0==g)return iW;if(1==s)return _=ta(e6(u[0]),o6),g<0&&(_=eQ(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return iV+r3(n);if(e=tU(fK,{6:1},-1,65,1),rv(),r=64,i=e6(t),rN(n,oJ)){for(;rN(n,i);)e[r--]=uO[nB(n6(n,i))],n=iI(n,i,!1);e[r]=uO[nB(n)]}else{for(;!rA(n,eQ(i));)e[r--]=uO[nB(eQ(n6(n,i)))],n=iI(n,i,!1);e[r--]=uO[nB(eQ(n))],e[r]=45}return t3(e,r,65)}(_,t);if(10==t||t<2||t>36)return iF(n,0);if(l=tU(fK,{6:1},-1,b=eo(eq(new n2(n.f<0?new to(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(iB(u,0,w=tU(fp,{6:1},-1,s,1),0,s),d=s,r=uP[t],e=uU[t-2];;){h=ii(w,w,d,e),a=i;do l[--i]=em(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=em(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tP(l,i,b-i)}(this,n[0]);else throw new nr("Unknown call signature for result = super.toString: "+e);return t},i$.Gb=function(n){return new n2(0==n.f?this:0==this.f?n:eV(n,(rW(),uS))?new n2(r8(this)):eV(this,uS)?new n2(r8(n)):this.f>0?n.f>0?this.e>n.e?rw(this,n):rw(n,this):iU(this,n):n.f>0?iU(n,this):ew(n)>ew(this)?io(n,this):io(this,n))},i$.cM={4:1,6:1,8:1,10:1,17:1,24:1},(i$=F.prototype=(function(){}).prototype=new a).gC=function(){return fj};var uI=!1;(i$=nm.prototype=ny.prototype=(function(){}).prototype=new a).gC=function(){return fF},i$.Hb=function(){return this.b.b},i$.Ib=function(){return new nn(this.b.c)},i$.hC=function(){return nx(this.b)},i$.tS=function(){return eh(this.b)},i$.cM={24:1},i$.b=null,(i$=j.prototype=(function(){}).prototype=new a).gC=function(){return fH};var uE=!1;(i$=nn.prototype=nC.prototype=(function(){}).prototype=new a).gC=function(){return f$},i$.Jb=function(){return this.b.b},i$.tS=function(){return this.b.b},i$.cM={5:1,24:1},i$.b=null,(i$=K.prototype=(function(){}).prototype=new a).gC=function(){return fq};var uR=!1;(i$=ni.prototype=(function(){}).prototype=new l).gC=function(){return fG},i$.cM={6:1,12:1,15:1},(i$=no.prototype=V.prototype=(function(){}).prototype=new l).gC=function(){return fJ},i$.cM={6:1,12:1,15:1},(i$=I.prototype=(function(){}).prototype=new a).gC=function(){return fW},i$.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?iV:"class ")+this.d},i$.b=null,i$.c=0,i$.d=null,(i$=$.prototype=(function(){}).prototype=new l).gC=function(){return fZ},i$.cM={6:1,12:1,15:1},(i$=E.prototype=new a).eQ=function(n){return this===n},i$.gC=function(){return fa},i$.hC=function(){return nF(this)},i$.tS=function(){return this.b},i$.cM={6:1,8:1,9:1},i$.b=null,i$.c=0,(i$=nu.prototype=q.prototype=R.prototype=new l).gC=function(){return fX},i$.cM={6:1,12:1,15:1},(i$=nf.prototype=G.prototype=O.prototype=new l).gC=function(){return fz},i$.cM={6:1,12:1,15:1},(i$=nc.prototype=z.prototype=(function(){}).prototype=new l).gC=function(){return fY},i$.cM={6:1,12:1,15:1},(i$=nd.prototype=(function(){}).prototype=new R).gC=function(){return f1},i$.cM={6:1,12:1,15:1},(i$=tu.prototype=(function(){}).prototype=new a).gC=function(){return fC},i$.tS=function(){return this.b+iK+this.d+"(Unknown Source"+(this.c>=0?i5+this.c:iV)+")"},i$.cM={6:1,13:1},i$.b=null,i$.c=0,i$.d=null,(i$=String.prototype).eQ=function(n){return tF(this,n)},i$.gC=function(){return fN},i$.hC=function(){var n,t;return nK(),null!=(t=uk[n=i5+this])?t:(null==(t=uD[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;et?n:t}function nv(n,t){return!rN(n,t)}function nm(n){this.b=new iM(n)}function ny(){this.b=(rF(),uF)}function nC(){this.b=(iA(),u4)}function nS(n,t){var e;nb(),e=o.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tw(n){return nz(n,15)?n:new n0(n)}function td(){try{null.a()}catch(n){return n}}function tp(n){var t;return(t=new I).d=iV+n,t.c=1,t}function t_(n,t){return nH(n)?n.eQ(t):n===t}function tv(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tm(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function ty(n,t,e){return(i$=new x).l=n,i$.m=t,i$.h=e,i$}function tC(n,t){return nj(n)===nj(t)||null!=n&&t_(n,t)}function tS(n,t){throw new nf("Index: "+n+", Size: "+t)}function tM(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tx(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tB(n,t,e,r){eJ.call(this,n,t,e),is(this,r)}function tA(n,t){eJ.call(this,n,0,n.length),is(this,t)}function tN(n,t){eJ.call(this,t5(n),0,n.length),is(this,t)}function tI(n){nr.call(this,"String index out of range: "+n)}function tE(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tR(n,t){rC(n.b,n.b,n.e,t.b,t.e),tZ(n),n.c=-2}function tO(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=ri(eN(t)))}function tD(){tD=g,ur=[],ui=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new M,ur,ui)}function tk(){uC||(uC=!0,new j,new F,function(){if(ng(oB,iV),u.bigdecimal.BigDecimal)var n=u.bigdecimal.BigDecimal;u.bigdecimal.BigDecimal=fc(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fk?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new nw,nl(this.__gwt_instance,this))});var t=u.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)u.bigdecimal.BigDecimal[p]=n[p];u.bigdecimal.BigDecimal.ROUND_CEILING=2,u.bigdecimal.BigDecimal.ROUND_DOWN=1,u.bigdecimal.BigDecimal.ROUND_FLOOR=3,u.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,u.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,u.bigdecimal.BigDecimal.ROUND_HALF_UP=4,u.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,u.bigdecimal.BigDecimal.ROUND_UP=0,u.bigdecimal.BigDecimal.__init__=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==on)t=new nL(new nG(n[0].toString()));else if("BigInteger number"==e)t=new tM(new nG(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new tr(new nG(n[0].toString()),n[1],new iM(n[2].toString()));else if("BigInteger MathContext"==e)t=new n3(new nG(n[0].toString()),new iM(n[1].toString()));else if(e==oM)t=new n4(t5(n[0].toString()));else if("array number number"==e)t=new eJ(t5(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tB(t5(n[0].toString()),n[1],n[2],new iM(n[3].toString()));else if("array MathContext"==e)t=new tA(t5(n[0].toString()),new iM(n[1].toString()));else if(e==oL)t=new ef(n[0]);else if(e==oU)t=new e_(n[0],new iM(n[1].toString()));else if(e==oH)t=new X(n[0].toString());else if("string MathContext"==e)t=new tN(n[0].toString(),new iM(n[1].toString()));else throw new nr("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nU(t)}(n);return nR(t)}),t.abs_va=fc(function(n){return nR(this.__gwt_instance.s(n))}),t.add_va=fc(function(n){return nR(this.__gwt_instance.t(n))}),t.byteValueExact=fc(function(){return this.__gwt_instance.u()}),t.compareTo=fc(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=fc(function(n){return nR(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=fc(function(n){return nR(this.__gwt_instance.x(n))}),t.doubleValue=fc(function(){return this.__gwt_instance.z()}),t.equals=fc(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=fc(function(){return this.__gwt_instance.A()}),t.hashCode=fc(function(){return this.__gwt_instance.hC()}),t.intValue=fc(function(){return this.__gwt_instance.B()}),t.intValueExact=fc(function(){return this.__gwt_instance.C()}),t.max=fc(function(n){return nR(this.__gwt_instance.F(n.__gwt_instance))}),t.min=fc(function(n){return nR(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=fc(function(n){return nR(this.__gwt_instance.H(n))}),t.movePointRight=fc(function(n){return nR(this.__gwt_instance.I(n))}),t.multiply_va=fc(function(n){return nR(this.__gwt_instance.J(n))}),t.negate_va=fc(function(n){return nR(this.__gwt_instance.K(n))}),t.plus_va=fc(function(n){return nR(this.__gwt_instance.L(n))}),t.pow_va=fc(function(n){return nR(this.__gwt_instance.M(n))}),t.precision=fc(function(){return this.__gwt_instance.q()}),t.remainder_va=fc(function(n){return nR(this.__gwt_instance.N(n))}),t.round=fc(function(n){return nR(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=fc(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=fc(function(n){return nR(this.__gwt_instance.Q(n))}),t.setScale_va=fc(function(n){return nR(this.__gwt_instance.R(n))}),t.shortValueExact=fc(function(){return this.__gwt_instance.S()}),t.signum=fc(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=fc(function(){return nR(this.__gwt_instance.T())}),t.subtract_va=fc(function(n){return nR(this.__gwt_instance.U(n))}),t.toBigInteger=fc(function(){return nR(this.__gwt_instance.V())}),t.toBigIntegerExact=fc(function(){return nR(this.__gwt_instance.W())}),t.toEngineeringString=fc(function(){return this.__gwt_instance.X()}),t.toPlainString=fc(function(){return this.__gwt_instance.Y()}),t.toString=fc(function(){return this.__gwt_instance.tS()}),t.ulp=fc(function(){return nR(this.__gwt_instance.Z())}),t.unscaledValue=fc(function(){return nR(this.__gwt_instance.$())}),t.divideAndRemainder_va=fc(function(n){return nO(this.__gwt_instance.w(n))}),t.longValue=fc(function(){return this.__gwt_instance.E()}),t.longValueExact=fc(function(){return this.__gwt_instance.D()}),u.bigdecimal.BigDecimal.valueOf_va=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==oL)t=function(n){if(!isFinite(n)||isNaN(n))throw new nd(oa);return new X(iV+n)}(n[0]);else if(e==oL)t=tX(e6(n[0]));else if(e==oP)t=eL(e6(n[0]),n[1]);else throw new nr("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nU(t)}(n);return nR(t)}),u.bigdecimal.BigDecimal.log=fc(function(n){iP(),typeof console!==o$&&console.log&&console.log(n)}),u.bigdecimal.BigDecimal.logObj=fc(function(n){iP(),typeof console!==o$&&console.log&&typeof JSON!==o$&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),u.bigdecimal.BigDecimal.ONE=fc(function(){var n=(iP(),new nU(uw));return nR(n)}),u.bigdecimal.BigDecimal.TEN=fc(function(){var n=(iP(),new nU(ud));return nR(n)}),u.bigdecimal.BigDecimal.ZERO=fc(function(){var n=(iP(),new nU(up));return nR(n)}),nS(fk,u.bigdecimal.BigDecimal)}())}function tL(n,t,e){var r;return(r=new I).d=n+t,r.c=4,r.b=e,r}function tU(n,t,e,r,i){var o;return tK(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tI(e)}(n.length,t,r),t3(n,t,r)}function tQ(n,t){return il(),t=n.c.c)throw new J;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tS(r,i),t.b[e]}function tF(n,t){return!!nz(t,1)&&String(n)==t}function tH(){nr.call(this,"Add not supported on this collection")}function t$(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function tV(n,t){rW(),this.f=n,this.e=1,this.b=tK(fp,{6:1},-1,[t])}function tq(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tG(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tz(n,t,e,r){var i,o;return null==t&&(t=ok),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tJ(n,t,e,r){var i;return rC(i=tU(fp,{6:1},-1,t,1),n,t,e,r),i}function tK(n,t,e,r){return tD(),function(n,t,e){tD();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tX(n){return rN(n,oJ)&&nv(n,oY)?us[nB(n)]:new eu(n,0)}function tY(n,t){return 0==t||0==n.f?n:t>0?e3(n,t):rY(n,-t)}function t1(n,t){return 0==t||0==n.f?n:t>0?rY(n,t):e3(n,-t)}function t0(n){var t;return 0==n.f?-1:((t=ew(n))<<5)+es(n.b[t])}function t2(n){var t;return 0!=(t=nB(n))?es(t):es(nB(rK(n,32)))+32}function t4(n,t){var e;return 0==(e=eO(n,t)).length?(new _).o(t):tg(e,1)}function t3(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t6(n,t,e,r){var i;return ib(i=tU(fp,{6:1},-1,t+1,1),n,t,e,r),i}function t5(n){var t,e;return t=tU(fK,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nB(y=iR(ta(e6(b.b[0]),o6),ta(e6(l.b[0]),o6))),0==(C=nB(rP(y,32)))?new tV(v,S):new to(v,2,tK(fp,{6:1},-1,[S,C]))):(eG(b.b,g,l.b,w,d=tU(fp,{6:1},-1,_,1)),tZ(m=new to(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=ia(t,a.eb(f)),o=ia(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iS(iS(u=n(ia(a,i),ia(o,h)),s),r)).eb(f),iS(iS(s=s.eb(f<<1),u),r))}(n,t))}function ee(n,t){var e;if(t.f<=0)throw new ni(or);return(e=rH(n,t)).f<0?iS(e,t):e}function er(n){var t;t=new nJ,n.d&&n5(t,new ne(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nA(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eP(n.g)),n.d).r()}function ep(n){return n.b<54?new ti(-n.g,n.f):new tx((n.d||(n.d=eP(n.g)),n.d).cb(),n.f)}function e_(n,t){if(!isFinite(n)||isNaN(n))throw new nd(oa);iQ(this,n.toPrecision(20)),is(this,t)}function ev(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function em(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function ey(n,t){var e,r;return t?((e=t[oC])||(e=new(r=t.gC(),t7(ei(n.b,r)))(t),t[oC]=e),e):null}function eC(n){var t,e;return 32==(e=r$(n.h))?32==(t=r$(n.m))?r$(n.l)+32:t+20-10:e-12}function eS(n){return ty(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eM(){eM=g,uo=ty(4194303,4194303,524287),uu=ty(0,0,524288),uf=e6(1),e6(2),uc=e6(0)}function ex(n,t){ib(n.b,n.b,n.e,t.b,t.e),n.e=np(n_(n.e,t.e)+1,n.b.length),tZ(n),n.c=-2}function eB(n,t){var e;e=~~t>>5,n.e+=e+(r$(n.b[n.e-1])-(31&t)>=0?0:1),rS(n.b,n.b,e,31&t),tZ(n),n.c=-2}function eA(n,t){var e,r;e=~~t>>5,n.e>>r:0,tZ(n))}function eN(n){var t;return t=n.e>1?th(rU(e6(n.b[1]),32),ta(e6(n.b[0]),o6)):ta(e6(n.b[0]),o6),iR(e6(n.f),t)}function eI(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:nv(ta(e6(n[r]),o6),ta(e6(t[r]),o6))?-1:1}function eE(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eR(n,t,e,r){if(iH=t,n)try{fc(iy)()}catch(i){n(t)}else fc(iy)()}function eO(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eu(oJ,2147483647):new eu(oJ,-2147483648)}function eP(n){return(rW(),n<0)?-1!=n?new ru(-1,-n):uS:n<=10?ux[eo(n)]:new ru(1,n)}function eQ(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,ty(t,e,r)}function eT(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function ej(n){var t,e,r;for(r=0,e=tU(fS,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rA(ta(e6(n[r]),o6),ta(e6(i[r]),o6));break}}return u=new to(1,o+1,n),e&&tR(u,t),tZ(u),u}(o,e)}function eV(n,t){var e;return n===t||!!nz(t,17)&&(e=tT(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eq(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&ew(n)==n.e-1&&(e=~~(e-1)),t-=r$(e))}function eG(n,t,e,r,i){il(),0!=t&&0!=r&&(1==t?i[r]=rc(i,e,r,n[0]):1==r?i[t]=rc(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nj(n)===nj(t)&&r==i){iu(n,r,e);return}for(f=0;f2147483647))return eo(n);throw new ni("Underflow")}function eW(n,t){if(rF(),n<0)throw new nu("Digits < 0");if(!t)throw new nc("null RoundingMode");this.b=n,this.c=t}function eZ(n){return(rW(),nv(n,oJ))?tm(n,oz)?new ro(-1,eQ(n)):uS:rA(n,oX)?new ro(1,n):ux[nB(n)]}function eX(n){var t;return nv(n,oJ)&&(n=ty(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nB(rK(n,32)))?r$(t):r$(nB(n))+32)}function eY(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e0(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-n_(e,n.bb())}function e2(n,t){var e;return n===t||!!nz(t,16)&&(e=tT(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e4(n,t,e){var r,i,o;for(o=oJ,r=t-1;r>=0;--r)i=r2(eY(rU(o,32),ta(e6(n[r]),o6)),e),o=e6(nB(rK(i,32)));return nB(o)}function e3(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rS(r=tU(fp,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tZ(o=new to(n.f,i,r)),o}function e6(n){var t,e;return n>-129&&n<128?(t=n+128,null==un&&(un=tU(fR,{6:1},2,256,0)),(e=un[t])||(e=un[t]=eS(n)),e):eS(n)}function e5(n){var t,e,r;return(rW(),n>5,t=31&n,(r=tU(fp,{6:1},-1,e+1,1))[e]=1<iq&&n[n.length-1]>iq?n:n.replace(/^(\s*)/,iV).replace(/\s*$/,iV)}function e8(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function rn(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==g||n$(e,1)))throw new V}return n[t]=e}function rt(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=e$(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=e$(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tU(f9,{6:1},17,8,0),a=n,rn(s,0,t),h=e$(t,t,r,i),u=1;u<=7;++u)rn(s,u,e$(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=e$(a,a,r,i);return a}(f,r,t,e,o),e$(u,(rW(),uM),e,o)}function ra(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nd("Radix out of range");if(0==n.length)throw new nd("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(ix(),uP)[e])),0!=(d=l%u)&&++o,c=tU(fp,{6:1},-1,o,1),r=uU[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:nv(ta(e6(n[i]),o6),ta(e6(t[i]),o6))?-1:1}function rg(n,t){var e,r,i;for(r=tU(fp,{6:1},-1,i=n.e,1),np(ew(n),ew(t)),e=0;e999999999)throw new ni(oh);return e=n.f*t,0==n.b&&-1!=n.g?eU(e):new tM((n.d||(n.d=eP(n.g)),n.d).db(t),eK(e))}function rp(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fu[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fo[n]=t,t*=.5}function rv(){rv=g,uO=tK(fK,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rm(n){var t;return 0!=n.c?n.c:n.b<54?(t=r4(n.g),n.c=nB(ta(t,oz)),n.c=33*n.c+nB(ta(rK(t,32),oz)),n.c=17*n.c+eo(n.f),n.c):(n.c=17*n.d.hC()+eo(n.f),n.c)}function ry(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=ev(n*t,0),0!=u&&(i=ev((u<=0?0-u:u)*2,t<=0?0-t:t),o+=it(1&eo(o),f*(5+i),r)),new ti(o,e)}function rC(n,t,e,r,i){var o,u;for(u=0,o=oJ;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rD(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=eo(nP(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eX(r4(n))}function rR(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eZ(rI(eN(e),eN(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rB(n,e),rB(t,r),1==rt(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eZ(rI(eN(n),eN(t)));break}if(t.e>1.2*n.e)0!=(t=rH(t,n)).r()&&rB(t,t.bb());else do tR(t,n),rB(t,t.bb());while(rt(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?eB(f,i):(rB(c,r-e0&&eB(f,i-r+e)),e+=i),0!=(i=e0(h,u))&&(eB(h,i),r>=e?eB(c,i):(rB(f,e-r0&&eB(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rq(s,h),rq(f,c)):(rq(h,s),rq(c,f)):e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)),0==h.r()||0==s.r())throw new ni(oe);return eD(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():ia(t,f)),0>f.r()&&(f=iS(f,t)),f}(n,t);for(o=32*t.e,h=eb(t),u=n_((b=eb(n)).e,h.e),c=new to(1,1,tU(fp,{6:1},-1,u+1,1)),(s=new to(1,1,tU(fp,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rB(h,r),rB(b,i),eB(c,i),e+=r-i):(rB(h,r),rB(b,i),eB(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rt(h,b)>0;)tR(h,b),a=h.bb(),rB(h,a),ex(c,s),eB(s,a),e+=a;for(;0>=rt(h,b)&&(tR(b,h),0!=b.r());)a=b.bb(),rB(b,a),ex(s,c),eB(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new ni(oe);return rt(c,t)>=0&&tR(c,t),c=ia(t,c),f=rf(t),e>o&&(c=e$(c,(rW(),uM),t,f),e-=o),c=e$(c,e5(o-e),t,f)}(ee(n._(),t),t)).f)throw new ni(oe);return n.f<0?ia(t,e):e}function rD(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rk(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eU(e):n.b+t.b<54?new ti(n.g*t.g,eK(e)):new tM(et((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),eK(e))}function rL(n,t){var e;if(t<0)throw new ni("Negative exponent");if(0==t)return uM;if(1==t||n.eQ(uM)||n.eQ(uA))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return et(e5(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(il(),rW(),r=uM,e=n;t>1;t>>=1)(1&t)!=0&&(r=et(r,e)),e=1==e.e?et(e,e):new e9(iu(e.b,e.e,tU(fp,{6:1},-1,e.e<<1,1)));return et(r,e)}(n,t)}function rU(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),ty(4194303&r,4194303&i,1048575&o)}function rQ(n){switch(iA(),n){case 2:return uX;case 1:return uY;case 3:return u1;case 5:return u0;case 6:return u2;case 4:return u4;case 7:return u3;case 0:return u6;default:throw new nu("Invalid rounding mode")}}function rT(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new ni(ol);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=ew(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rj(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ih((n.d||(n.d=eP(n.g)),n.d),im(t)).r()&&++t),n.e=eo(t)),n.e}function rF(){rF=g,uQ=new eW(34,(iA(),u2)),uT=new eW(7,u2),uj=new eW(16,u2),uF=new eW(0,u4),uH=tK(fK,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),u$=tK(fK,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rH(n,t){var e,r,i,o;if(0==t.f)throw new ni(ot);return((o=n.e)!=(e=t.e)?o>e?1:-1:eI(n.b,t.b,o))==-1?n:(r=tU(fp,{6:1},-1,e,1),1==e?r[0]=e4(n.b,o,t.b[0]):r=iL(null,o-e+1,n.b,o,t.b,e),tZ(i=new to(n.f,e,r)),i)}function r$(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16)+(t=~~(r=(n=~~n>>t)-256)>>16&8),n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function rV(n,t){if(0==n.f)iB(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ib(n.b,n.b,n.e,t.b,t.e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rq(n,t){var e;e=rt(n,t),0==n.f?(iB(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ib(n.b,n.b,n.e,t.b,t.e),n.f=e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rG(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new ni(or);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uA:0==r.f&&0==t.f?uM:(t.f<0&&(r=rO(n,e),t=t.cb()),i=e.gb(0)?rs(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rs(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rW(),u=uM,i=eb(t),r=eb(n),n.gb(0)&&eA(i,e-1),eA(r,e),o=i.ab()-1;o>=0;--o)eA(f=eb(u),e),u=et(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eA(u=et(u,r),e);return eA(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e9(tU(fp,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eA(b=et(ia(h,a),s),f),b.f<0&&(b=iS(b,e5(f))),iS(a,et(c,b))),r.f<0&&t.gb(0)&&(i=ee(et(ia(e,uM),i),e)),i)}function rz(n,t){var e,r,i,o,u,f,c;if(i=ew(n),(r=ew(t))>=n.e)return rW(),uA;for(u=tU(fp,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=np(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new ti(n.g,eK(t)):new tM((n.d||(n.d=eP(n.g)),n.d),eK(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),ty(4194303&i,4194303&o,1048575&u)}function rW(){var n;for(n=0,rW=g,uM=new tV(1,1),uB=new tV(1,10),uA=new tV(0,0),uS=new tV(-1,1),ux=tK(f9,{6:1},17,[uA,uM,new tV(1,2),new tV(1,3),new tV(1,4),new tV(1,5),new tV(1,6),new tV(1,7),new tV(1,8),new tV(1,9),uB]),uN=tU(f9,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rW(),uS):(rW(),uA);if(rD(i=tU(fp,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rM(n,t,e):rM(t,n,-e):n_(n.b,t.b)+1<54?new ti(n.g+t.g,n.f):new tx(iS((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f)}function r2(n,t){var e,r,i,o,u;return(r=ta(e6(t),o6),rN(n,oJ))?(o=iI(n,r,!1),u=n6(n,r)):(o=iI(e=rP(n,1),i=e6(~~t>>>1),!1),u=eY(rU(u=n6(e,i),1),ta(n,oK)),(1&t)!=0&&(rA(o,u)?rA(e1(o,u),r)?(u=eY(u,e1(rU(r,1),o)),o=e1(o,oW)):(u=eY(u,e1(r,o)),o=e1(o,oK)):u=e1(u,o))),th(rU(u,32),ta(o,o6))}function r4(n){var t,e,r,i;return isNaN(n)?(eM(),uc):n<-0x8000000000000000?(eM(),uu):n>=0x7fffffffffffffff?(eM(),uo):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=eo(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=eo(n/4194304),n-=4194304*t),i=ty(eo(n),t,e),r&&eT(i),i)}function r3(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iW;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iJ+r3(eQ(n));for(e=n,r=iV;!(0==e.l&&0==e.m&&0==e.h);){if(e=iI(e,e6(1e9),!0),t=iV+nB(o8),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iW+t;r=t+r}return r}function r6(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new ni(ot);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iI(g=ta(e6(S[0]),o6),w=ta(e6(l),o6),!1),v=n6(g,w),x!=i&&(d=eQ(d)),x<0&&(v=eQ(v)),tK(f9,{6:1},17,[eZ(d),eZ(v)])):(_=tU(fp,{6:1},-1,M,1),m=tK(fp,{6:1},-1,[ii(_,S,M,l)]),y=new to(x==i?1:-1,M,_),C=new to(x,1,m),tZ(y),tZ(C),tK(f9,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eI(a,e,h))<0)?tK(f9,{6:1},17,[uA,n]):(b=n.f,f=iL(o=tU(fp,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new to(b==i?1:-1,u,o),s=new to(b,r,f),tZ(c),tZ(s),tK(f9,{6:1},17,[c,s]))}function r5(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eP(n.g)),n.d;if(n.f<0)return et((n.d||(n.d=eP(n.g)),n.d),im(-n.f));if(n.f>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eP(n.g)),n.d).bb()||0!=(t=r6((n.d||(n.d=eP(n.g)),n.d),im(n.f)))[1].r())throw new ni(og);return t[0]}function r9(n,t,e,r,i){var o,u;if(o=oJ,e36)throw new nd("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nd(os+n+iG);return i}function r8(n){var t,e;if(0==n.f)return rW(),uS;if(eV(n,(rW(),uS)))return uA;if(e=tU(fp,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function ie(n,t){var e,r,i,o,u,f,c,s,a;if(s=0==n.f?1:n.f,u=~~t>>5,e=31&t,f=tU(fp,{6:1},-1,c=n_(u+1,n.e)+1,1),r=1<=n.e)f[u]=r;else if(u>(i=ew(n)))f[u]^=r;else if(u=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rG(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rN(a=th(rU(s,32),ta(e6(t[f]),o6)),oJ)?(c=iI(a,o,!1),s=n6(a,o)):(c=iI(i=rP(a,1),u=e6(~~r>>>1),!1),s=eY(rU(s=n6(i,u),1),ta(a,oK)),(1&r)!=0&&(rA(c,s)?rA(e1(c,s),o)?(s=eY(s,e1(rU(o,1),c)),c=e1(c,oW)):(s=eY(s,e1(o,c)),c=e1(c,oK)):s=e1(s,c))),n[f]=nB(ta(c,o6));return nB(s)}function io(n,t){var e,r,i,o,u,f,c;if(u=tU(fp,{6:1},-1,f=n_(n.e,t.e),1),i=ew(n),e=r=ew(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=np(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=et(u,im(r))),rt(o,u))}function is(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r4(ul[r]),b=e1(r4(c.f),e6(r)),h=iI(g=r4(c.g),l,!1),tm(a=n6(g,l),oJ)&&(s=tv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?0:nv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?-1:1,h=eY(h,e6(it(1&nB(h),(tv(a,oJ)?0:nv(a,oJ)?-1:1)*(5+s),t.c))),tn(ri(nv(h,oJ)?eQ(h):h))>=t.b&&(h=nQ(h,oX),b=e1(b,oK))),c.f=eK(ri(b)),c.e=t.b,c.g=ri(h),c.b=eX(h),c.d=null;return}f=im(r),i=r6((n.d||(n.d=eP(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rt(eH(i[1]._()),f),0!=(e=it(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&rn(i,0,iS(i[0],eZ(e6(e)))),new nL(i[0]).q()>o&&(rn(i,0,ih(i[0],(rW(),uB))),--u)),n.f=eK(u),n.e=o,tO(n,i[0])}}function ia(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u<0&&(e=eQ(e)),c<0&&(r=eQ(r)),eZ(e1(e,r));if(-1==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))h=-c,a=u==c?tJ(t.b,f,n.b,o):t6(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rW(),uA;a=tJ(n.b,o,t.b,f)}else a=t6(n.b,o,t.b,f);return tZ(s=new to(h,a.length,a)),s}function ih(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new ni(ot);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nQ(ta(e6(n.b[0]),o6),ta(e6(t.b[0]),o6)),s!=i&&(a=eQ(a)),eZ(a)):0==(e=c!=r?c>r?1:-1:eI(n.b,t.b,c))?s==i?uM:uS:-1==e?uA:(o=tU(fp,{6:1},-1,u=c-r+1,1),1==r?ii(o,n.b,c,t.b[0]):iL(o,u,n.b,c,t.b,r),tZ(f=new to(s==i?1:-1,u,o)),f)}function ib(n,t,e,r,i){var o,u;if(o=eY(ta(e6(t[0]),o6),ta(e6(r[0]),o6)),n[0]=nB(o),o=rK(o,32),e>=i){for(u=1;u0){if(i0?u=tQ(u,eo(i)):i<0&&(o=tQ(o,eo(-i))),id(o,u,e,r)}function iw(n,t){var e,r,i,o,u,f,c;if(r=ew(t),(i=ew(n))>=t.e)return t;if(u=tU(fp,{6:1},-1,f=t.e,1),rt.ab()?(c=eN(s),o=eN(t),i=tv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?0:nv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?-1:1,i=it(f.gb(0)?1:0,a*(5+i),r)):(i=rt(eH(s._()),t._()),i=it(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return eL(eY(eN(f),e6(i)),e);f=iS(f,eZ(e6(i)))}return new tM(f,e)}function ip(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;if(ix(),(u=nv(n,oJ))&&(n=eQ(n)),tv(n,oJ))switch(t){case 0:return iW;case 1:return iX;case 2:return iY;case 3:return i1;case 4:return i0;case 5:return i2;case 6:return i4;default:return s=new W,t<0?s.b.b+=i6:s.b.b+=i3,b=s.b,l=-2147483648==t?"2147483648":iV+-t,b.b+=l,s.b.b}c=tU(fK,{6:1},-1,19,1),e=18,h=n;do f=h,h=nQ(h,oX),c[--e]=65535&nB(eY(o0,e1(f,iR(h,oX))));while(tm(h,oJ))if(r=e1(e1(e1(o1,e6(e)),e6(t)),oK),0==t)return u&&(c[--e]=45),tP(c,e,18-e);if(t>0&&rN(r,oG)){if(rN(r,oJ)){for(o=17,i=e+nB(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tP(c,e,18-e+1)}for(o=2;nv(e6(o),eY(eQ(r),oK));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tP(c,e,18-e)}return(a=e+1,s=new Z,u&&(s.b.b+=iJ),18-a>=1)?(tE(s,c[e]),s.b.b+=iK,g=s.b,w=tP(c,e+1,18-e-1),g.b+=w):(d=s.b,_=tP(c,e,18-e),d.b+=_),s.b.b+=oc,rA(r,oJ)&&(s.b.b+=iz),v=s.b,m=iV+r3(r),v.b+=m,s.b.b}(r4(n.g),eo(n.f)),n.i):(i=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new W).b,u.b+=i,n.f>0&&r>=-6?r>=0?n7(o,e-eo(n.f),iK):(te(o.b,t-1,t-1,iZ),n7(o,t+1,tP(ua,0,-eo(r)-1))):(e-t>=1&&(te(o.b,t,t,iK),++e),te(o.b,e,e,oc),r>0&&n7(o,++e,iz),n7(o,++e,iV+r3(r4(r)))),n.i=o.b.b,n.i)}function i_(n,t){var e,r,i,o,u,f;if(i=ew(n),o=ew(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==iV;)--s;s1e6)throw new ni("power of ten too big");if(n<=2147483647)return uV[1].db(t).eb(t);for(i=r=uV[1].db(2147483647),e=r4(n-2147483647),t=eo(n%2147483647);rA(e,o3);)i=et(i,r),e=e1(e,o3);for(i=(i=et(i,uV[1].db(t))).eb(2147483647),e=r4(n-2147483647);rA(e,o3);)i=i.eb(2147483647),e=e1(e,o3);return i.eb(t)}function iy(){var n,t;c&&rx("com.iriscouch.gwtapp.client.BigDecimalApp"),nZ(new K),nY(new j),nX(new F),tk(new H),c&&rx("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oT)?oT:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=o$)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oF:-1!=t.indexOf(oD)&&f.documentMode>=9?"ie9":-1!=t.indexOf(oD)&&f.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tF(oF,n)||u.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),c&&rx("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=f.compatMode,n=tK(fI,{6:1},1,[oo]);e>5,this.b=tU(fp,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tZ(this)}}function iS(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u==c)?(l=nB(s=eY(e,r)),0==(b=nB(rP(s,32)))?new tV(u,l):new to(u,2,tK(fp,{6:1},-1,[l,b]))):eZ(u<0?e1(r,e):e1(e,r));if(u==c)h=u,a=o>=f?t6(n.b,o,t.b,f):t6(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))return rW(),uA;1==i?(h=u,a=tJ(n.b,o,t.b,f)):(h=c,a=tJ(t.b,f,n.b,o))}return tZ(s=new to(h,a.length,a)),s}function iM(n){var t,e,r,i;if(rF(),null==n)throw new nc("null string");if((t=t5(n)).length<27||t.length>45)throw new nu(ox);for(r=0;rfe.length)throw new q;if(o=null,i=null,67==r[0]?(i=uX,o=u5):68==r[0]?(i=uY,o=u9):70==r[0]?(i=u1,o=u7):72==r[0]?e>6&&(68==r[5]?(i=u0,o=u8):69==r[5]?(i=u2,o=fn):85==r[5]&&(i=u4,o=ft)):85==r[0]&&(80==r[1]?(i=u6,o=fr):78==r[1]&&(i=u3,o=fe)),i&&e==o.length){for(t=1;tl||r+i>s)throw new G;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tT(n,11),o=tT(e,11),nj(n)===nj(e)&&tr;)rn(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eK(e+(o>u?o:u)),s=(i=o-u)>0?(il(),i>19!=0&&(t=eQ(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?es(b):0==h&&0!=l&&0==b?es(l)+22:0!=h&&0==l&&0==b?es(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rK(n,u),c&&eT(f),e&&(o8=ty(0,0,0)),f;n=nT((eM(),uo)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eQ(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rK(g,u),w&&eT(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eT(f),o&&(r?(o8=eQ(n),i&&(o8=e1(o8,(eM(),uf)))):o8=ty(n.l,n.m,n.h)),f}(r?n:ty(n.l,n.m,n.h),t,c,o,i,e):(e&&(o8=o?eQ(n):ty(n.l,n.m,n.h)),ty(0,0,0))}function iE(n){var t=[];for(var e in n){var r=typeof n[e];r!=oQ?t[t.length]=r:n[e]instanceof Array?t[t.length]=oM:u&&u.bigdecimal&&u.bigdecimal.BigInteger&&n[e]instanceof u.bigdecimal.BigInteger?t[t.length]=on:u&&u.bigdecimal&&u.bigdecimal.BigDecimal&&n[e]instanceof u.bigdecimal.BigDecimal?t[t.length]=i9:u&&u.bigdecimal&&u.bigdecimal.RoundingMode&&n[e]instanceof u.bigdecimal.RoundingMode?t[t.length]=ow:u&&u.bigdecimal&&u.bigdecimal.MathContext&&n[e]instanceof u.bigdecimal.MathContext?t[t.length]=ob:t[t.length]=oQ}return t.join(iq)}function iR(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,ty(b,l&=4194303,g&=1048575)}function iO(n,t,e){var r,i,o,u,f,c,s,a;if(a=ri(eY(e6(e.b),oW))+(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=um.length-1,s=tK(f9,{6:1},17,[(n.d||(n.d=eP(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iN(n,t);if(a>0&&(rn(s,0,et((n.d||(n.d=eP(n.g)),n.d),im(a))),c+=a),u=(s=r6(s[0],(t.d||(t.d=eP(t.g)),t.d)))[0],0!=s[1].r())r=rt(eH(s[1]),(t.d||(t.d=eP(t.g)),t.d)),u=iS(et(u,(rW(),uB)),eZ(e6(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r6(u,um[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?n_(n.b,t.b)+1<54?new ti(n.g-t.g,n.f):new tx(ia((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f):e>0?e0?t.e:nP((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rW(),r=uA;else if(0==o)r=ih((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d));else if(o>0)u=im(o),r=ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),u)),r=et(r,u);else{for(u=im(-o),r=ih(et((n.d||(n.d=eP(n.g)),n.d),u),(t.d||(t.d=eP(t.g)),t.d));!r.gb(0);)if(0==(f=r6(r,um[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nB(m=r2(eY(rU(ta(e6(w[h]),o6),32),ta(e6(w[h-1]),o6)),c)),v=nB(rK(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iR(ta(e6(s),o6),ta(e6(d[o-2]),o6)),y=eY(rU(e6(v),32),ta(e6(w[h-2]),o6)),32>r$(nB(rP(g=eY(ta(e6(v),o6),ta(e6(c),o6)),32)))?_=!0:v=nB(g)}while(rA(tb(l,oV),tb(y,oV)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oJ,u=oJ;f0)rn(b,0,ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),im(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,rn(b,0,et(b[0],im(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r6(et((n.d||(n.d=eP(n.g)),n.d),im(u)),(t.d||(t.d=eP(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nL(b[1]).q()+u-t.q())&&(rn(b,1,ih(et(b[1],im(u)),(t.d||(t.d=eP(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new ni(of);if(0==b[0].r())return eU(o);for(w=b[0],g=(c=new nL(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r6(w,um[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new ni(of);return c.f=eK(h),tO(c,w),c}function ij(){var n;for(n=0,ij=g,uJ=tK(fp,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uK=tU(f9,{6:1},17,(uW=tK(fp,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rN(n,oJ)?(e=nQ(n,o4),r=n6(n,o4)):(e=nQ(t=rP(n,1),o2),r=eY(rU(r=n6(t,o2),1),ta(n,oK))),th(rU(r,32),ta(e,o6))}(eY(rU(y,32),ta(e6(M[c]),o6))),M[c]=nB(w),y=e6(nB(rK(w,32)));d=nB(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tP(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tP(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tP(v,e,_-e)}return(S=e+1,m=new Z,h&&(m.b.b+=iJ),_-S>=1)?(tE(m,v[e]),m.b.b+=iK,I=m.b,E=tP(v,e+1,_-e-1),I.b+=E):(R=m.b,O=tP(v,e,_-e),R.b+=O),m.b.b+=oc,o>0&&(m.b.b+=iz),D=m.b,k=iV+o,D.b+=k,m.b.b}c&&c({moduleName:"gwtapp",sessionId:s,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iH,i$,iV="",iq=" ",iG='"',iz="+",iJ="-",iK=".",iW="0",iZ="0.",iX="0.0",iY="0.00",i1="0.000",i0="0.0000",i2="0.00000",i4="0.000000",i3="0E",i6="0E+",i5=":",i9="BigDecimal",i7="BigDecimal MathContext",i8="BigDecimal;",on="BigInteger",ot="BigInteger divide by zero",oe="BigInteger not invertible.",or="BigInteger: modulus not positive",oi="BigInteger;",oo="CSS1Compat",ou="Division by zero",of="Division impossible",oc="E",os='For input string: "',oa="Infinite or NaN",oh="Invalid Operation",ob="MathContext",ol="Negative bit address",og="Rounding necessary",ow="RoundingMode",od="RoundingMode;",op="String",o_="[Lcom.iriscouch.gwtapp.client.",ov="[Ljava.lang.",om="[Ljava.math.",oy="\\.",oC="__gwtex_wrap",oS="anonymous",oM="array",ox="bad string format",oB="bigdecimal",oA="com.google.gwt.core.client.",oN="com.google.gwt.core.client.impl.",oI="com.iriscouch.gwtapp.client.",oE="java.lang.",oR="java.math.",oO="java.util.",oD="msie",ok="null",oL="number",oU="number MathContext",oP="number number",oQ="object",oT="opera",oj="org.timepedia.exporter.client.",oF="safari",oH="string",o$="undefined",oV={l:0,m:0,h:524288},oq={l:0,m:4193280,h:1048575},oG={l:4194298,m:4194303,h:1048575},oz={l:4194303,m:4194303,h:1048575},oJ={l:0,m:0,h:0},oK={l:1,m:0,h:0},oW={l:2,m:0,h:0},oZ={l:5,m:0,h:0},oX={l:10,m:0,h:0},oY={l:11,m:0,h:0},o1={l:18,m:0,h:0},o0={l:48,m:0,h:0},o2={l:877824,m:119,h:0},o4={l:1755648,m:238,h:0},o3={l:4194303,m:511,h:0},o6={l:4194303,m:1023,h:0},o5={l:0,m:1024,h:0};(i$=a.prototype={}).eQ=function(n){return this===n},i$.gC=function(){return fs},i$.hC=function(){return nF(this)},i$.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tU(fK,{6:1},-1,8,1),rv(),e=7,n>=0)for(;n>15;)t[e--]=uO[15&n],n>>=4;else for(;e>0;)t[e--]=uO[15&n],n>>=4;return t[e]=uO[15&n],t3(t,e,8)}(this.hC())},i$.toString=function(){return this.tS()},i$.tM=g,i$.cM={},(i$=h.prototype=new a).gC=function(){return fh},i$.j=function(){return this.f},i$.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},i$.cM={6:1,15:1},i$.f=null,(i$=b.prototype=new h).gC=function(){return fb},i$.cM={6:1,15:1},(i$=nr.prototype=l.prototype=new b).gC=function(){return fl},i$.cM={6:1,12:1,15:1},(i$=n0.prototype=(function(){}).prototype=new l).gC=function(){return fg},i$.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?ok:tt(e)?null==(r=t7(e))?null:r.name:nz(e,1)?op:(nH(e)?e.gC():fw).d,this.b=tt(n=this.c)?null==(i=t7(n))?null:i.message:n+iV,this.d="("+this.e+"): "+this.b+(tt(t=this.c)?function(n){var t=iV;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t7(t)):iV)),this.d},i$.cM={6:1,12:1,15:1},i$.b=null,i$.c=null,i$.d=null,i$.e=null,(i$=w.prototype=new a).gC=function(){return fd};var o9=0,o7=0;(i$=d.prototype=(function(){}).prototype=new w).gC=function(){return fm},i$.b=null,i$.c=null,(i$=_.prototype=v.prototype=new a).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i5+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oS},i$.gC=function(){return fy},i$.o=function(n){return[]},(i$=m.prototype=new v).k=function(){return tg(this.o(td()),this.p())},i$.gC=function(){return fM},i$.o=function(n){return eO(this,n)},i$.p=function(){return 2},(i$=y.prototype=(function(){}).prototype=new m).k=function(){return ea(this)},i$.n=function(n){var t,e;return 0==n.length||(0==(e=e7(n)).indexOf("at ")&&(e=n8(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oS:(-1!=(t=(e=e7(e.substr(0,t-0))).indexOf("."))&&(e=n8(e,t+1)),e.length>0?e:oS)},i$.gC=function(){return fx},i$.o=function(n){return t4(this,n)},i$.p=function(){return 3},(i$=C.prototype=new a).gC=function(){return fB},(i$=S.prototype=(function(){}).prototype=new C).gC=function(){return fA},i$.b=iV,(i$=M.prototype=(function(){}).prototype=new a).gC=function(){return this.aC},i$.aC=null,i$.qI=0;var o8=null,un=null;(i$=x.prototype=(function(){}).prototype=new a).gC=function(){return fE},i$.cM={2:1},(i$=B.prototype=new a).gC=function(){return fO},i$.cM={6:1,10:1};var ut=null;(i$=eu.prototype=ti.prototype=tx.prototype=tN.prototype=X.prototype=e_.prototype=ef.prototype=tA.prototype=tB.prototype=eJ.prototype=n4.prototype=n3.prototype=tr.prototype=tM.prototype=nL.prototype=A.prototype=new B).eQ=function(n){return e2(this,n)},i$.gC=function(){return fD},i$.hC=function(){return rm(this)},i$.q=function(){return rj(this)},i$.r=function(){return ed(this)},i$.tS=function(){return ip(this)},i$.cM={6:1,8:1,10:1,16:1},i$.b=0,i$.c=0,i$.d=null,i$.e=0,i$.f=0,i$.g=0,i$.i=null;var ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_,uv=null,um=null,uy=null;(i$=nU.prototype=nw.prototype=(function(){}).prototype=new A).s=function(n){var t,e,r;if((e=iE(n))==iV)t=0>ed(this)?ep(this):this;else if(e==ob)t=0>(r=t8(this,new iM(n[0].toString()))).r()?ep(r):r;else throw new nr("Unknown call signature for interim = super.abs: "+e);return new nU(t)},i$.t=function(n){var t,e;if((e=iE(n))==i9)t=r0(this,new X(n[0].toString()));else if(e==i7)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t8(r0(n,t),e);if((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)0?t.e:nP((t.b-1)*.3010299956639812)+1)<-r-1))return t8(r0(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nP((i.b-1)*.3010299956639812)+1)?t8(r0(n,t),e):(f=(o=i.r())==u.r()?iS(rZ((i.d||(i.d=eP(i.g)),i.d),10),eZ(e6(o))):iS(rZ(f=ia((i.d||(i.d=eP(i.g)),i.d),eZ(e6(o))),10),eZ(e6(9*o))),t8(i=new tx(f,i.f+1),e))}(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.add: "+e);return new nU(t)},i$.u=function(){return~~(nB(en(this,8))<<24)>>24},i$.v=function(n){return ic(this,n)},i$.w=function(n){var t,e,r,i;if((i=iE(n))==i9)e=el(this,new X(n[0].toString()));else if(i==i7)e=eg(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tU(fL,{6:1},3,e.length,0);t129?n*=1/0:n=t9(ip(this)),n},i$.gC=function(){return fk},i$.hC=function(){return rm(this)},i$.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nP((this.b-1)*.3010299956639812)+1)?0:(n=new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))).f*n.b[0]},i$.C=function(){return nB(en(this,32))},i$.D=function(){return nB(en(this,32))},i$.E=function(){return t9(ip(this))},i$.F=function(n){return new nU(ic(this,n)>=0?this:n)},i$.G=function(n){return new nU(0>=ic(this,n)?this:n)},i$.H=function(n){return new nU(rJ(this,this.f+n))},i$.I=function(n){return new nU(rJ(this,this.f-n))},i$.J=function(n){var t,e;if((e=iE(n))==i9)t=rk(this,new X(n[0].toString()));else if(e==i7)t=tl(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.multiply: "+e);return new nU(t)},i$.K=function(n){var t,e;if((e=iE(n))==iV)t=ep(this);else if(e==ob)t=ep(t8(this,new iM(n[0].toString())));else throw new nr("Unknown call signature for interim = super.negate: "+e);return new nU(t)},i$.L=function(n){var t,e;if((e=iE(n))==iV)t=this;else if(e==ob)t=t8(this,new iM(n[0].toString()));else throw new nr("Unknown call signature for interim = super.plus: "+e);return new nU(t)},i$.M=function(n){var t,e;if((e=iE(n))==oL)t=rd(this,n[0]);else if(e==oU)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=eo(tn(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rd(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new ni(oh);for(u>0&&(f=new eW(u+i+1,e.c)),r=t8(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tl(r,r,f),(o&c)==c&&(r=tl(r,n,f)),c>>=1;return t<0&&(r=iO(uw,r,f)),is(r,e),r}(this,n[0],new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.pow: "+e);return new nU(t)},i$.q=function(){return rj(this)},i$.N=function(n){var t,e;if((e=iE(n))==i9)t=el(this,new X(n[0].toString()))[1];else if(e==i7)t=eg(this,new X(n[0].toString()),new iM(n[1].toString()))[1];else throw new nr("Unknown call signature for interim = super.remainder: "+e);return new nU(t)},i$.O=function(n){return new nU(t8(this,new iM(eh(n.b))))},i$.P=function(){return eo(this.f)},i$.Q=function(n){var t,e;return new nU((t=this,(e=t.f-n,t.b<54)?0==t.g?eU(e):new ti(t.g,eK(e)):new tM((t.d||(t.d=eP(t.g)),t.d),eK(e))))},i$.R=function(n){var t,e;if((e=iE(n))==oL)t=r1(this,n[0],(iA(),u3));else if(e==oP)t=r1(this,n[0],rQ(n[1]));else if("number RoundingMode"==e)t=r1(this,n[0],ts(n[1].toString()));else throw new nr("Unknown call signature for interim = super.setScale: "+e);return new nU(t)},i$.S=function(){return~~(nB(en(this,16))<<16)>>16},i$.r=function(){return ed(this)},i$.T=function(){return new nU(function(n){var t,e,r,i,o;if(t=1,e=um.length-1,r=n.f,0==n.b&&-1!=n.g)return new X(iW);for(n.d||(n.d=eP(n.g)),o=n.d;!o.gb(0);)if(0==(i=r6(o,um[t]))[1].r())r-=t,t0?i.e:nP((i.b-1)*.3010299956639812)+1)0?r.e:nP((r.b-1)*.3010299956639812)+1)?(f=(c=ed(r))!=i.r()?iS(rZ((r.d||(r.d=eP(r.g)),r.d),10),eZ(e6(c))):iS(rZ(f=ia((r.d||(r.d=eP(r.g)),r.d),eZ(e6(c))),10),eZ(e6(9*c))),t8(new tx(f,r.f+1),o)):t8(iD(r,i),o);else throw new nr("Unknown call signature for interim = super.subtract: "+e);return new nU(t)},i$.V=function(){return new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))},i$.W=function(){return new n2(r5(this))},i$.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nq(u),n.f>0&&i>=-6)i>=0?n7(c,r-eo(n.f),iK):(te(c.b,t-1,t-1,iZ),n7(c,t+1,tP(ua,0,-eo(i)-1)));else{if(e=r-t,0!=(f=eo(i%3))&&(0==(n.d||(n.d=eP(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n7(c,r++,iW);r-t>=1&&(te(c.b,t,t,iK),++r),0!=i&&(te(c.b,r,r,oc),i>0&&n7(c,++r,iz),n7(c,++r,iV+r3(r4(i))))}return c.b.b}(this)},i$.Y=function(){return function(n){var t,e,r,i,o,u;if(r=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ed(n)?1:0,e=n.f,i=new Z(r.length+1+((o=eo(n.f))<0?-o:o)),1==t&&(i.b.b+=iJ),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iZ;e>ua.length;e-=ua.length)tG(i,ua);n9(i,ua,eo(e)),nE(i,n8(r,t))}else nE(i,(u=eo(e=t-e),r.substr(t,u-t))),i.b.b+=iK,nE(i,n8(r,eo(e)))}else{for(nE(i,n8(r,t));e<-ua.length;e+=ua.length)tG(i,ua);n9(i,ua,eo(-e))}return i.b.b}(this)},i$.tS=function(){return ip(this)},i$.Z=function(){return new nU(new ti(1,this.f))},i$.$=function(){return new n2((this.d||(this.d=eP(this.g)),this.d))},i$.cM={3:1,6:1,8:1,10:1,16:1,24:1},(i$=H.prototype=(function(){}).prototype=new a).gC=function(){return fU};var uC=!1;(i$=ru.prototype=ro.prototype=to.prototype=e9.prototype=tV.prototype=rh.prototype=nG.prototype=iC.prototype=N.prototype=new B)._=function(){return this.f<0?new to(1,this.e,this.b):this},i$.ab=function(){return eq(this)},i$.eQ=function(n){return eV(this,n)},i$.gC=function(){return fP},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.cb=function(){return 0==this.f?this:new to(-this.f,this.e,this.b)},i$.db=function(n){return rL(this,n)},i$.eb=function(n){return tY(this,n)},i$.fb=function(n){return t1(this,n)},i$.r=function(){return this.f},i$.gb=function(n){return rT(this,n)},i$.tS=function(){return iF(this,0)},i$.cM={6:1,8:1,10:1,17:1},i$.b=null,i$.c=-2,i$.d=0,i$.e=0,i$.f=0;var uS,uM,ux,uB,uA,uN=null;(i$=n2.prototype=nD.prototype=nk.prototype=(function(){}).prototype=new N)._=function(){return new n2(this.f<0?new to(1,this.e,this.b):this)},i$.hb=function(n){return new n2(iS(this,n))},i$.ib=function(n){return new n2(0==n.f||0==this.f?(rW(),uA):eV(n,(rW(),uS))?this:eV(this,uS)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=np(n.e,t.e),(e=n_(ew(n),ew(t)))>=i)return rW(),uA;for(r=tU(fp,{6:1},-1,i,1);e0?rz(n,this):this.e>n.e?i_(this,n):i_(n,this))},i$.jb=function(n){return new n2(0==n.f?this:0==this.f?(rW(),uA):eV(this,(rW(),uS))?new n2(r8(n)):eV(n,uS)?uA:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tU(fp,{6:1},-1,n.e,1),r=np(n.e,t.e),e=ew(n);e=n.e)return n;for(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=ew(n),o=ew(t),i>=t.e)return n;if(c=n_(n.e,t.e),r=i,o>i){for(f=tU(fp,{6:1},-1,c,1),u=np(n.e,o);r=t.e)return rW(),uA;if(u=tU(fp,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},i$.qb=function(n){return new n2(rR(this,n))},i$.gC=function(){return fQ},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.B=function(){return this.f*this.b[0]},i$.rb=function(n){return function(n,t){var e,r;if(ij(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rT(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uW,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n2(this.f<0?new to(1,this.e,this.b):this),n)},i$.sb=function(){return t9(iF(this,0))},i$.tb=function(n){return new n2(1==rt(this,n)?this:n)},i$.ub=function(n){return new n2(-1==rt(this,n)?this:n)},i$.vb=function(n){return new n2(ee(this,n))},i$.wb=function(n){return new n2(rO(this,n))},i$.xb=function(n,t){return new n2(rG(this,n,t))},i$.yb=function(n){return new n2(et(this,n))},i$.cb=function(){return new n2(0==this.f?this:new to(-this.f,this.e,this.b))},i$.zb=function(){return new n2(function(n){if(n.f<0)throw new ni("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(ij(),o=tU(fp,{6:1},-1,uW.length,1),r=tU(fv,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uW[e];++e);return uK[e]}for(f=new to(1,n.e,tU(fp,{6:1},-1,n.e+1,1)),iB(n.b,0,f.b,0,n.e),rT(n,0)?tW(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iw(this,n):n.f>0?iw(n,this):ew(n)>ew(this)?rX(n,this):rX(this,n))},i$.db=function(n){return new n2(rL(this,n))},i$.Cb=function(n){return new n2(rH(this,n))},i$.Db=function(n){return new n2(rT(this,n)?this:ie(this,n))},i$.eb=function(n){return new n2(tY(this,n))},i$.fb=function(n){return new n2(t1(this,n))},i$.r=function(){return this.f},i$.Eb=function(n){return new n2(ia(this,n))},i$.gb=function(n){return rT(this,n)},i$.Fb=function(n){var t,e;if((e=iE(n))==iV)t=iF(this,0);else if(e==oL)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(ix(),g=n.f,s=n.e,u=n.b,0==g)return iW;if(1==s)return _=ta(e6(u[0]),o6),g<0&&(_=eQ(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return iV+r3(n);if(e=tU(fK,{6:1},-1,65,1),rv(),r=64,i=e6(t),rN(n,oJ)){for(;rN(n,i);)e[r--]=uO[nB(n6(n,i))],n=iI(n,i,!1);e[r]=uO[nB(n)]}else{for(;!rA(n,eQ(i));)e[r--]=uO[nB(eQ(n6(n,i)))],n=iI(n,i,!1);e[r--]=uO[nB(eQ(n))],e[r]=45}return t3(e,r,65)}(_,t);if(10==t||t<2||t>36)return iF(n,0);if(l=tU(fK,{6:1},-1,b=eo(eq(new n2(n.f<0?new to(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(iB(u,0,w=tU(fp,{6:1},-1,s,1),0,s),d=s,r=uP[t],e=uU[t-2];;){h=ii(w,w,d,e),a=i;do l[--i]=em(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=em(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tP(l,i,b-i)}(this,n[0]);else throw new nr("Unknown call signature for result = super.toString: "+e);return t},i$.Gb=function(n){return new n2(0==n.f?this:0==this.f?n:eV(n,(rW(),uS))?new n2(r8(this)):eV(this,uS)?new n2(r8(n)):this.f>0?n.f>0?this.e>n.e?rw(this,n):rw(n,this):iU(this,n):n.f>0?iU(n,this):ew(n)>ew(this)?io(n,this):io(this,n))},i$.cM={4:1,6:1,8:1,10:1,17:1,24:1},(i$=F.prototype=(function(){}).prototype=new a).gC=function(){return fj};var uI=!1;(i$=nm.prototype=ny.prototype=(function(){}).prototype=new a).gC=function(){return fF},i$.Hb=function(){return this.b.b},i$.Ib=function(){return new nn(this.b.c)},i$.hC=function(){return nx(this.b)},i$.tS=function(){return eh(this.b)},i$.cM={24:1},i$.b=null,(i$=j.prototype=(function(){}).prototype=new a).gC=function(){return fH};var uE=!1;(i$=nn.prototype=nC.prototype=(function(){}).prototype=new a).gC=function(){return f$},i$.Jb=function(){return this.b.b},i$.tS=function(){return this.b.b},i$.cM={5:1,24:1},i$.b=null,(i$=K.prototype=(function(){}).prototype=new a).gC=function(){return fq};var uR=!1;(i$=ni.prototype=(function(){}).prototype=new l).gC=function(){return fG},i$.cM={6:1,12:1,15:1},(i$=no.prototype=V.prototype=(function(){}).prototype=new l).gC=function(){return fJ},i$.cM={6:1,12:1,15:1},(i$=I.prototype=(function(){}).prototype=new a).gC=function(){return fW},i$.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?iV:"class ")+this.d},i$.b=null,i$.c=0,i$.d=null,(i$=$.prototype=(function(){}).prototype=new l).gC=function(){return fZ},i$.cM={6:1,12:1,15:1},(i$=E.prototype=new a).eQ=function(n){return this===n},i$.gC=function(){return fa},i$.hC=function(){return nF(this)},i$.tS=function(){return this.b},i$.cM={6:1,8:1,9:1},i$.b=null,i$.c=0,(i$=nu.prototype=q.prototype=R.prototype=new l).gC=function(){return fX},i$.cM={6:1,12:1,15:1},(i$=nf.prototype=G.prototype=O.prototype=new l).gC=function(){return fz},i$.cM={6:1,12:1,15:1},(i$=nc.prototype=z.prototype=(function(){}).prototype=new l).gC=function(){return fY},i$.cM={6:1,12:1,15:1},(i$=nd.prototype=(function(){}).prototype=new R).gC=function(){return f1},i$.cM={6:1,12:1,15:1},(i$=tu.prototype=(function(){}).prototype=new a).gC=function(){return fC},i$.tS=function(){return this.b+iK+this.d+"(Unknown Source"+(this.c>=0?i5+this.c:iV)+")"},i$.cM={6:1,13:1},i$.b=null,i$.c=0,i$.d=null,(i$=String.prototype).eQ=function(n){return tF(this,n)},i$.gC=function(){return fN},i$.hC=function(){var n,t;return nK(),null!=(t=uk[n=i5+this])?t:(null==(t=uD[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;e Date: Fri, 21 Oct 2022 11:05:51 +0900 Subject: [PATCH 15/27] Fix --- crates/swc_ecma_minifier/src/compress/optimize/sequences.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs index 2104be3b9075..377a411cff80 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/sequences.rs @@ -2492,7 +2492,7 @@ fn can_drop_op_for(a: AssignOp, b: AssignOp) -> bool { } if a == b { - return matches!(a, op!("+=") | op!("-=") | op!("*=")); + return matches!(a, op!("+=") | op!("*=")); } false From 9be6d08c806ce3ef5e884b181a38ba2496ae43e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 21 Oct 2022 11:06:46 +0900 Subject: [PATCH 16/27] Update test refs --- crates/swc/tests/tsc-references/symbolType12.2.minified.js | 2 +- .../33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/swc/tests/tsc-references/symbolType12.2.minified.js b/crates/swc/tests/tsc-references/symbolType12.2.minified.js index 4a820b8ce4bb..b205fe6cbe00 100644 --- a/crates/swc/tests/tsc-references/symbolType12.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolType12.2.minified.js @@ -1,3 +1,3 @@ //// [symbolType12.ts] var s = Symbol.for("assign"), str = ""; -s *= 0, s /= s, s /= 0, s %= s, s %= 0, str += s = s + 0 + "", s -= 0, s <<= s, s <<= 0, s >>= s, s >>= 0, s >>>= s, s >>>= 0, s &= s, s &= 0, s ^= s, s ^= 0, s |= s, s |= 0, str += s || str; +s *= 0, s /= s, s /= 0, s %= s, s %= 0, str += s = s + 0 + "", s -= s, s -= 0, s <<= s, s <<= 0, s >>= s, s >>= 0, s >>>= s, s >>>= 0, s &= s, s &= 0, s ^= s, s ^= 0, s |= s, s |= 0, str += s || str; 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 e7b0858a363d..67c9d3497ac5 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 @@ -68,7 +68,7 @@ }, BigInt(0)); if (void 0 !== _ref$signed && _ref$signed) { var max = BYTE_TABLE[bytes.length] / BigInt(2) - BigInt(1); - (number = BigInt(number)) > max && (number = max - max - BigInt(2)); + (number = BigInt(number)) > max && (number -= max, number -= max, number -= BigInt(2)); } return Number(number); }, numberToBytes = function(number, _temp2) { From be1e3fb24120e020852df815ff3f3842fa3aa888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 24 Oct 2022 16:17:00 +0900 Subject: [PATCH 17/27] Update test refs --- .../full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js | 1 + 1 file changed, 1 insertion(+) 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 7c23436ed0fc..be20c72a6018 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 @@ -8,6 +8,7 @@ ${JSON.stringify(n,null,2)} Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[3*i+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=n?-(i*N)+Math.PI:i*N,s*=.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),s(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i,d=3*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[d+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=n?-(i*N)+Math.PI:i*N,s*=.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),o(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,H({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return eo(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:eo(r))}getTransition(i){return eo(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=eo(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=Z(Math.floor(i),0,255))+Z(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i,d=3*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[d+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return ei(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(ei(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),en(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&ea(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(q(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const c=1<{const n=o8((r.x+i.x/s)/c),o=o9((r.y+i.y/s)/c),a=p.project(n,o);i.x=(a.x*h-u)*s,i.y=(a.y*h-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,c,m,u,d),i(r,p,f,s,a,m,h,u,d)):r.push(h)}(c,o,s,u,d,a,h,r,1):c.push(h),o=u,s=d,a=h}return c}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=Z(n,se,16383),i.y=Z(o,se,16383),(ni.x+1||oi.y+1)&&ea("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const c=[new l(r,n),new l(r,s),new l(o,s),new l(o,n)];if(i.length>2){for(const h of c)if(su(i,h))return!0}for(let u=0;us.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=el(i,r,n[0]);return a!==el(i,r,n[1])||a!==el(i,r,n[2])||a!==el(i,r,n[3])}(i[u],i[u+1],c))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=l.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const c=[];for(let h=0;h{var a,l;const c=D([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=A([],z([],E([],a[i[0]],a[i[1]]),E([],a[i[2]],a[i[1]]))),n=-C(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=I([],T([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=v(this.min),o=v(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,c,h,u){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(u*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(h),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=D([],[i.x,i.y,r,1],n);return new l(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=x();return sw[2]=r,i.intersectsPlane(sw,sT,n),new l(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,v=D([],[p.x,p.y,_,1],o);if(!c&&a?u*=v[3]/n.cameraToCenterDistance:c&&!a&&(u*=n.cameraToCenterDistance/v[3]),f=u,su(y,g)||sl(g,y,f))return!0}return!1}const sw=w(0,0,0),sT=w(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,c=0,h=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),c+=i.readSVarint(),1===o&&(r&&h.push(r),r=[]),r.push(new l(a,c));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&h.push(r),h},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new l(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new l(i.x,i.y),this.max=new l(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new l(0,0)}span(){return new l(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=H({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),h&&p.equals(h[h.length-1])||(h=[p],a.push(h)),h.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,c=a.pixelRatio,h=a.paddedRect.w-2,u=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,h]],m=a.stretchY||[[0,u]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=h-g,v=u-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,h,u)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(h.stretch-b)/w*d+i.left,C=h.fixed-S-I*h.stretch/g,z=(u.stretch-T)/E*p+i.top,k=u.fixed-M-A*u.stretch/y,P=new l(f,_),D=new l(v,_),L=new l(v,z),B=new l(f,z),R=new l(m/c,x/c),F=new l(C/c,k/c),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:h.stretch+h.fixed-j,h:u.stretch+u.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/c/d,minFontScaleY:A/c/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new l(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,c,h,u,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,c,h){const u=[];if(0===r.positionedLines.length)return u;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=c[b.imageName];if(!k)continue;if(k.sdf){ea("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||h)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;h&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new l(-D,D-j),Z=-Math.PI/2,$=new l(...O);(w=new l(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new l(w.x,w.y-V),E=new l(w.x+N,w.y),S=new l(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new l(W,H),T=new l(K,H),E=new l(W,Y),S=new l(K,Y)}if(d){let J;J=s?new l(0,0):U?new l(p[0],p[1]):new l(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new l(0,0),ee=new l(0,0);u.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return u}(0,o,u,a,c,h,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(h,{},x)])[0]>32640&&ea(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(h,{},x),128*g.compositeTextSizes[1].evaluate(h,{},x)])[0]>32640||w[1]>32640)&&ea(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,u,c,h,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,c,h,u,d){let p=c.top,f=c.bottom,m=c.left,_=c.right;const g=c.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),u){const y=new l(m,p),x=new l(_,p),v=new l(m,f),b=new l(_,f),w=u*O;let T=new l(0,0);d&&(T=new l(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,h,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=p([]),this.placementViewportMatrix=p([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=w(0,0,1),f=B(L());return o=f,s=(n?-(i*O)+Math.PI:i*O)*.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,R(f,f,-(r*O)),P(p,p,f),A(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,h){const u=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,c,h,!0,!0,new l(0,0),u)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,h,u){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=h&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=u+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var c,h;if(i.queryGeometry.isAboveHorizon)return!1;const u=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(c=this.paint.get("line-width").evaluate(r,n),(h=this.paint.get("line-gap-width").evaluate(r,n))>0?h+2*c:c),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new l(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return ea("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=h.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],et(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ec(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ec();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return W(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new l(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new l(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ex.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ex.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ex.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;X(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=H({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return er(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new l(0,0),new l(8193,0),new l(8193,8193),new l(0,8193),new l(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=Y(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,c,h,u;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&ea(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=er(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(c&&h&&u){const i=new c9(c),r=new a4(h,u);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,c,h,u,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),h),f["text-size"].possiblyEvaluate(new nk(g),h)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),h),f["icon-size"].possiblyEvaluate(new nk(x),h)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(u+1),h),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(u+1),h),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),h);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},h).join(","),E=b.evaluate(w,{},h),S=m.layoutTextSize.evaluate(w,{},h),I=(m.layoutIconSize.evaluate(w,{},h),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},h),P=24*p.get("text-line-height").evaluate(w,{},h),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},h),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},h);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},h).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},h);const U=p.get("symbol-placement"),V="point"===U,N="point"===U?24*p.get("text-max-width").evaluate(w,{},h):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,N,P,L,o,D,C,a6.vertical,!0,U,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,N,P,L,F,D,C,a6.horizontal,!1,U,S,E);W&&(I.horizontal[F]=W)}j("point"===U?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},h),p.get("icon-anchor").evaluate(w,{},h)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&ea("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,c,h,u,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=c);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=c/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*O,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,h)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,h),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&ea(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&ea(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&ea("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,u,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const U of s1(r.geometry,0)){const V=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,c=-1/0;const h=i[0];for(let u=0;ua)&&(a=d.x),(!u||d.y>c)&&(c=d.y)}const p=Math.min(a-o,c-s);let f=p/2;const m=new lb([],lT);if(0===p)return new l(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(U,16);P(U[0],new lc(V.x,V.y,0,0,void 0),f)}else if("LineString"===r.type)for(const N of r.geometry)P(N,new lc(N[0].x,N[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,c,h,d)}a&&i.generateCollisionDebugBuffers(u,i.collisionBoxArray)}(d,c,i.positions,h,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:W(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?c:null,iconMap:this.returnDependencies?h:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,u=r,L.call(this))},void 0,!1,z):u={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=p(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=p(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,_(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return m(a,a,[n,o,0]),_(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new l(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*O,hc=85.051129*O,hh={albers:{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&&F(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*O),r=(i+Math.sin(this.parallels[1]*O))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*O,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*O))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*O*n;l=q(l,-Math.PI-c,Math.PI-c);const h=l/n*U+this.center[0],u=Math.asin(Z((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=Z(u*U,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=Z(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=Z(180*h/Math.PI,-180,180),p=Z(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=Z(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&F(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*O,r=this.parallels[1]*O,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=O,i=(i-this.center[0])*O;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=Z(c/n*U+this.center[0],-180,180),u=Z((2*Math.atan(Math.pow(o/l,1/n))-hs)*U,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=O)*r,o=n*n;return{x:.5*((i*=O)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=Z(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=Z(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*U,-180,180),h=n*U;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=O,i*=O;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=Z(n-a,-Math.PI,Math.PI),o=Z(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*U,o*U)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=u,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},et(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ec()?i:h,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=eg(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ec()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=eg(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return I(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eT.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${ev.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${ev.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||ev.ACCESS_TOKEN;return ev.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${ev.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${ev.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(ev.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!ev.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||ev.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,H({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=T,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=X,i.bezier=j,i.bindAll=et,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=Z(i.center.lat,-85.051129,85.051129),o=new l(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,c=r/(s/i.pixelsPerMeter),h=p(new Float64Array(16));return m(h,h,[o.x,o.y,0]),_(h,h,[c,c,a]),h},i.clamp=Z,i.clearTileCache=function(i){const r=h.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new u(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=eo,i.collisionCircleLayout=az,i.config=ev,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new u(16);return u!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=d,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=z,i.degToRad=function(i){return i*O},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=C,i.ease=G,i.easeCubicInOut=N,i.emitValidationErrors=rU,i.endsWith=ei,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*O)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*O)/r;return{x:i*O*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=Z((i-.5)/n*U/r,-180,180),a=Math.asin(Z(-(o-.5)/n*r,-1,1)),l=Z(a*U,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return H({},i,r,n)}return H({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new l(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return w(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=h.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),o(["./shared"],function(i){function r(i){var o;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===n[o=i&&i.failIfMajorPerformanceCaveat]&&(n[o]=function(i){var n,o,s,a=(n=document.createElement("canvas"),(o=Object.create(r.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,n.getContext("webgl",o)||n.getContext("experimental-webgl",o));if(!a)return!1;try{s=a.createShader(a.VERTEX_SHADER)}catch(l){return!1}return!(!s||a.isContextLost())&&(a.shaderSource(s,"void main() {}"),a.compileShader(s),!0===a.getShaderParameter(s,a.COMPILE_STATUS))}(o)),!!n[o]&&!document.documentMode)}var n={};function o(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function s(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",h,!0)},0)},a.mousePos=function(i,r){const n=i.getBoundingClientRect();return u(i,n,r)},a.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class d extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function S(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}E.Actor=i.Actor;class I{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const M={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class A{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new ep(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=S(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ef(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class em{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new em(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eg(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ey extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eg(0,0,r,0,0,n,r,n),f=eg(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const ex={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ef(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new em(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:e_,"raster-dem":class extends e_{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function s(i,o){i&&(r.state="errored",n(i)),o&&(r.dem=o,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",n(null))}r.request=i.getImage(this.map._requestManager.transformRequest(o,i.ResourceType.Tile),(function(o,a,l,c){if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(a){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:l,expires:c});const h=i.window.ImageBitmap&&a instanceof i.window.ImageBitmap&&(null==rB&&(rB=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),rB),u=1-(a.width-i.prevPowerOfTwo(a.width))/2;u<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const d=h?a:i.exported.getImageData(a,u),p={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:d,encoding:this.encoding,padding:u};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",p,s.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ey{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ey,canvas:class extends ey{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},ev=function(r,n,o,s){const a=new ex[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eb(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function ew(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eT="mapboxgl_preloaded_worker_pool";class eE{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eT]}numActive(){return Object.keys(this.active).length}}function eS(){return rR||(rR=new eE),rR}function eI(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eE.workerCount=2;const eM={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eA(i,r,n){n.push({command:eM.addSource,args:[i,r[i]]})}function eC(i,r,n){r.push({command:eM.removeSource,args:[i]}),n[i]=!0}function ez(i,r,n,o,a,l){let c;for(c in r=r||{},i=i||{})i.hasOwnProperty(c)&&(s(i[c],r[c])||n.push({command:l,args:[o,c,r[c],a]}));for(c in r)r.hasOwnProperty(c)&&!i.hasOwnProperty(c)&&(s(i[c],r[c])||n.push({command:l,args:[o,c,r[c],a]}))}function ek(i){return i.id}function eP(i,r){return i[r.id]=r,i}class eD{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eL{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eB=Math.tan(85*Math.PI/180);function eR(r,n,s,a,l,c){let h=i.create();if(s){if("globe"===l.projection.name)h=i.calculateGlobeMatrix(l,l.worldSize/l._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=o([],c);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}a||i.rotateZ(h,h,l.angle)}else i.multiply$1(h,l.labelPlaneMatrix,r);return h}function eF(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eR(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function eO(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eW(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eU(i,r){return Math.min(.5+i/r*.5,1.5)}function eV(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=e$(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=e$(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function eN(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeB}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function ej(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eV(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=eO(M.first.point,c).point,C=eO(M.last.point,c).point;if(s&&!o){const z=eN(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eZ(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=e$(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eG(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return eO(l,o,l.z);const c=a(r);return eO(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eZ(i,r,n,o,s,a,l,c){const h=eG(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function e$(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eZ(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eG(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eq=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eX(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=eO(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eV(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eD,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(reO(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),x(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eW(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e2(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e3(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e5{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eH(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e1(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eR(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eF(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e0(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e2(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e3(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e3(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new eJ(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new eJ(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e3(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new eQ);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new eY(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new eY(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new eY(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new eY(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new eY(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=e6(T.text);_(r.text,v,M?e8:C),_(r.text,b,A?e8:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=e6(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?e8:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?e8:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e2(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e4(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e4(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e4(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e4(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e4(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function e6(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const e8=0;class e9{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new e9(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const te=512/i.EXTENT/2;class tt{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const to=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),ts=i.pick(eM,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),ta=i.pick(eM,["setCenter","setZoom","setBearing","setPitch"]),tl=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tc={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class th extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new E(eS(),this),this.imageManager=new d,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tn,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=th.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(tl,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&to(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=eI(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tc[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),to(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=eI(r.layers);const n=(function(i,r){if(!i)return[{command:eM.setStyle,args:[r]}];let n=[];try{if(!s(i.version,r.version))return[{command:eM.setStyle,args:[r]}];s(i.center,r.center)||n.push({command:eM.setCenter,args:[r.center]}),s(i.zoom,r.zoom)||n.push({command:eM.setZoom,args:[r.zoom]}),s(i.bearing,r.bearing)||n.push({command:eM.setBearing,args:[r.bearing]}),s(i.pitch,r.pitch)||n.push({command:eM.setPitch,args:[r.pitch]}),s(i.sprite,r.sprite)||n.push({command:eM.setSprite,args:[r.sprite]}),s(i.glyphs,r.glyphs)||n.push({command:eM.setGlyphs,args:[r.glyphs]}),s(i.transition,r.transition)||n.push({command:eM.setTransition,args:[r.transition]}),s(i.light,r.light)||n.push({command:eM.setLight,args:[r.light]}),s(i.fog,r.fog)||n.push({command:eM.setFog,args:[r.fog]}),s(i.projection,r.projection)||n.push({command:eM.setProjection,args:[r.projection]});const o={},a=[];!function(i,r,n,o){let a;for(a in r=r||{},i=i||{})i.hasOwnProperty(a)&&(r.hasOwnProperty(a)||eC(a,n,o));for(a in r){var l,c;r.hasOwnProperty(a)&&(i.hasOwnProperty(a)?s(i[a],r[a])||("geojson"===i[a].type&&"geojson"===r[a].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!s(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!s(i[n][o],r[n][o]))return!1;return!0}(i,r,a)?n.push({command:eM.setGeoJSONSourceData,args:[a,r[a].data]}):(l=a,c=r,eC(l,n,o),eA(l,c,n))):eA(a,r,n))}}(i.sources,r.sources,a,o);const l=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:eM.removeLayer,args:[i.id]}):l.push(i)});let c=i.terrain;c&&o[c.source]&&(n.push({command:eM.setTerrain,args:[void 0]}),c=void 0),n=n.concat(a),s(c,r.terrain)||n.push({command:eM.setTerrain,args:[r.terrain]}),function(i,r,n){let o,a,l,c,h,u,d;r=r||[];const p=(i=i||[]).map(ek),f=r.map(ek),m=i.reduce(eP,{}),_=r.reduce(eP,{}),g=p.slice(),y=Object.create(null);for(o=0,a=0;o!(i.command in ta));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in ts));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=ev(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(to(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const a=this.getLayer(r);if(a){if(!s(a.filter,n))return null==n?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(i.validateStyle.filter,`layers.${a.id}.filter`,n,{layerType:a.type},o)||(a.filter=i.clone$1(n),this._updateLayer(a)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,a={}){this._checkLoaded();const l=this.getLayer(r);l?s(l.getLayoutProperty(n),o)||(l.setLayoutProperty(n,o,a),this._updateLayer(l)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,a={}){this._checkLoaded();const l=this.getLayer(r);l?s(l.getPaintProperty(n),o)||(l.setPaintProperty(n,o,a)&&this._updateLayer(l),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=ep.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eb);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eb),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const a in r)if(!s(r[a],o[a])){n.set(r),this.stylesheet.fog=r;const l={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(l);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new y(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&to(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new e7(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}th.getSourceType=function(i){return ex[i]},th.setSourceType=function(i,r){ex[i]=r},th.registerForPluginStateChange=i.registerForPluginStateChange;var tu="\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",td="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 tp={},tf={};tp=tg("","\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),tf=tg("#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 tm=tg("\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.");var t_={background:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("#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:tg("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:tg("#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:tg("\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}",td),skyboxGradient:tg("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}",td),skyboxCapture:tg("\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:tg("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:tg("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 tg(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tu.match(s);let u=c?c.concat(l):l;n||(tp.staticUniforms&&(u=tp.staticUniforms.concat(u)),tf.staticUniforms&&(u=tf.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` +Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i,d=3*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[d+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=(n?-(i*N)+Math.PI:i*N)*.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),o(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` #ifndef HAS_UNIFORM_u_${s} varying ${n} ${o} ${s}; #else From 0e64a971b241c21c4dbcdd6ad2484bb8b0d54072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 26 Oct 2022 14:10:26 +0900 Subject: [PATCH 18/27] Add a test --- crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js b/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js new file mode 100644 index 000000000000..911681da5622 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js @@ -0,0 +1,6 @@ +var value, ref = [ + "foo" +], key = "foo"; +[ + "foo" +][1].toUpperCase(); From 77c5563973555fd5f76cc7dbb63ad937debff040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 26 Oct 2022 14:12:25 +0900 Subject: [PATCH 19/27] fixup for add test --- crates/swc_ecma_minifier/tests/fixture/pr/config.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 crates/swc_ecma_minifier/tests/fixture/pr/config.json diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/config.json b/crates/swc_ecma_minifier/tests/fixture/pr/config.json new file mode 100644 index 000000000000..ac4e89404c80 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/pr/config.json @@ -0,0 +1,5 @@ +{ + "defaults": true, + "toplevel": true, + "passes": 0 +} From 72e8d3e35883b90ab24a566eb94dde36e4372fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 26 Oct 2022 14:14:32 +0900 Subject: [PATCH 20/27] Fix input --- crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js b/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js index 911681da5622..83750164e91e 100644 --- a/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js +++ b/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/input.js @@ -1,6 +1,4 @@ -var value, ref = [ +var ref = [ "foo" -], key = "foo"; -[ - "foo" -][1].toUpperCase(); +], key = ref[0], value = ref[1]; +value.toUpperCase(); From e56b714a21b9172aa31a8547a5bfd8d903c1e959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 26 Oct 2022 14:23:43 +0900 Subject: [PATCH 21/27] Fix `this` --- .../src/simplify/expr/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs b/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs index dff8c6efbc8b..5482bd38dcf4 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs @@ -258,7 +258,10 @@ impl SimplifyExpr { } if exprs.is_empty() { - *expr = *val; + *expr = Expr::Seq(SeqExpr { + span: val.span(), + exprs: vec![0.into(), val], + }); return; } From ac4ea57c3cca3305de10f35482be9269b9e9a65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 26 Oct 2022 14:24:10 +0900 Subject: [PATCH 22/27] Update test refs --- crates/swc_ecma_minifier/tests/fixture/pr/6169/1/output.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 crates/swc_ecma_minifier/tests/fixture/pr/6169/1/output.js diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/output.js b/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/output.js new file mode 100644 index 000000000000..7eb42feb65d3 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/pr/6169/1/output.js @@ -0,0 +1,3 @@ +[ + "foo" +][1].toUpperCase(); From f6d1a462f98168284544bfa3bf0edafd0c1cafcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Wed, 26 Oct 2022 14:25:39 +0900 Subject: [PATCH 23/27] Add one more test --- .../swc_ecma_minifier/tests/fixture/pr/6169/2/input.js | 8 ++++++++ .../swc_ecma_minifier/tests/fixture/pr/6169/2/output.js | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 crates/swc_ecma_minifier/tests/fixture/pr/6169/2/input.js create mode 100644 crates/swc_ecma_minifier/tests/fixture/pr/6169/2/output.js diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/6169/2/input.js b/crates/swc_ecma_minifier/tests/fixture/pr/6169/2/input.js new file mode 100644 index 000000000000..389ddef17ae0 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/pr/6169/2/input.js @@ -0,0 +1,8 @@ +var ref = [ + , { + toUpperCase() { + console.log(this) + } + } +], key = ref[0], value = ref[1]; +value.toUpperCase(); diff --git a/crates/swc_ecma_minifier/tests/fixture/pr/6169/2/output.js b/crates/swc_ecma_minifier/tests/fixture/pr/6169/2/output.js new file mode 100644 index 000000000000..e4adab9b1b78 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/pr/6169/2/output.js @@ -0,0 +1,9 @@ +var ref = [ + , + { + toUpperCase () { + console.log(this); + } + } +]; +(ref[0], ref[1]).toUpperCase(); From bd696251cc71d044ddcf13b299415fd3a5bafe7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 27 Oct 2022 07:51:48 +0900 Subject: [PATCH 24/27] Update test refs --- .../static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js | 6 +----- .../feedback-mapbox/2c796e83-0724e2af5f19128a/output.js | 5 +---- .../tests/full/issue-5912-bigdecimal/output.js | 4 +--- .../tests/terser/compress/evaluate/issue_2231_3/output.js | 2 +- .../tests/terser/compress/issue_t50/issue_t50/output.js | 8 +++++++- .../terser/compress/issue_t50/issue_t50_const/output.js | 8 +++++++- .../terser/compress/issue_t50/issue_t50_let/output.js | 8 +++++++- 7 files changed, 25 insertions(+), 16 deletions(-) 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 35ef1fa43160..e4581deaf4b8 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 @@ -10244,12 +10244,8 @@ return ("00" + value.toString(16)).slice(-2); } }, parseType_1 = function(buffer) { - var result = ""; - return result += String.fromCharCode(buffer[0]), result += String.fromCharCode(buffer[1]), result += String.fromCharCode(buffer[2]), result += String.fromCharCode(buffer[3]); - }, toUnsigned$2 = bin.toUnsigned, findBox_1 = function findBox(data, path) { - }, parseType$1 = function(buffer) { return String.fromCharCode(buffer[0]) + String.fromCharCode(buffer[1]) + String.fromCharCode(buffer[2]) + String.fromCharCode(buffer[3]); - }, toUnsigned$2 = bin.toUnsigned, findBox = function findBox(data, path) { + }, toUnsigned$2 = bin.toUnsigned, findBox_1 = function findBox(data, path) { var i, size, type, end, subresults, results = []; if (!path.length) return null; for(i = 0; i < data.byteLength;)size = toUnsigned$2(data[i] << 24 | data[i + 1] << 16 | data[i + 2] << 8 | data[i + 3]), type = parseType_1(data.subarray(i + 4, i + 8)), end = size > 1 ? i + size : data.byteLength, type === path[0] && (1 === path.length ? results.push(data.subarray(i + 8, end)) : (subresults = findBox(data.subarray(i + 8, end), path.slice(1))).length && (results = results.concat(subresults))), i = end; 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 be20c72a6018..6b329c902979 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 @@ -5,10 +5,7 @@ Thank you! Filter Expression: ${JSON.stringify(n,null,2)} `)}const a=tr[`filter_${r}`],l=i9(o,a);let c=null;if("error"===l.result)throw Error(l.value.map(i=>`${i.key}: ${i.message}`).join(", "));c=(i,r,n)=>l.value.evaluate(i,r,{},n);let h=null,u=null;if(o!==n){const d=i9(n,a);if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));h=(i,r,n,o,s)=>d.value.evaluate(i,r,{},n,void 0,void 0,o,s),u=!t8(d.value.expression)}return{filter:c,dynamicFilter:h||void 0,needGeometry:function i(r){if(!Array.isArray(r))return!1;if("within"===r[0])return!0;for(let n=1;n",">=","<","<=","to-boolean"]);function rp(i,r){return ir?1:0}function rf(i,r,n){switch(i){case"$type":return[`filter-type-${n}`,r];case"$id":return[`filter-id-${n}`,r];default:return[`filter-${n}`,i,r]}}function rm(i,r){if(0===r.length)return!1;switch(i){case"$type":return["filter-type-in",["literal",r]];case"$id":return["filter-id-in",["literal",r]];default:return r.length>200&&!r.some(i=>typeof i!=typeof r[0])?["filter-in-large",i,["literal",r.sort(rp)]]:["filter-in-small",i,["literal",r]]}}function r_(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function rg(i){return["!",i]}function ry(i){if(rc(tl(i.value))){const r=tl(i.layerType);return ra(ts({},i,{expressionContext:"filter",valueSpec:i.styleSpec[`filter_${r||"fill"}`]}))}return function i(r){const n=r.value,o=r.key;if("array"!==iJ(n))return[new tn(o,n,`array expected, ${iJ(n)} found`)];const s=r.styleSpec;let a,l=[];if(n.length<1)return[new tn(o,n,"filter array must have at least 1 element")];switch(l=l.concat(rl({key:`${o}[0]`,value:n[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),ta(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===ta(n[1])&&l.push(new tn(o,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":3!==n.length&&l.push(new tn(o,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&"string"!==(a=iJ(n[1]))&&l.push(new tn(`${o}[1]`,n[1],`string expected, ${a} found`));for(let c=2;c{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[3*i+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=n?-(i*N)+Math.PI:i*N,s*=.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),s(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` -Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i,d=3*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[d+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=n?-(i*N)+Math.PI:i*N,s*=.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),o(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` -Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,H({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return eo(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:eo(r))}getTransition(i){return eo(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=eo(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=Z(Math.floor(i),0,255))+Z(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i,d=3*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[d+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return ei(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(ei(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),en(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&ea(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(q(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const c=1<{const n=o8((r.x+i.x/s)/c),o=o9((r.y+i.y/s)/c),a=p.project(n,o);i.x=(a.x*h-u)*s,i.y=(a.y*h-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,c,m,u,d),i(r,p,f,s,a,m,h,u,d)):r.push(h)}(c,o,s,u,d,a,h,r,1):c.push(h),o=u,s=d,a=h}return c}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=Z(n,se,16383),i.y=Z(o,se,16383),(ni.x+1||oi.y+1)&&ea("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const c=[new l(r,n),new l(r,s),new l(o,s),new l(o,n)];if(i.length>2){for(const h of c)if(su(i,h))return!0}for(let u=0;us.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=el(i,r,n[0]);return a!==el(i,r,n[1])||a!==el(i,r,n[2])||a!==el(i,r,n[3])}(i[u],i[u+1],c))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=l.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const c=[];for(let h=0;h{var a,l;const c=D([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=A([],z([],E([],a[i[0]],a[i[1]]),E([],a[i[2]],a[i[1]]))),n=-C(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=I([],T([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=v(this.min),o=v(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,c,h,u){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(u*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(h),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=D([],[i.x,i.y,r,1],n);return new l(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=x();return sw[2]=r,i.intersectsPlane(sw,sT,n),new l(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,v=D([],[p.x,p.y,_,1],o);if(!c&&a?u*=v[3]/n.cameraToCenterDistance:c&&!a&&(u*=n.cameraToCenterDistance/v[3]),f=u,su(y,g)||sl(g,y,f))return!0}return!1}const sw=w(0,0,0),sT=w(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,c=0,h=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),c+=i.readSVarint(),1===o&&(r&&h.push(r),r=[]),r.push(new l(a,c));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&h.push(r),h},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new l(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new l(i.x,i.y),this.max=new l(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new l(0,0)}span(){return new l(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=H({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new l(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new l(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),h&&p.equals(h[h.length-1])||(h=[p],a.push(h)),h.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,c=a.pixelRatio,h=a.paddedRect.w-2,u=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,h]],m=a.stretchY||[[0,u]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=h-g,v=u-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,h,u)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(h.stretch-b)/w*d+i.left,C=h.fixed-S-I*h.stretch/g,z=(u.stretch-T)/E*p+i.top,k=u.fixed-M-A*u.stretch/y,P=new l(f,_),D=new l(v,_),L=new l(v,z),B=new l(f,z),R=new l(m/c,x/c),F=new l(C/c,k/c),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:h.stretch+h.fixed-j,h:u.stretch+u.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/c/d,minFontScaleY:A/c/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new l(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,c,h,u,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,c,h){const u=[];if(0===r.positionedLines.length)return u;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=c[b.imageName];if(!k)continue;if(k.sdf){ea("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||h)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;h&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new l(-D,D-j),Z=-Math.PI/2,$=new l(...O);(w=new l(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new l(w.x,w.y-V),E=new l(w.x+N,w.y),S=new l(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new l(W,H),T=new l(K,H),E=new l(W,Y),S=new l(K,Y)}if(d){let J;J=s?new l(0,0):U?new l(p[0],p[1]):new l(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new l(0,0),ee=new l(0,0);u.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return u}(0,o,u,a,c,h,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(h,{},x)])[0]>32640&&ea(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(h,{},x),128*g.compositeTextSizes[1].evaluate(h,{},x)])[0]>32640||w[1]>32640)&&ea(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,u,c,h,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,c,h,u,d){let p=c.top,f=c.bottom,m=c.left,_=c.right;const g=c.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),u){const y=new l(m,p),x=new l(_,p),v=new l(m,f),b=new l(_,f),w=u*O;let T=new l(0,0);d&&(T=new l(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,h,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=p([]),this.placementViewportMatrix=p([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=w(0,0,1),f=B(L());return o=f,s=(n?-(i*O)+Math.PI:i*O)*.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,R(f,f,-(r*O)),P(p,p,f),A(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,h){const u=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,c,h,!0,!0,new l(0,0),u)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,c,h,u){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=h&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=u+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var c,h;if(i.queryGeometry.isAboveHorizon)return!1;const u=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(c=this.paint.get("line-width").evaluate(r,n),(h=this.paint.get("line-gap-width").evaluate(r,n))>0?h+2*c:c),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new l(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return ea("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=h.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],et(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ec(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ec();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return W(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new l(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new l(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ex.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ex.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ex.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;X(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=H({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return er(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new l(0,0),new l(8193,0),new l(8193,8193),new l(0,8193),new l(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=Y(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,c,h,u;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&ea(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=er(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(c&&h&&u){const i=new c9(c),r=new a4(h,u);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,c,h,u,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),h),f["text-size"].possiblyEvaluate(new nk(g),h)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),h),f["icon-size"].possiblyEvaluate(new nk(x),h)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(u+1),h),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(u+1),h),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),h);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},h).join(","),E=b.evaluate(w,{},h),S=m.layoutTextSize.evaluate(w,{},h),I=(m.layoutIconSize.evaluate(w,{},h),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},h),P=24*p.get("text-line-height").evaluate(w,{},h),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},h),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},h);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},h).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},h);const U=p.get("symbol-placement"),V="point"===U,N="point"===U?24*p.get("text-max-width").evaluate(w,{},h):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,N,P,L,o,D,C,a6.vertical,!0,U,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,N,P,L,F,D,C,a6.horizontal,!1,U,S,E);W&&(I.horizontal[F]=W)}j("point"===U?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},h),p.get("icon-anchor").evaluate(w,{},h)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&ea("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,c,h,u,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=c);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=c/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*O,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,h)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,h),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&ea(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&ea(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&ea("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,u,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const U of s1(r.geometry,0)){const V=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,c=-1/0;const h=i[0];for(let u=0;ua)&&(a=d.x),(!u||d.y>c)&&(c=d.y)}const p=Math.min(a-o,c-s);let f=p/2;const m=new lb([],lT);if(0===p)return new l(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(U,16);P(U[0],new lc(V.x,V.y,0,0,void 0),f)}else if("LineString"===r.type)for(const N of r.geometry)P(N,new lc(N[0].x,N[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,c,h,d)}a&&i.generateCollisionDebugBuffers(u,i.collisionBoxArray)}(d,c,i.positions,h,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:W(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?c:null,iconMap:this.returnDependencies?h:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,u=r,L.call(this))},void 0,!1,z):u={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=p(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=p(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,_(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return m(a,a,[n,o,0]),_(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new l(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*O,hc=85.051129*O,hh={albers:{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&&F(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*O),r=(i+Math.sin(this.parallels[1]*O))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*O,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*O))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*O*n;l=q(l,-Math.PI-c,Math.PI-c);const h=l/n*U+this.center[0],u=Math.asin(Z((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=Z(u*U,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=Z(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=Z(180*h/Math.PI,-180,180),p=Z(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=Z(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&F(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*O,r=this.parallels[1]*O,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=O,i=(i-this.center[0])*O;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=Z(c/n*U+this.center[0],-180,180),u=Z((2*Math.atan(Math.pow(o/l,1/n))-hs)*U,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=O)*r,o=n*n;return{x:.5*((i*=O)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=Z(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=Z(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*U,-180,180),h=n*U;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=O,i*=O;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=Z(n-a,-Math.PI,Math.PI),o=Z(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*U,o*U)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=u,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},et(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ec()?i:h,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=eg(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ec()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=eg(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return I(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eT.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${ev.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${ev.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||ev.ACCESS_TOKEN;return ev.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${ev.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${ev.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(ev.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!ev.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||ev.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,H({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=T,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=X,i.bezier=j,i.bindAll=et,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=Z(i.center.lat,-85.051129,85.051129),o=new l(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,c=r/(s/i.pixelsPerMeter),h=p(new Float64Array(16));return m(h,h,[o.x,o.y,0]),_(h,h,[c,c,a]),h},i.clamp=Z,i.clearTileCache=function(i){const r=h.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new u(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=eo,i.collisionCircleLayout=az,i.config=ev,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new u(16);return u!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=d,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=z,i.degToRad=function(i){return i*O},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=C,i.ease=G,i.easeCubicInOut=N,i.emitValidationErrors=rU,i.endsWith=ei,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*O)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*O)/r;return{x:i*O*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=Z((i-.5)/n*U/r,-180,180),a=Math.asin(Z(-(o-.5)/n*r,-1,1)),l=Z(a*U,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return H({},i,r,n)}return H({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new l(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return w(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=h.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),o(["./shared"],function(i){function r(i){var o;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===n[o=i&&i.failIfMajorPerformanceCaveat]&&(n[o]=function(i){var n,o,s,a=(n=document.createElement("canvas"),(o=Object.create(r.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,n.getContext("webgl",o)||n.getContext("experimental-webgl",o));if(!a)return!1;try{s=a.createShader(a.VERTEX_SHADER)}catch(l){return!1}return!(!s||a.isContextLost())&&(a.shaderSource(s,"void main() {}"),a.compileShader(s),!0===a.getShaderParameter(s,a.COMPILE_STATUS))}(o)),!!n[o]&&!document.documentMode)}var n={};function o(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function s(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",h,!0)},0)},a.mousePos=function(i,r){const n=i.getBoundingClientRect();return u(i,n,r)},a.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class d extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function S(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}E.Actor=i.Actor;class I{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const M={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class A{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new ep(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=S(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ef(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class em{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new em(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eg(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ey extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eg(0,0,r,0,0,n,r,n),f=eg(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const ex={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ef(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new em(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:e_,"raster-dem":class extends e_{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function s(i,o){i&&(r.state="errored",n(i)),o&&(r.dem=o,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",n(null))}r.request=i.getImage(this.map._requestManager.transformRequest(o,i.ResourceType.Tile),(function(o,a,l,c){if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(a){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:l,expires:c});const h=i.window.ImageBitmap&&a instanceof i.window.ImageBitmap&&(null==rB&&(rB=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),rB),u=1-(a.width-i.prevPowerOfTwo(a.width))/2;u<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const d=h?a:i.exported.getImageData(a,u),p={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:d,encoding:this.encoding,padding:u};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",p,s.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ey{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ey,canvas:class extends ey{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},ev=function(r,n,o,s){const a=new ex[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eb(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function ew(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eT="mapboxgl_preloaded_worker_pool";class eE{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eT]}numActive(){return Object.keys(this.active).length}}function eS(){return rR||(rR=new eE),rR}function eI(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eE.workerCount=2;const eM={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eA(i,r,n){n.push({command:eM.addSource,args:[i,r[i]]})}function eC(i,r,n){r.push({command:eM.removeSource,args:[i]}),n[i]=!0}function ez(i,r,n,o,a,l){let c;for(c in r=r||{},i=i||{})i.hasOwnProperty(c)&&(s(i[c],r[c])||n.push({command:l,args:[o,c,r[c],a]}));for(c in r)r.hasOwnProperty(c)&&!i.hasOwnProperty(c)&&(s(i[c],r[c])||n.push({command:l,args:[o,c,r[c],a]}))}function ek(i){return i.id}function eP(i,r){return i[r.id]=r,i}class eD{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eL{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eB=Math.tan(85*Math.PI/180);function eR(r,n,s,a,l,c){let h=i.create();if(s){if("globe"===l.projection.name)h=i.calculateGlobeMatrix(l,l.worldSize/l._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=o([],c);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}a||i.rotateZ(h,h,l.angle)}else i.multiply$1(h,l.labelPlaneMatrix,r);return h}function eF(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eR(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function eO(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eW(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eU(i,r){return Math.min(.5+i/r*.5,1.5)}function eV(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=e$(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=e$(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function eN(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeB}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function ej(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eV(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=eO(M.first.point,c).point,C=eO(M.last.point,c).point;if(s&&!o){const z=eN(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eZ(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=e$(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eG(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return eO(l,o,l.z);const c=a(r);return eO(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eZ(i,r,n,o,s,a,l,c){const h=eG(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function e$(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eZ(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eG(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eq=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eX(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=eO(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eV(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eD,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(reO(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),x(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eW(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e2(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e3(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e5{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eH(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e1(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eR(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eF(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e0(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e2(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e3(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e3(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new eJ(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new eJ(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e3(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new eQ);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new eY(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new eY(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new eY(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new eY(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new eY(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=e6(T.text);_(r.text,v,M?e8:C),_(r.text,b,A?e8:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=e6(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?e8:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?e8:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e2(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e4(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e4(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e4(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e4(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e4(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function e6(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const e8=0;class e9{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new e9(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const te=512/i.EXTENT/2;class tt{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const to=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),ts=i.pick(eM,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),ta=i.pick(eM,["setCenter","setZoom","setBearing","setPitch"]),tl=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tc={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class th extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new E(eS(),this),this.imageManager=new d,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tn,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=th.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(tl,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&to(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=eI(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tc[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),to(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=eI(r.layers);const n=(function(i,r){if(!i)return[{command:eM.setStyle,args:[r]}];let n=[];try{if(!s(i.version,r.version))return[{command:eM.setStyle,args:[r]}];s(i.center,r.center)||n.push({command:eM.setCenter,args:[r.center]}),s(i.zoom,r.zoom)||n.push({command:eM.setZoom,args:[r.zoom]}),s(i.bearing,r.bearing)||n.push({command:eM.setBearing,args:[r.bearing]}),s(i.pitch,r.pitch)||n.push({command:eM.setPitch,args:[r.pitch]}),s(i.sprite,r.sprite)||n.push({command:eM.setSprite,args:[r.sprite]}),s(i.glyphs,r.glyphs)||n.push({command:eM.setGlyphs,args:[r.glyphs]}),s(i.transition,r.transition)||n.push({command:eM.setTransition,args:[r.transition]}),s(i.light,r.light)||n.push({command:eM.setLight,args:[r.light]}),s(i.fog,r.fog)||n.push({command:eM.setFog,args:[r.fog]}),s(i.projection,r.projection)||n.push({command:eM.setProjection,args:[r.projection]});const o={},a=[];!function(i,r,n,o){let a;for(a in r=r||{},i=i||{})i.hasOwnProperty(a)&&(r.hasOwnProperty(a)||eC(a,n,o));for(a in r){var l,c;r.hasOwnProperty(a)&&(i.hasOwnProperty(a)?s(i[a],r[a])||("geojson"===i[a].type&&"geojson"===r[a].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!s(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!s(i[n][o],r[n][o]))return!1;return!0}(i,r,a)?n.push({command:eM.setGeoJSONSourceData,args:[a,r[a].data]}):(l=a,c=r,eC(l,n,o),eA(l,c,n))):eA(a,r,n))}}(i.sources,r.sources,a,o);const l=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:eM.removeLayer,args:[i.id]}):l.push(i)});let c=i.terrain;c&&o[c.source]&&(n.push({command:eM.setTerrain,args:[void 0]}),c=void 0),n=n.concat(a),s(c,r.terrain)||n.push({command:eM.setTerrain,args:[r.terrain]}),function(i,r,n){let o,a,l,c,h,u,d;r=r||[];const p=(i=i||[]).map(ek),f=r.map(ek),m=i.reduce(eP,{}),_=r.reduce(eP,{}),g=p.slice(),y=Object.create(null);for(o=0,a=0;o!(i.command in ta));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in ts));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=ev(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(to(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const a=this.getLayer(r);if(a){if(!s(a.filter,n))return null==n?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(i.validateStyle.filter,`layers.${a.id}.filter`,n,{layerType:a.type},o)||(a.filter=i.clone$1(n),this._updateLayer(a)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,a={}){this._checkLoaded();const l=this.getLayer(r);l?s(l.getLayoutProperty(n),o)||(l.setLayoutProperty(n,o,a),this._updateLayer(l)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,a={}){this._checkLoaded();const l=this.getLayer(r);l?s(l.getPaintProperty(n),o)||(l.setPaintProperty(n,o,a)&&this._updateLayer(l),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=ep.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eb);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eb),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const a in r)if(!s(r[a],o[a])){n.set(r),this.stylesheet.fog=r;const l={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(l);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new y(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&to(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new e7(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}th.getSourceType=function(i){return ex[i]},th.setSourceType=function(i,r){ex[i]=r},th.registerForPluginStateChange=i.registerForPluginStateChange;var tu="\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",td="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 tp={},tf={};tp=tg("","\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),tf=tg("#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 tm=tg("\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.");var t_={background:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("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:tg("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:tg("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:tg("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:tg("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:tg("#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:tg("#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:tg("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:tg("#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:tg("\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}",td),skyboxGradient:tg("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}",td),skyboxCapture:tg("\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:tg("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:tg("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 tg(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tu.match(s);let u=c?c.concat(l):l;n||(tp.staticUniforms&&(u=tp.staticUniforms.concat(u)),tf.staticUniforms&&(u=tf.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` -Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i,d=3*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[d+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=(n?-(i*N)+Math.PI:i*N)*.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),o(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` +Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(n[1])} }\`.`)];const p=[];return"symbol"===i.layerType&&("text-field"===c&&s&&!s.glyphs&&p.push(new tn(o,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&iQ(tl(l))&&"identity"===ta(l.type)&&p.push(new tn(o,l,'"text-font" does not support identity functions'))),p.concat(rz({key:i.key,value:l,valueSpec:d,style:s,styleSpec:a,expressionContext:"property",propertyType:r,propertyKey:c}))}function rv(i){return rx(i,"paint")}function rb(i){return rx(i,"layout")}function rw(i){let r=[];const n=i.value,o=i.key,s=i.style,a=i.styleSpec;n.type||n.ref||r.push(new tn(o,n,'either "type" or "ref" is required'));let l=ta(n.type);const c=ta(n.ref);if(n.id){const h=ta(n.id);for(let u=0;u{i in n&&r.push(new tn(o,n[i],`"${i}" is prohibited for ref layers`))}),s.layers.forEach(i=>{ta(i.id)===c&&(p=i)}),p?p.ref?r.push(new tn(o,n.ref,"ref cannot reference another ref layer")):l=ta(p.type):r.push(new tn(o,n.ref,`ref layer "${c}" not found`))}else if("background"!==l&&"sky"!==l){if(n.source){const f=s.sources&&s.sources[n.source],m=f&&ta(f.type);f?"vector"===m&&"raster"===l?r.push(new tn(o,n.source,`layer "${n.id}" requires a raster source`)):"raster"===m&&"raster"!==l?r.push(new tn(o,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==m||n["source-layer"]?"raster-dem"===m&&"hillshade"!==l?r.push(new tn(o,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===l&&n.paint&&n.paint["line-gradient"]&&("geojson"!==m||!f.lineMetrics)&&r.push(new tn(o,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new tn(o,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new tn(o,n.source,`source "${n.source}" not found`))}else r.push(new tn(o,n,'missing required property "source"'))}return r=r.concat(rr({key:o,value:n,valueSpec:a.layer,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":()=>[],type:()=>rz({key:`${o}.type`,value:n.type,valueSpec:a.layer.type,style:i.style,styleSpec:i.styleSpec,object:n,objectKey:"type"}),filter:i=>ry(ts({layerType:l},i)),layout:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rb(ts({layerType:l},i))}}),paint:i=>rr({layer:n,key:i.key,value:i.value,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{"*":i=>rv(ts({layerType:l},i))}})}}))}function rT(i){const r=i.value,n=i.key,o=iJ(r);return"string"!==o?[new tn(n,r,`string expected, ${o} found`)]:[]}const rE={promoteId:function({key:i,value:r}){if("string"===iJ(r))return rT({key:i,value:r});{const n=[];for(const o in r)n.push(...rT({key:`${i}.${o}`,value:r[o]}));return n}}};function rS(i){let r;const n=i.value,o=i.key,s=i.styleSpec,a=i.style;if(!n.type)return[new tn(o,n,'"type" is required')];const l=ta(n.type);switch(l){case"vector":case"raster":case"raster-dem":return rr({key:o,value:n,valueSpec:s[`source_${l.replace("-","_")}`],style:i.style,styleSpec:s,objectElementValidators:rE});case"geojson":if(r=rr({key:o,value:n,valueSpec:s.source_geojson,style:a,styleSpec:s,objectElementValidators:rE}),n.cluster)for(const c in n.clusterProperties){const[h,u]=n.clusterProperties[c],d="string"==typeof h?[h,["accumulated"],["get",c]]:h;r.push(...ra({key:`${o}.${c}.map`,value:u,expressionContext:"cluster-map"})),r.push(...ra({key:`${o}.${c}.reduce`,value:d,expressionContext:"cluster-reduce"}))}return r;case"video":return rr({key:o,value:n,valueSpec:s.source_video,style:a,styleSpec:s});case"image":return rr({key:o,value:n,valueSpec:s.source_image,style:a,styleSpec:s});case"canvas":return[new tn(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rl({key:`${o}.type`,value:n.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:a,styleSpec:s})}}function rI(i){const r=i.value,n=i.styleSpec,o=n.light,s=i.style;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("light",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&o[h[1]]&&o[h[1]].transition?rz({key:c,value:r[c],valueSpec:n.transition,style:s,styleSpec:n}):o[c]?rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}function rM(i){const r=i.value,n=i.key,o=i.style,s=i.styleSpec,a=s.terrain;let l=[];const c=iJ(r);if(void 0===r)return l;if("object"!==c)return l.concat([new tn("terrain",r,`object expected, ${c} found`)]);for(const h in r){const u=h.match(/^(.*)-transition$/);l=l.concat(u&&a[u[1]]&&a[u[1]].transition?rz({key:h,value:r[h],valueSpec:s.transition,style:o,styleSpec:s}):a[h]?rz({key:h,value:r[h],valueSpec:a[h],style:o,styleSpec:s}):[new tn(h,r[h],`unknown property "${h}"`)])}if(r.source){const d=o.sources&&o.sources[r.source],p=d&&ta(d.type);d?"raster-dem"!==p&&l.push(new tn(n,r.source,`terrain cannot be used with a source of type ${p}, it only be used with a "raster-dem" source type`)):l.push(new tn(n,r.source,`source "${r.source}" not found`))}else l.push(new tn(n,r,'terrain is missing required property "source"'));return l}function rA(i){const r=i.value,n=i.style,o=i.styleSpec,s=o.fog;let a=[];const l=iJ(r);if(void 0===r)return a;if("object"!==l)return a.concat([new tn("fog",r,`object expected, ${l} found`)]);for(const c in r){const h=c.match(/^(.*)-transition$/);a=a.concat(h&&s[h[1]]&&s[h[1]].transition?rz({key:c,value:r[c],valueSpec:o.transition,style:n,styleSpec:o}):s[c]?rz({key:c,value:r[c],valueSpec:s[c],style:n,styleSpec:o}):[new tn(c,r[c],`unknown property "${c}"`)])}return a}const rC={"*":()=>[],array:rn,boolean:function(i){const r=i.value,n=i.key,o=iJ(r);return"boolean"!==o?[new tn(n,r,`boolean expected, ${o} found`)]:[]},number:ro,color:function(i){const r=i.key,n=i.value,o=iJ(n);return"string"!==o?[new tn(r,n,`color expected, ${o} found`)]:null===tA.parseCSSColor(n)?[new tn(r,n,`color expected, "${n}" found`)]:[]},constants:to,enum:rl,filter:ry,function:rs,layer:rw,object:rr,source:rS,light:rI,terrain:rM,fog:rA,string:rT,formatted:function(i){return 0===rT(i).length?[]:ra(i)},resolvedImage:function(i){return 0===rT(i).length?[]:ra(i)},projection:function(i){const r=i.value,n=i.styleSpec,o=n.projection,s=i.style;let a=[];const l=iJ(r);if("object"===l)for(const c in r)a=a.concat(rz({key:c,value:r[c],valueSpec:o[c],style:s,styleSpec:n}));else"string"!==l&&(a=a.concat([new tn("projection",r,`object or string expected, ${l} found`)]));return a}};function rz(i){const r=i.value,n=i.valueSpec,o=i.styleSpec;return n.expression&&iQ(ta(r))?rs(i):n.expression&&i8(tl(r))?ra(i):n.type&&rC[n.type]?rC[n.type](i):rr(ts({},i,{valueSpec:n.type?o[n.type]:n}))}function rk(i){const r=i.value,n=i.key,o=rT(i);return o.length||(-1===r.indexOf("{fontstack}")&&o.push(new tn(n,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&o.push(new tn(n,r,'"glyphs" url must include a "{range}" token'))),o}function rP(i,r=tr){let n=[];return n=n.concat(rz({key:"",value:i,valueSpec:r.$root,styleSpec:r,style:i,objectElementValidators:{glyphs:rk,"*":()=>[]}})),i.constants&&(n=n.concat(to({key:"constants",value:i.constants,style:i,styleSpec:r}))),rD(n)}function rD(i){return[].concat(i).sort((i,r)=>i.line-r.line)}function rL(i){return function(...r){return rD(i.apply(this,r))}}rP.source=rL(rS),rP.light=rL(rI),rP.terrain=rL(rM),rP.fog=rL(rA),rP.layer=rL(rw),rP.filter=rL(ry),rP.paintProperty=rL(rv),rP.layoutProperty=rL(rb);const rB=rP.light,rR=rP.fog,rF=rP.paintProperty,rO=rP.layoutProperty;function rU(i,r){let n=!1;if(r&&r.length)for(const o of r)i.fire(new tt(Error(o.message))),n=!0;return n}var rV=rN;function rN(i,r,n){var o=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var s=new Int32Array(this.arrayBuffer);i=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a=d[m+0]&&o>=d[m+1])?(l[f]=!0,a.push(u[f])):l[f]=!1}}},rN.prototype._forEachCell=function(i,r,n,o,s,a,l,c){for(var h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=this._convertToCellCoord(n),p=this._convertToCellCoord(o),f=h;f<=d;f++)for(var m=u;m<=p;m++){var _=this.d*m+f;if((!c||c(this._convertFromCellCoord(f),this._convertFromCellCoord(m),this._convertFromCellCoord(f+1),this._convertFromCellCoord(m+1)))&&s.call(this,i,r,n,o,_,a,l,c))return}},rN.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},rN.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},rN.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,r=3+this.cells.length+1+1,n=0,o=0;o=0)continue;const h=i[c];l[c]=rZ[a].shallow.indexOf(c)>=0?h:rH(h,r)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==a&&(l.$name=a),l}throw Error("can't serialize object of type "+typeof i)}function rK(i){if(null==i||"boolean"==typeof i||"number"==typeof i||"string"==typeof i||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||rX(i)||rW(i)||ArrayBuffer.isView(i)||i instanceof rj)return i;if(Array.isArray(i))return i.map(rK);if("object"==typeof i){const r=i.$name||"Object",{klass:n}=rZ[r];if(!n)throw Error(`can't deserialize unregistered class ${r}`);if(n.deserialize)return n.deserialize(i);const o=Object.create(n.prototype);for(const s of Object.keys(i)){if("$name"===s)continue;const a=i[s];o[s]=rZ[r].shallow.indexOf(s)>=0?a:rK(a)}return o}throw Error("can't deserialize object of type "+typeof i)}class rY{constructor(){this.first=!0}update(i,r){const n=Math.floor(i);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=i,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=1536&&i<=1791,rQ=i=>i>=1872&&i<=1919,r0=i=>i>=2208&&i<=2303,r1=i=>i>=11904&&i<=12031,r2=i=>i>=12032&&i<=12255,r3=i=>i>=12272&&i<=12287,r5=i=>i>=12288&&i<=12351,r4=i=>i>=12352&&i<=12447,r6=i=>i>=12448&&i<=12543,r8=i=>i>=12544&&i<=12591,r9=i=>i>=12704&&i<=12735,r7=i=>i>=12736&&i<=12783,ne=i=>i>=12784&&i<=12799,nt=i=>i>=12800&&i<=13055,ni=i=>i>=13056&&i<=13311,nr=i=>i>=13312&&i<=19903,nn=i=>i>=19968&&i<=40959,no=i=>i>=40960&&i<=42127,ns=i=>i>=42128&&i<=42191,na=i=>i>=44032&&i<=55215,nl=i=>i>=63744&&i<=64255,nc=i=>i>=64336&&i<=65023,nh=i=>i>=65040&&i<=65055,nu=i=>i>=65072&&i<=65103,nd=i=>i>=65104&&i<=65135,np=i=>i>=65136&&i<=65279,nf=i=>i>=65280&&i<=65519;function nm(i){for(const r of i)if(n_(r.charCodeAt(0)))return!0;return!1}function n_(i){return!(746!==i&&747!==i&&(i<4352||!(r9(i)||r8(i)||nu(i)&&!(i>=65097&&i<=65103)||nl(i)||ni(i)||r1(i)||r7(i)||!(!r5(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||12336===i)||nr(i)||nn(i)||nt(i)||i>=12592&&i<=12687||i>=43360&&i<=43391||i>=55216&&i<=55295||i>=4352&&i<=4607||na(i)||r4(i)||r3(i)||i>=12688&&i<=12703||r2(i)||ne(i)||r6(i)&&12540!==i||!(!nf(i)||65288===i||65289===i||65293===i||i>=65306&&i<=65310||65339===i||65341===i||65343===i||i>=65371&&i<=65503||65507===i||i>=65512&&i<=65519)||!(!nd(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||i>=5120&&i<=5759||i>=6320&&i<=6399||nh(i)||i>=19904&&i<=19967||no(i)||ns(i))))}function ng(i){return!(n_(i)||i>=128&&i<=255&&(167===i||169===i||174===i||177===i||188===i||189===i||190===i||215===i||247===i)||i>=8192&&i<=8303&&(8214===i||8224===i||8225===i||8240===i||8241===i||8251===i||8252===i||8258===i||8263===i||8264===i||8265===i||8273===i)||i>=8448&&i<=8527||i>=8528&&i<=8591||i>=8960&&i<=9215&&(i>=8960&&i<=8967||i>=8972&&i<=8991||i>=8996&&i<=9e3||9003===i||i>=9085&&i<=9114||i>=9150&&i<=9165||9167===i||i>=9169&&i<=9179||i>=9186&&i<=9215)||i>=9216&&i<=9279&&9251!==i||i>=9280&&i<=9311||i>=9312&&i<=9471||i>=9632&&i<=9727||i>=9728&&i<=9983&&!(i>=9754&&i<=9759)||i>=11008&&i<=11263&&(i>=11026&&i<=11055||i>=11088&&i<=11097||i>=11192&&i<=11243)||r5(i)||r6(i)||i>=57344&&i<=63743||nu(i)||nd(i)||nf(i)||8734===i||8756===i||8757===i||i>=9984&&i<=10087||i>=10102&&i<=10131||65532===i||65533===i)}function ny(i){return i>=1424&&i<=2303||nc(i)||np(i)}const nx="deferred",nv="loading",nb="loaded";let nw=null,nT="unavailable",nE=null;const nS=function(i){i&&"string"==typeof i&&i.indexOf("NetworkError")>-1&&(nT="error"),nw&&nw(i)};function nI(){nM.fire(new te("pluginStateChange",{pluginStatus:nT,pluginURL:nE}))}const nM=new ti,nA=function(){return nT},nC=function(){if(nT!==nx||!nE)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");nT=nv,nI(),nE&&e3({url:nE},i=>{i?nS(i):(nT=nb,nI())})},nz={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>nT===nb||null!=nz.applyArabicShaping,isLoading:()=>nT===nv,setState(i){nT=i.pluginStatus,nE=i.pluginURL},isParsed:()=>null!=nz.applyArabicShaping&&null!=nz.processBidirectionalText&&null!=nz.processStyledBidirectionalText,getPluginURL:()=>nE};class nk{constructor(i,r){this.zoom=i,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new rY,this.transition={},this.pitch=0)}isSupportedScript(i){return function(i,r){for(const n of i){var o;if(o=n.charCodeAt(0),!r&&ny(o)||o>=2304&&o<=3583||o>=3840&&o<=4255||o>=6016&&o<=6143)return!1}return!0}(i,nz.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const i=this.zoom,r=i-Math.floor(i),n=this.crossFadingFactor();return i>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*r}}}class nP{constructor(i,r){this.property=i,this.value=r,this.expression=function(i,r){if(iQ(i))return new ri(i,r);if(i8(i)){const n=rt(i,r);if("error"===n.result)throw Error(n.value.map(i=>`${i.key}: ${i.message}`).join(", "));return n.value}{let o=i;return"string"==typeof i&&"color"===r.type&&(o=tC.parse(i)),{kind:"constant",evaluate:()=>o}}}(void 0===r?i.specification.default:r,i.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(i,r,n){return this.property.possiblyEvaluate(this,i,r,n)}}class nD{constructor(i){this.property=i,this.value=new nP(i,void 0)}transitioned(i,r){return new nB(this.property,this.value,r,J({},i.transition,this.transition),i.now)}untransitioned(){return new nB(this.property,this.value,null,{},0)}}class nL{constructor(i){this._properties=i,this._values=Object.create(i.defaultTransitionablePropertyValues)}getValue(i){return el(this._values[i].value.value)}setValue(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].value=new nP(this._values[i].property,null===r?void 0:el(r))}getTransition(i){return el(this._values[i].transition)}setTransition(i,r){this._values.hasOwnProperty(i)||(this._values[i]=new nD(this._values[i].property)),this._values[i].transition=el(r)||void 0}serialize(){const i={};for(const r of Object.keys(this._values)){const n=this.getValue(r);void 0!==n&&(i[r]=n);const o=this.getTransition(r);void 0!==o&&(i[`${r}-transition`]=o)}return i}transitioned(i,r){const n=new nR(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].transitioned(i,r._values[o]);return n}untransitioned(){const i=new nR(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].untransitioned();return i}}class nB{constructor(i,r,n,o,s){const a=o.delay||0,l=o.duration||0;s=s||0,this.property=i,this.value=r,this.begin=s+a,this.end=this.begin+l,i.specification.transition&&(o.delay||o.duration)&&(this.prior=n)}possiblyEvaluate(i,r,n){const o=i.now||0,s=this.value.possiblyEvaluate(i,r,n),a=this.prior;if(a){if(o>this.end||this.value.isDataDriven())return this.prior=null,s;if(oo.zoomHistory.lastIntegerZoom?{from:i,to:r,other:n}:{from:n,to:r,other:i}}interpolate(i){return i}}class nG{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){if(void 0!==i.value){if("constant"===i.expression.kind){const s=i.expression.evaluate(r,null,{},n,o);return this._calculate(s,s,s,r)}return this._calculate(i.expression.evaluate(new nk(Math.floor(r.zoom-1),r)),i.expression.evaluate(new nk(Math.floor(r.zoom),r)),i.expression.evaluate(new nk(Math.floor(r.zoom+1),r)),r)}}_calculate(i,r,n,o){return o.zoom>o.zoomHistory.lastIntegerZoom?{from:i,to:r}:{from:n,to:r}}interpolate(i){return i}}class nZ{constructor(i){this.specification=i}possiblyEvaluate(i,r,n,o){return!!i.expression.evaluate(r,null,{},n,o)}interpolate(){return!1}}class n${constructor(i){for(const r in this.properties=i,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],i){const n=i[r];n.specification.overridable&&this.overridableProperties.push(r);const o=this.defaultPropertyValues[r]=new nP(n,void 0),s=this.defaultTransitionablePropertyValues[r]=new nD(n);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate({})}}}function nq(i,r){return 256*(i=X(Math.floor(i),0,255))+X(Math.floor(r),0,255)}r$("DataDrivenProperty",nN),r$("DataConstantProperty",nV),r$("CrossFadedDataDrivenProperty",nj),r$("CrossFadedProperty",nG),r$("ColorRampProperty",nZ);const nX={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class nW{constructor(i,r){this._structArray=i,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class nH{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(i,r){return i._trim(),r&&(i.isTransferred=!0,r.push(i.arrayBuffer)),{length:i.length,arrayBuffer:i.arrayBuffer}}static deserialize(i){const r=Object.create(this.prototype);return r.arrayBuffer=i.arrayBuffer,r.length=i.length,r.capacity=i.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(i){this.reserve(i),this.length=i}reserve(i){if(i>this.capacity){this.capacity=Math.max(i,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function nK(i,r=1){let n=0,o=0;return{members:i.map(i=>{const s=nX[i.type].BYTES_PER_ELEMENT,a=n=nY(n,Math.max(r,s)),l=i.components||1;return o=Math.max(o,s),n+=s*l,{name:i.name,type:i.type,components:l,offset:a}}),size:nY(n,Math.max(o,r)),alignment:r}}function nY(i,r){return Math.ceil(i/r)*r}class nJ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.int16[o+0]=r,this.int16[o+1]=n,i}}nJ.prototype.bytesPerElement=4,r$("StructArrayLayout2i4",nJ);class nQ extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.int16[a+0]=r,this.int16[a+1]=n,this.int16[a+2]=o,this.int16[a+3]=s,i}}nQ.prototype.bytesPerElement=8,r$("StructArrayLayout4i8",nQ);class n0 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=6*i,u=12*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.uint8[u+4]=o,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=l,this.float32[3*i+2]=c,i}}n0.prototype.bytesPerElement=12,r$("StructArrayLayout2i4ub1f12",n0);class n1 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.float32[s+0]=r,this.float32[s+1]=n,this.float32[s+2]=o,i}}n1.prototype.bytesPerElement=12,r$("StructArrayLayout3f12",n1);class n2 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,i,r,n,o,s,a,l,c,h,u)}emplace(i,r,n,o,s,a,l,c,h,u,d){const p=10*i;return this.uint16[p+0]=r,this.uint16[p+1]=n,this.uint16[p+2]=o,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=l,this.uint16[p+6]=c,this.uint16[p+7]=h,this.uint16[p+8]=u,this.uint16[p+9]=d,i}}n2.prototype.bytesPerElement=20,r$("StructArrayLayout10ui20",n2);class n3 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,i,r,n,o,s,a,l,c)}emplace(i,r,n,o,s,a,l,c,h){const u=8*i;return this.uint16[u+0]=r,this.uint16[u+1]=n,this.uint16[u+2]=o,this.uint16[u+3]=s,this.uint16[u+4]=a,this.uint16[u+5]=l,this.uint16[u+6]=c,this.uint16[u+7]=h,i}}n3.prototype.bytesPerElement=16,r$("StructArrayLayout8ui16",n3);class n5 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=this.length;return this.resize(y+1),this.emplace(y,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=16*i;return this.int16[x+0]=r,this.int16[x+1]=n,this.int16[x+2]=o,this.int16[x+3]=s,this.uint16[x+4]=a,this.uint16[x+5]=l,this.uint16[x+6]=c,this.uint16[x+7]=h,this.int16[x+8]=u,this.int16[x+9]=d,this.int16[x+10]=p,this.int16[x+11]=f,this.int16[x+12]=m,this.int16[x+13]=_,this.int16[x+14]=g,this.int16[x+15]=y,i}}n5.prototype.bytesPerElement=32,r$("StructArrayLayout4i4ui4i4i32",n5);class n4 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint32[1*i+0]=r,i}}n4.prototype.bytesPerElement=4,r$("StructArrayLayout1ul4",n4);class n6 extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f){const m=this.length;return this.resize(m+1),this.emplace(m,i,r,n,o,s,a,l,c,h,u,d,p,f)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=20*i,g=10*i;return this.int16[_+0]=r,this.int16[_+1]=n,this.int16[_+2]=o,this.int16[_+3]=s,this.int16[_+4]=a,this.float32[g+3]=l,this.float32[g+4]=c,this.float32[g+5]=h,this.float32[g+6]=u,this.int16[_+14]=d,this.uint32[g+8]=p,this.uint16[_+18]=f,this.uint16[_+19]=m,i}}n6.prototype.bytesPerElement=40,r$("StructArrayLayout5i4f1i1ul2ui40",n6);class n8 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=8*i;return this.int16[h+0]=r,this.int16[h+1]=n,this.int16[h+2]=o,this.int16[h+4]=s,this.int16[h+5]=a,this.int16[h+6]=l,this.int16[h+7]=c,i}}n8.prototype.bytesPerElement=16,r$("StructArrayLayout3i2i2i16",n8);class n9 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,i,r,n,o,s)}emplace(i,r,n,o,s,a){const l=4*i,c=8*i;return this.float32[l+0]=r,this.float32[l+1]=n,this.float32[l+2]=o,this.int16[c+6]=s,this.int16[c+7]=a,i}}n9.prototype.bytesPerElement=16,r$("StructArrayLayout2f1f2i16",n9);class n7 extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=12*i,l=3*i;return this.uint8[a+0]=r,this.uint8[a+1]=n,this.float32[l+1]=o,this.float32[l+2]=s,i}}n7.prototype.bytesPerElement=12,r$("StructArrayLayout2ub2f12",n7);class oe extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.uint16[s+0]=r,this.uint16[s+1]=n,this.uint16[s+2]=o,i}}oe.prototype.bytesPerElement=6,r$("StructArrayLayout3ui6",oe);class ot extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w){const T=this.length;return this.resize(T+1),this.emplace(T,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T){const E=30*i,S=15*i,I=60*i;return this.int16[E+0]=r,this.int16[E+1]=n,this.int16[E+2]=o,this.float32[S+2]=s,this.float32[S+3]=a,this.uint16[E+8]=l,this.uint16[E+9]=c,this.uint32[S+5]=h,this.uint32[S+6]=u,this.uint32[S+7]=d,this.uint16[E+16]=p,this.uint16[E+17]=f,this.uint16[E+18]=m,this.float32[S+10]=_,this.float32[S+11]=g,this.uint8[I+48]=y,this.uint8[I+49]=x,this.uint8[I+50]=v,this.uint32[S+13]=b,this.int16[E+28]=w,this.uint8[I+58]=T,i}}ot.prototype.bytesPerElement=60,r$("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ot);class oi extends nH{_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(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k){const P=this.length;return this.resize(P+1),this.emplace(P,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k)}emplace(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z,k,P){const D=38*i,L=19*i;return this.int16[D+0]=r,this.int16[D+1]=n,this.int16[D+2]=o,this.float32[L+2]=s,this.float32[L+3]=a,this.int16[D+8]=l,this.int16[D+9]=c,this.int16[D+10]=h,this.int16[D+11]=u,this.int16[D+12]=d,this.int16[D+13]=p,this.uint16[D+14]=f,this.uint16[D+15]=m,this.uint16[D+16]=_,this.uint16[D+17]=g,this.uint16[D+18]=y,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=T,this.uint16[D+24]=E,this.uint16[D+25]=S,this.uint16[D+26]=I,this.uint16[D+27]=M,this.uint16[D+28]=A,this.uint32[L+15]=C,this.float32[L+16]=z,this.float32[L+17]=k,this.float32[L+18]=P,i}}oi.prototype.bytesPerElement=76,r$("StructArrayLayout3i2f6i15ui1ul3f76",oi);class or extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.float32[1*i+0]=r,i}}or.prototype.bytesPerElement=4,r$("StructArrayLayout1f4",or);class on extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,i,r,n)}emplace(i,r,n,o){const s=3*i;return this.int16[s+0]=r,this.int16[s+1]=n,this.int16[s+2]=o,i}}on.prototype.bytesPerElement=6,r$("StructArrayLayout3i6",on);class oo extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,i,r,n,o,s,a,l)}emplace(i,r,n,o,s,a,l,c){const h=7*i;return this.float32[h+0]=r,this.float32[h+1]=n,this.float32[h+2]=o,this.float32[h+3]=s,this.float32[h+4]=a,this.float32[h+5]=l,this.float32[h+6]=c,i}}oo.prototype.bytesPerElement=28,r$("StructArrayLayout7f28",oo);class os extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=6*i;return this.uint32[3*i+0]=r,this.uint16[a+2]=n,this.uint16[a+3]=o,this.uint16[a+4]=s,i}}os.prototype.bytesPerElement=12,r$("StructArrayLayout1ul3ui12",os);class oa extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.uint16[o+0]=r,this.uint16[o+1]=n,i}}oa.prototype.bytesPerElement=4,r$("StructArrayLayout2ui4",oa);class ol extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(i){const r=this.length;return this.resize(r+1),this.emplace(r,i)}emplace(i,r){return this.uint16[1*i+0]=r,i}}ol.prototype.bytesPerElement=2,r$("StructArrayLayout1ui2",ol);class oc extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r){const n=this.length;return this.resize(n+1),this.emplace(n,i,r)}emplace(i,r,n){const o=2*i;return this.float32[o+0]=r,this.float32[o+1]=n,i}}oc.prototype.bytesPerElement=8,r$("StructArrayLayout2f8",oc);class oh extends nH{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,i,r,n,o)}emplace(i,r,n,o,s){const a=4*i;return this.float32[a+0]=r,this.float32[a+1]=n,this.float32[a+2]=o,this.float32[a+3]=s,i}}oh.prototype.bytesPerElement=16,r$("StructArrayLayout4f16",oh);class ou extends nW{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]}}ou.prototype.size=40;class od extends n6{get(i){return new ou(this,i)}}r$("CollisionBoxArray",od);class op extends nW{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(i){this._structArray.uint8[this._pos1+49]=i}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(i){this._structArray.uint8[this._pos1+50]=i}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(i){this._structArray.uint32[this._pos4+13]=i}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(i){this._structArray.uint8[this._pos1+58]=i}}op.prototype.size=60;class of extends ot{get(i){return new op(this,i)}}r$("PlacedSymbolArray",of);class om extends nW{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(i){this._structArray.uint32[this._pos4+15]=i}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]}}om.prototype.size=76;class o_ extends oi{get(i){return new om(this,i)}}r$("SymbolInstanceArray",o_);class og extends or{getoffsetX(i){return this.float32[1*i+0]}}r$("GlyphOffsetArray",og);class oy extends on{getx(i){return this.int16[3*i+0]}gety(i){return this.int16[3*i+1]}gettileUnitDistanceFromAnchor(i){return this.int16[3*i+2]}}r$("SymbolLineVertexArray",oy);class ox extends nW{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]}}ox.prototype.size=12;class ov extends os{get(i){return new ox(this,i)}}r$("FeatureIndexArray",ov);class ob extends nW{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ob.prototype.size=4;class ow extends oa{get(i){return new ob(this,i)}}r$("FillExtrusionCentroidArray",ow);const oT=nK([{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"}]),oE=nK([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var oS=tM(function(i){i.exports=function(i,r){var n,o,s,a,l,c;for(o=i.length-(n=3&i.length),s=r,c=0;c>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&i.charCodeAt(c+2))<<16;case 2:l^=(255&i.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&i.charCodeAt(c)))*3432918353+(((l>>>16)*3432918353&65535)<<16)&4294967295)<<15|l>>>17))*461845907+(((l>>>16)*461845907&65535)<<16)&4294967295}return s^=i.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}}),oI=tM(function(i){i.exports=function(i,r){for(var n,o=i.length,s=r^o,a=0;o>=4;)n=1540483477*(65535&(n=255&i.charCodeAt(a)|(255&i.charCodeAt(++a))<<8|(255&i.charCodeAt(++a))<<16|(255&i.charCodeAt(++a))<<24))+((1540483477*(n>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),o-=4,++a;switch(o){case 3:s^=(255&i.charCodeAt(a+2))<<16;case 2:s^=(255&i.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&i.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}}),oM=oS;oM.murmur3=oS,oM.murmur2=oI;class oA{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(i,r,n,o){this.ids.push(oC(i)),this.positions.push(r,n,o)}getPositions(i){const r=oC(i);let n=0,o=this.ids.length-1;for(;n>1;this.ids[s]>=r?o=s:n=s+1}const a=[];for(;this.ids[n]===r;)a.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return a}static serialize(i,r){const n=new Float64Array(i.ids),o=new Uint32Array(i.positions);return function i(r,n,o,s){for(;o>1];let l=o-1,c=s+1;for(;;){do l++;while(r[l]a)if(l>=c)break;oz(r,l,c),oz(n,3*l,3*c),oz(n,3*l+1,3*c+1),oz(n,3*l+2,3*c+2)}c-o`u_${i}`),this.type=n}setUniform(i,r,n){i.set(n.constantOr(this.value))}getBinding(i,r,n){return"color"===this.type?new oL(i,r):new oP(i,r)}}class oV{constructor(i,r){this.uniformNames=r.map(i=>`u_${i}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(i,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=i.pixelRatio,this.patternFrom=r.tl.concat(r.br),this.patternTo=i.tl.concat(i.br)}setUniform(i,r,n,o){const s="u_pattern_to"===o||"u_dash_to"===o?this.patternTo:"u_pattern_from"===o||"u_dash_from"===o?this.patternFrom:"u_pixel_ratio_to"===o?this.pixelRatioTo:"u_pixel_ratio_from"===o?this.pixelRatioFrom:null;s&&i.set(s)}getBinding(i,r,n){return"u_pattern_from"===n||"u_pattern_to"===n||"u_dash_from"===n||"u_dash_to"===n?new oD(i,r):new oP(i,r)}}class oN{constructor(i,r,n,o){this.expression=i,this.type=n,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new o}populatePaintArray(i,r,n,o,s,a){const l=this.paintVertexArray.length,c=this.expression.evaluate(new nk(0),r,{},s,o,a);this.paintVertexArray.resize(i),this._setPaintValue(l,i,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:0},n,o,void 0,s);this._setPaintValue(i,r,a)}_setPaintValue(i,r,n){if("color"===this.type){const o=oO(n);for(let s=i;s`u_${i}_t`),this.type=n,this.useIntegerZoom=o,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=r.map(i=>({name:`a_${i}`,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new a}populatePaintArray(i,r,n,o,s,a){const l=this.expression.evaluate(new nk(this.zoom),r,{},s,o,a),c=this.expression.evaluate(new nk(this.zoom+1),r,{},s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(i),this._setPaintValue(h,i,l,c)}updatePaintArray(i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom},n,o,void 0,s),l=this.expression.evaluate({zoom:this.zoom+1},n,o,void 0,s);this._setPaintValue(i,r,a,l)}_setPaintValue(i,r,n,o){if("color"===this.type){const s=oO(n),a=oO(o);for(let l=i;l!0){this.binders={},this._buffers=[];const o=[];for(const s in i.paint._values){var a,l;if(!n(s))continue;const c=i.paint.get(s);if(!(c instanceof nO&&iH(c.property.specification)))continue;const h=(a=s,l=i.type,oq[a]||[a.replace(`${l}-`,"").replace(/-/g,"_")]),u=c.value,d=c.property.specification.type,p=c.property.useIntegerZoom,f=c.property.specification["property-type"],m="cross-faded"===f||"cross-faded-data-driven"===f,_="line-dasharray"===String(s)&&"constant"!==i.layout.get("line-cap").value.kind;if("constant"!==u.kind||_){if("source"===u.kind||_||m){const g=oH(s,d,"source");this.binders[s]=m?new oG(u,h,d,p,r,g,i.id):new oN(u,h,d,g),o.push(`/a_${s}`)}else{const y=oH(s,d,"composite");this.binders[s]=new oj(u,h,d,p,r,y),o.push(`/z_${s}`)}}else this.binders[s]=m?new oV(u.value,h):new oU(u.value,h,d),o.push(`/u_${s}`)}this.cacheKey=o.sort().join("")}getMaxValue(i){const r=this.binders[i];return r instanceof oN||r instanceof oj?r.maxValue:0}populatePaintArrays(i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];(c instanceof oN||c instanceof oj||c instanceof oG)&&c.populatePaintArray(i,r,n,o,s,a)}}setConstantPatternPositions(i,r){for(const n in this.binders){const o=this.binders[n];o instanceof oV&&o.setConstantPatternPositions(i,r)}}updatePaintArrays(i,r,n,o,s,a){let l=!1;for(const c in i){const h=r.getPositions(c);for(const u of h){const d=n.feature(u.index);for(const p in this.binders){const f=this.binders[p];if((f instanceof oN||f instanceof oj||f instanceof oG)&&!0===f.expression.isStateDependent){const m=o.paint.get(p);f.expression=m.value,f.updatePaintArray(u.start,u.end,d,i[c],s,a),l=!0}}}}return l}defines(){const i=[];for(const r in this.binders){const n=this.binders[r];(n instanceof oU||n instanceof oV)&&i.push(...n.uniformNames.map(i=>`#define HAS_UNIFORM_${i}`))}return i}getBinderAttributes(){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof oN||n instanceof oj||n instanceof oG)for(let o=0;o!0){for(const o of(this.programConfigurations={},i))this.programConfigurations[o.id]=new oZ(o,r,n);this.needsUpload=!1,this._featureMap=new oA,this._bufferOffset=0}populatePaintArrays(i,r,n,o,s,a,l){for(const c in this.programConfigurations)this.programConfigurations[c].populatePaintArrays(i,r,o,s,a,l);void 0!==r.id&&this._featureMap.add(r.id,n,this._bufferOffset,i),this._bufferOffset=i,this.needsUpload=!0}updatePaintArrays(i,r,n,o,s){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(i,this._featureMap,r,a,o,s)||this.needsUpload}get(i){return this.programConfigurations[i]}upload(i){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(i);this.needsUpload=!1}}destroy(){for(const i in this.programConfigurations)this.programConfigurations[i].destroy()}}const oq={"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"]},oX={"line-pattern":{source:n2,composite:n2},"fill-pattern":{source:n2,composite:n2},"fill-extrusion-pattern":{source:n2,composite:n2},"line-dasharray":{source:n3,composite:n3}},oW={color:{source:oc,composite:oh},number:{source:or,composite:oc}};function oH(i,r,n){const o=oX[i];return o&&o[n]||oW[r][n]}r$("ConstantBinder",oU),r$("CrossFadedConstantBinder",oV),r$("SourceExpressionBinder",oN),r$("CrossFadedCompositeBinder",oG),r$("CompositeExpressionBinder",oj),r$("ProgramConfiguration",oZ,{omit:["_buffers"]}),r$("ProgramConfigurationSet",o$);const oK="-transition";class oY extends ti{constructor(i,r){if(super(),this.id=i.id,this.type=i.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==i.type&&(this.metadata=i.metadata,this.minzoom=i.minzoom,this.maxzoom=i.maxzoom,"background"!==i.type&&"sky"!==i.type&&(this.source=i.source,this.sourceLayer=i["source-layer"],this.filter=i.filter),r.layout&&(this._unevaluatedLayout=new nF(r.layout)),r.paint)){for(const n in this._transitionablePaint=new nL(r.paint),i.paint)this.setPaintProperty(n,i.paint[n],{validate:!1});for(const o in i.layout)this.setLayoutProperty(o,i.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nU(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(i){return"visibility"===i?this.visibility:this._unevaluatedLayout.getValue(i)}setLayoutProperty(i,r,n={}){null!=r&&this._validate(rO,`layers.${this.id}.layout.${i}`,i,r,n)||("visibility"!==i?this._unevaluatedLayout.setValue(i,r):this.visibility=r)}getPaintProperty(i){return eo(i,oK)?this._transitionablePaint.getTransition(i.slice(0,-oK.length)):this._transitionablePaint.getValue(i)}setPaintProperty(i,r,n={}){if(null!=r&&this._validate(rF,`layers.${this.id}.paint.${i}`,i,r,n))return!1;if(eo(i,oK))return this._transitionablePaint.setTransition(i.slice(0,-oK.length),r||void 0),!1;{const o=this._transitionablePaint._values[i],s="cross-faded-data-driven"===o.property.specification["property-type"],a=o.value.isDataDriven(),l=o.value;this._transitionablePaint.setValue(i,r),this._handleSpecialPaintPropertyUpdate(i);const c=this._transitionablePaint._values[i].value;return c.isDataDriven()||a||s||this._handleOverridablePaintPropertyUpdate(i,l,c)}}_handleSpecialPaintPropertyUpdate(i){}getProgramIds(){return null}getProgramConfiguration(i){return null}_handleOverridablePaintPropertyUpdate(i,r,n){return!1}isHidden(i){return!!(this.minzoom&&i=this.maxzoom)||"none"===this.visibility}updateTransitions(i){this._transitioningPaint=this._transitionablePaint.transitioned(i,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(i,r){i.getCrossfadeParameters&&(this._crossfadeParameters=i.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(i,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(i,void 0,r)}serialize(){const i={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&&(i.layout=i.layout||{},i.layout.visibility=this.visibility),ea(i,(i,r)=>!(void 0===i||"layout"===r&&!Object.keys(i).length||"paint"===r&&!Object.keys(i).length))}_validate(i,r,n,o,s={}){return(!s||!1!==s.validate)&&rU(this,i.call(rP,{key:r,layerType:this.type,objectKey:n,value:o,styleSpec:tr,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const i in this.paint._values){const r=this.paint.get(i);if(r instanceof nO&&iH(r.property.specification)&&("source"===r.value.kind||"composite"===r.value.kind)&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const oJ=nK([{name:"a_pos",components:2,type:"Int16"}],4),{members:oQ}=oJ;class o0{constructor(i=[]){this.segments=i}prepareSegment(i,r,n,o){let s=this.segments[this.segments.length-1];return i>o0.MAX_VERTEX_ARRAY_LENGTH&&eh(`Max vertices per segment is ${o0.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${i}`),(!s||s.vertexLength+i>o0.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==o)&&(s={vertexOffset:r.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==o&&(s.sortKey=o),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const i of this.segments)for(const r in i.vaos)i.vaos[r].destroy()}static simpleSegment(i,r,n,o){return new o0([{vertexOffset:i,primitiveOffset:r,vertexLength:n,primitiveLength:o,vaos:{},sortKey:0}])}}o0.MAX_VERTEX_ARRAY_LENGTH=65535,r$("SegmentVector",o0);class o1{constructor(i,r){i&&(r?this.setSouthWest(i).setNorthEast(r):4===i.length?this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]]):this.setSouthWest(i[0]).setNorthEast(i[1]))}setNorthEast(i){return this._ne=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}setSouthWest(i){return this._sw=i instanceof o2?new o2(i.lng,i.lat):o2.convert(i),this}extend(i){let r,n;const o=this._sw,s=this._ne;if(i instanceof o2)r=i,n=i;else{if(!(i instanceof o1))return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(o1.convert(i)):this.extend(o2.convert(i)):this;if(r=i._sw,n=i._ne,!r||!n)return this}return o||s?(o.lng=Math.min(r.lng,o.lng),o.lat=Math.min(r.lat,o.lat),s.lng=Math.max(n.lng,s.lng),s.lat=Math.max(n.lat,s.lat)):(this._sw=new o2(r.lng,r.lat),this._ne=new o2(n.lng,n.lat)),this}getCenter(){return new o2((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 o2(this.getWest(),this.getNorth())}getSouthEast(){return new o2(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(i){const{lng:r,lat:n}=o2.convert(i);let o=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&o}static convert(i){return!i||i instanceof o1?i:new o1(i)}}class o2{constructor(i,r){if(isNaN(i)||isNaN(r))throw Error(`Invalid LngLat object: (${i}, ${r})`);if(this.lng=+i,this.lat=+r,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new o2(H(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(i){const r=Math.PI/180,n=this.lat*r,o=i.lat*r,s=Math.sin(n)*Math.sin(o)+Math.cos(n)*Math.cos(o)*Math.cos((i.lng-this.lng)*r);return 6371008.8*Math.acos(Math.min(s,1))}toBounds(i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*this.lat);return new o1(new o2(this.lng-n,this.lat-r),new o2(this.lng+n,this.lat+r))}static convert(i){if(i instanceof o2)return i;if(Array.isArray(i)&&(2===i.length||3===i.length))return new o2(Number(i[0]),Number(i[1]));if(!Array.isArray(i)&&"object"==typeof i&&null!==i)return new o2(Number("lng"in i?i.lng:i.lon),Number(i.lat));throw Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const o3=2*Math.PI*6371008.8;function o5(i){return o3*Math.cos(i*Math.PI/180)}function o4(i){return(180+i)/360}function o6(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function o8(i){return 360*i-180}function o9(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class o7{constructor(i,r,n=0){this.x=+i,this.y=+r,this.z=+n}static fromLngLat(i,r=0){const n=o2.convert(i);return new o7(o4(n.lng),o6(n.lat),r/o5(n.lat))}toLngLat(){return new o2(o8(this.x),o9(this.y))}toAltitude(){return this.z*o5(o9(this.y))}meterInMercatorCoordinateUnits(){return 1/o3*(1/Math.cos(o9(this.y)*Math.PI/180))}}const se=-16383-1;function st(i,r,n){const o=i.loadGeometry(),s=i.extent,a=8192/s;if(r&&n&&n.projection.isReprojectedInTileSpace){const l=1<{const n=o8((r.x+i.x/s)/l),o=o9((r.y+i.y/s)/l),a=p.project(n,o);i.x=(a.x*c-h)*s,i.y=(a.y*c-d)*s};for(let m=0;m=d?(i(r,n,o,p,f,l,m,h,d),i(r,p,f,s,a,m,c,h,d)):r.push(c)}(l,o,s,h,d,a,c,r,1):l.push(c),o=h,s=d,a=c}return l}(o[m],f,0);else{const _=[];for(const g of o[m])g.x<0||g.x>=s||g.y<0||g.y>=s||(f(g),_.push(g));o[m]=_}}for(const y of o)for(const x of y)!function(i,r){const n=Math.round(i.x*r),o=Math.round(i.y*r);i.x=X(n,se,16383),i.y=X(o,se,16383),(ni.x+1||oi.y+1)&&eh("Geometry exceeds allowed extent, reduce your vector tile buffer size")}(x,a);return o}function si(i,r){return{type:i.type,id:i.id,properties:i.properties,geometry:r?st(i):[]}}function sr(i,r,n,o,s){i.emplaceBack(2*r+(o+1)/2,2*n+(s+1)/2)}class sn{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nJ,this.indexArray=new oe,this.segments=new o0,this.programConfigurations=new o$(i.layers,i.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){const s=this.layers[0],a=[];let l=null;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of("circle"===s.type&&(l=s.layout.get("circle-sort-key")),i)){const p=this.layers[0]._featureFilter.needGeometry,f=si(c,p);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),f,n))continue;const m=l?l.evaluate(f,{},n):void 0,_={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:p?f.geometry:st(c,n,o),patterns:{},sortKey:m};a.push(_)}for(const g of(l&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:y,index:x,sourceLayerIndex:v}=g,b=i[x].feature;this.addFeature(g,y,x,r.availableImages,n),r.featureIndex.insert(b,y,x,v,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,oQ),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(i,r,n,o,s){for(const a of r)for(const l of a){const c=l.x,h=l.y;if(c<0||c>=8192||h<0||h>=8192)continue;const u=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,i.sortKey),d=u.vertexLength;sr(this.layoutVertexArray,c,h,-1,-1),sr(this.layoutVertexArray,c,h,1,-1),sr(this.layoutVertexArray,c,h,1,1),sr(this.layoutVertexArray,c,h,-1,1),this.indexArray.emplaceBack(d,d+1,d+2),this.indexArray.emplaceBack(d,d+3,d+2),u.vertexLength+=4,u.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,{},o,s)}}function so(i,r){for(let n=0;n1?n:n.sub(r)._mult(s)._add(r))}function sh(i,r){let n,o,s,a=!1;for(let l=0;lr.y!=s.y>r.y&&r.x<(s.x-o.x)*(r.y-o.y)/(s.y-o.y)+o.x&&(a=!a)}return a}function su(i,r){let n=!1;for(let o=0,s=i.length-1;or.y!=l.y>r.y&&r.x<(l.x-a.x)*(r.y-a.y)/(l.y-a.y)+a.x&&(n=!n)}return n}function sd(i,r,n,o,s){for(const a of i)if(r<=a.x&&n<=a.y&&o>=a.x&&s>=a.y)return!0;const l=[new u(r,n),new u(r,s),new u(o,s),new u(o,n)];if(i.length>2){for(const c of l)if(su(i,c))return!0}for(let h=0;hs.x&&r.x>s.x||i.ys.y&&r.y>s.y)return!1;const a=eu(i,r,n[0]);return a!==eu(i,r,n[1])||a!==eu(i,r,n[2])||a!==eu(i,r,n[3])}(i[h],i[h+1],l))return!0;return!1}function sp(i,r,n){const o=r.paint.get(i).value;return"constant"===o.kind?o.value:n.programConfigurations.get(r.id).getMaxValue(i)}function sf(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function sm(i,r,n,o,s){if(!r[0]&&!r[1])return i;const a=u.convert(r)._mult(s);"viewport"===n&&a._rotate(-o);const l=[];for(let c=0;c{var a,l;const c=R([],n,i),h=1/c[3]/r*s;return a=c,l=[h,h,o?1/c[3]:h,h],a[0]=c[0]*l[0],a[1]=c[1]*l[1],a[2]=c[2]*l[2],a[3]=c[3]*l[3],a}),l=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(i=>{const r=k([],D([],M([],a[i[0]],a[i[1]]),M([],a[i[2]],a[i[1]]))),n=-P(r,a[i[1]]);return r.concat(n)});return new sx(a,l)}}class sv{constructor(i,r){this.min=i,this.max=r,this.center=C([],I([],this.min,this.max),.5)}quadrant(i){const r=[i%2==0,i<2],n=T(this.min),o=T(this.max);for(let s=0;s=0;if(0===a)return 0;a!==r.length&&(n=!1)}if(n)return 2;for(let c=0;c<3;c++){let h=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let d=0;dthis.max[c]-this.min[c])return 0}return 1}}function sb(i,r,n,o,s,a,l,c,h){if(a&&i.queryGeometry.isAboveHorizon)return!1;for(const d of(a&&(h*=i.pixelToTileUnitsFactor),r))for(const p of d){var f;const m=p.add(c),_=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(m.x,m.y,!0):0,g=a?m:function(i,r,n){const o=R([],[i.x,i.y,r,1],n);return new u(o[0]/o[3],o[1]/o[3])}(m,_,o),y=a?i.tilespaceRays.map(i=>(function(i,r){const n=w();return sw[2]=r,i.intersectsPlane(sw,sT,n),new u(n[0],n[1])})(i,_)):i.queryGeometry.screenGeometry,x=R([],[p.x,p.y,_,1],o);if(!l&&a?h*=x[3]/n.cameraToCenterDistance:l&&!a&&(h*=n.cameraToCenterDistance/x[3]),f=h,su(y,g)||sl(g,y,f))return!0}return!1}const sw=S(0,0,0),sT=S(0,0,1);class sE extends sn{}function sS(i,{width:r,height:n},o,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==r*n*o)throw RangeError("mismatched image size")}else s=new Uint8Array(r*n*o);return i.width=r,i.height=n,i.data=s,i}function sI(i,{width:r,height:n},o){if(r===i.width&&n===i.height)return;const s=sS({},{width:r,height:n},o);sM(i,s,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,r),height:Math.min(i.height,n)},o),i.width=r,i.height=n,i.data=s.data}function sM(i,r,n,o,s,a){if(0===s.width||0===s.height)return r;if(s.width>i.width||s.height>i.height||n.x>i.width-s.width||n.y>i.height-s.height)throw RangeError("out of range source coordinates for image copy");if(s.width>r.width||s.height>r.height||o.x>r.width-s.width||o.y>r.height-s.height)throw RangeError("out of range destination coordinates for image copy");const l=i.data,c=r.data;for(let h=0;h{r[i.evaluationKey]=a;const l=i.expression.evaluate(r);s.data[n+o+0]=Math.floor(255*l.r/l.a),s.data[n+o+1]=Math.floor(255*l.g/l.a),s.data[n+o+2]=Math.floor(255*l.b/l.a),s.data[n+o+3]=Math.floor(255*l.a)};if(i.clips)for(let l=0,c=0;l=a.next.y&&a.next.y!==a.y){var u=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(u<=l&&u>h){if(h=u,u===l){if(c===a.y)return a;if(c===a.next.y)return a.next}s=a.x=a.x&&a.x>=f&&l!==a.x&&sN(cs.x||a.x===s.x&&(n=s,o=a,0>sj(n.prev,n,o.prev)&&0>sj(o.next,n,n.next))))&&(s=a,_=d)),a=a.next;while(a!==p)return s}(i,r);if(!n)return r;var o=sW(n,i),s=sO(n,n.next);return sO(o,o.next),r===n?s:r}(c[s],n),n.next);return n}(i,r,f,n)),i.length>80*n){o=a=i[0],s=l=i[1];for(var _=n;_a&&(a=c),h>l&&(l=h);u=0!==(u=Math.max(a-o,l-s))?1/u:0}return function i(r,n,o,s,a,l,c){if(r){!c&&l&&function(i,r,n,o){var s=i;do null===s.z&&(s.z=sV(s.x,s.y,r,n,o)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==i)s.prevZ.nextZ=null,s.prevZ=null,function(i){var r,n,o,s,a,l,c,h,u=1;do{for(n=i,i=null,a=null,l=0;n;){for(l++,o=n,c=0,r=0;r0||h>0&&o;)0!==c&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,c--):(s=o,o=o.nextZ,h--),a?a.nextZ=s:i=s,s.prevZ=a,a=s;n=o}a.nextZ=null,u*=2}while(l>1)}(s)}(r,s,a,l);for(var h,u,d=r;r.prev!==r.next;)if(h=r.prev,u=r.next,l?function(i,r,n,o){var s=i.prev,a=i.next;if(sj(s,i,a)>=0)return!1;for(var l=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,h=sV(s.x=h&&p&&p.z<=u;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0||(d=d.prevZ,p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==i.prev&&d!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&sj(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==i.prev&&p!==i.next&&sN(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&sj(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}(r,s,a,l):function(i){var r=i.prev,n=i.next;if(sj(r,i,n)>=0)return!1;for(var o=i.next.next;o!==i.prev;){if(sN(r.x,r.y,i.x,i.y,n.x,n.y,o.x,o.y)&&sj(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(r))n.push(h.i/o),n.push(r.i/o),n.push(u.i/o),sK(r),r=u.next,d=u.next;else if((r=u)===d){c?1===c?i(r=function(i,r,n){var o=i;do{var s=o.prev,a=o.next.next;!sG(s,a)&&sZ(s,o,o.next,a)&&sX(s,a)&&sX(a,s)&&(r.push(s.i/n),r.push(o.i/n),r.push(a.i/n),sK(o),sK(o.next),o=i=a),o=o.next}while(o!==i)return sO(o)}(sO(r),n,o),n,o,s,a,l,2):2===c&&function(r,n,o,s,a,l){var c=r;do{for(var h,u,d=c.next.next;d!==c.prev;){if(c.i!==d.i&&(h=c,u=d,h.next.i!==u.i&&h.prev.i!==u.i&&!function(i,r){var n=i;do{if(n.i!==i.i&&n.next.i!==i.i&&n.i!==r.i&&n.next.i!==r.i&&sZ(n,n.next,i,r))return!0;n=n.next}while(n!==i)return!1}(h,u)&&(sX(h,u)&&sX(u,h)&&function(i,r){var n=i,o=!1,s=(i.x+r.x)/2,a=(i.y+r.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&s<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==i)return o}(h,u)&&(sj(h.prev,h,u.prev)||sj(h,u.prev,u))||sG(h,u)&&sj(h.prev,h,h.next)>0&&sj(u.prev,u,u.next)>0))){var p=sW(c,d);return c=sO(c,c.next),p=sO(p,p.next),i(c,n,o,s,a,l),void i(p,n,o,s,a,l)}d=d.next}c=c.next}while(c!==r)}(r,n,o,s,a,l):i(sO(r),n,o,s,a,l,1);break}}}(f,m,n,o,s,u),m}function sF(i,r,n,o,s){var a,l;if(s===sJ(i,r,n,o)>0)for(a=r;a=r;a-=o)l=sH(a,i[a],i[a+1],l);return l&&sG(l,l.next)&&(sK(l),l=l.next),l}function sO(i,r){if(!i)return i;r||(r=i);var n,o=i;do if(n=!1,o.steiner||!sG(o,o.next)&&0!==sj(o.prev,o,o.next))o=o.next;else{if(sK(o),(o=r=o.prev)===o.next)break;n=!0}while(n||o!==r)return r}function sU(i,r){return i.x-r.x}function sV(i,r,n,o,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=32767*(i-n)*s)|i<<8))|i<<4))|i<<2))|i<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-o)*s)|r<<8))|r<<4))|r<<2))|r<<1))<<1}function sN(i,r,n,o,s,a,l,c){return(s-l)*(r-c)-(i-l)*(a-c)>=0&&(i-l)*(o-c)-(n-l)*(r-c)>=0&&(n-l)*(a-c)-(s-l)*(o-c)>=0}function sj(i,r,n){return(r.y-i.y)*(n.x-r.x)-(r.x-i.x)*(n.y-r.y)}function sG(i,r){return i.x===r.x&&i.y===r.y}function sZ(i,r,n,o){var s=sq(sj(i,r,n)),a=sq(sj(i,r,o)),l=sq(sj(n,o,i)),c=sq(sj(n,o,r));return s!==a&&l!==c||!(0!==s||!s$(i,n,r))||!(0!==a||!s$(i,o,r))||!(0!==l||!s$(n,i,o))||!(0!==c||!s$(n,r,o))}function s$(i,r,n){return r.x<=Math.max(i.x,n.x)&&r.x>=Math.min(i.x,n.x)&&r.y<=Math.max(i.y,n.y)&&r.y>=Math.min(i.y,n.y)}function sq(i){return i>0?1:i<0?-1:0}function sX(i,r){return 0>sj(i.prev,i,i.next)?sj(i,r,i.next)>=0&&sj(i,i.prev,r)>=0:0>sj(i,r,i.prev)||0>sj(i,i.next,r)}function sW(i,r){var n=new sY(i.i,i.x,i.y),o=new sY(r.i,r.x,r.y),s=i.next,a=r.prev;return i.next=r,r.prev=i,n.next=s,s.prev=n,o.next=n,n.prev=o,a.next=o,o.prev=a,o}function sH(i,r,n,o){var s=new sY(i,r,n);return o?(s.next=o.next,s.prev=o,o.next.prev=s,o.next=s):(s.prev=s,s.next=s),s}function sK(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function sY(i,r,n){this.i=i,this.x=r,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function sJ(i,r,n,o){for(var s=0,a=r,l=n-o;ar?1:0}function s1(i,r){let n,o;const s=i.length;if(s<=1)return[i];const a=[];for(let l=0;l1)for(let h=0;ho;){if(s-o>600){var l=s-o+1,c=n-o+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);i(r,n,Math.max(o,Math.floor(n-c*u/l+d)),Math.min(s,Math.floor(n+(l-c)*u/l+d)),a)}var p=r[n],f=o,m=s;for(sQ(r,o,n),a(r[s],p)>0&&sQ(r,o,s);fa(r[f],p);)f++;for(;a(r[m],p)>0;)m--}0===a(r[o],p)?sQ(r,o,m):sQ(r,++m,s),m<=n&&(o=m+1),n<=m&&(s=m-1)}}(u,r,1,d||u.length-1,s2||s0),a[h]=a[h].slice(0,r))}return a}function s2(i,r){return r.area-i.area}function s3(i,r,n){const o=n.patternDependencies;let s=!1;for(const a of r){const l=a.paint.get(`${i}-pattern`);l.isConstant()||(s=!0);const c=l.constantOr(null);c&&(s=!0,o[c.to]=!0,o[c.from]=!0)}return s}function s5(i,r,n,o,s){const a=s.patternDependencies;for(const l of r){const c=l.paint.get(`${i}-pattern`).value;if("constant"!==c.kind){let h=c.evaluate({zoom:o-1},n,{},s.availableImages),u=c.evaluate({zoom:o},n,{},s.availableImages),d=c.evaluate({zoom:o+1},n,{},s.availableImages);h=h&&h.name?h.name:h,u=u&&u.name?u.name:u,d=d&&d.name?d.name:d,a[h]=!0,a[u]=!0,a[d]=!0,n.patterns[l.id]={min:h,mid:u,max:d}}}return n}sR.deviation=function(i,r,n,o){var s=r&&r.length,a=Math.abs(sJ(i,0,s?r[0]*n:i.length,n));if(s)for(var l=0,c=r.length;l0&&n.holes.push(o+=i[s-1].length)}return n},sB.default=sR;class s4{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new nJ,this.indexArray=new oe,this.indexArray2=new oa,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.segments2=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("fill",this.layers,r);const s=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n,r.availableImages):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}for(const _ of(s&&a.sort((i,r)=>i.sortKey-r.sortKey),a)){const{geometry:g,index:y,sourceLayerIndex:x}=_;if(this.hasPattern){const v=s5("fill",this.layers,_,this.zoom,r);this.patternFeatures.push(v)}else this.addFeature(_,g,y,n,{},r.availableImages);r.featureIndex.insert(i[y].feature,g,y,x,this.index)}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,sL),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.indexBuffer2=i.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(i),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(i,r,n,o,s,a=[]){for(const l of s1(r,500)){let c=0;for(const h of l)c+=h.length;const u=this.segments.prepareSegment(c,this.layoutVertexArray,this.indexArray),d=u.vertexLength,p=[],f=[];for(const m of l){if(0===m.length)continue;m!==l[0]&&f.push(p.length/2);const _=this.segments2.prepareSegment(m.length,this.layoutVertexArray,this.indexArray2),g=_.vertexLength;this.layoutVertexArray.emplaceBack(m[0].x,m[0].y),this.indexArray2.emplaceBack(g+m.length-1,g),p.push(m[0].x),p.push(m[0].y);for(let y=1;y>3;r=1===o?i.readString():2===o?i.readFloat():3===o?i.readDouble():4===o?i.readVarint64():5===o?i.readVarint():6===o?i.readSVarint():7===o?i.readBoolean():null}return r}(n))}function ao(i,r,n){if(3===i){var o=new ar(n,n.readVarint()+n.pos);o.length&&(r[o.name]=o)}}at.types=["Unknown","Point","LineString","Polygon"],at.prototype.loadGeometry=function(){var i=this._pbf;i.pos=this._geometry;for(var r,n=i.readVarint()+i.pos,o=1,s=0,a=0,l=0,c=[];i.pos>3}if(s--,1===o||2===o)a+=i.readSVarint(),l+=i.readSVarint(),1===o&&(r&&c.push(r),r=[]),r.push(new u(a,l));else{if(7!==o)throw Error("unknown command "+o);r&&r.push(r[0].clone())}}return r&&c.push(r),c},at.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var r=i.readVarint()+i.pos,n=1,o=0,s=0,a=0,l=1/0,c=-1/0,h=1/0,u=-1/0;i.pos>3}if(o--,1===n||2===n)(s+=i.readSVarint())c&&(c=s),(a+=i.readSVarint())u&&(u=a);else if(7!==n)throw Error("unknown command "+n)}return[l,h,c,u]},at.prototype.toGeoJSON=function(i,r,n){var o,s,a=this.extent*Math.pow(2,n),l=this.extent*i,c=this.extent*r,h=this.loadGeometry(),u=at.types[this.type];function d(i){for(var r=0;r=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[i];var r=this._pbf.readVarint()+this._pbf.pos;return new at(this._pbf,r,this.extent,this._keys,this._values)};var as={VectorTile:function(i,r){this.layers=i.readFields(ao,{},r)},VectorTileFeature:at,VectorTileLayer:ar};const aa=as.VectorTileFeature.types;function al(i,r,n,o,s,a,l,c){i.emplaceBack((r<<1)+l,(n<<1)+a,(Math.floor(8192*o)<<1)+s,Math.round(c))}class ac{constructor(){this.acc=new u(0,0),this.polyCount=[]}startRing(i){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new u(i.x,i.y),this.max=new u(i.x,i.y))}append(i,r){this.currentPolyCount.edges++,this.acc._add(i);let n=!!this.borders;const o=this.min,s=this.max;i.xs.x&&(s.x=i.x,n=!0),i.ys.y&&(s.y=i.y,n=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),n&&this.checkBorderIntersection(i,r)}checkBorderIntersection(i,r){r.x<0!=i.x<0&&this.addBorderIntersection(0,io(r.y,i.y,(0-r.x)/(i.x-r.x))),r.x>8192!=i.x>8192&&this.addBorderIntersection(1,io(r.y,i.y,(8192-r.x)/(i.x-r.x))),r.y<0!=i.y<0&&this.addBorderIntersection(2,io(r.x,i.x,(0-r.y)/(i.y-r.y))),r.y>8192!=i.y>8192&&this.addBorderIntersection(3,io(r.x,i.x,(8192-r.y)/(i.y-r.y)))}addBorderIntersection(i,r){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 n=this.borders[i];rn[1]&&(n[1]=r)}processBorderOverlap(i,r){if(i.x===r.x){if(i.y===r.y)return;const n=0===i.x?0:1;this.addBorderIntersection(n,r.y),this.addBorderIntersection(n,i.y)}else{const o=0===i.y?2:3;this.addBorderIntersection(o,r.x),this.addBorderIntersection(o,i.x)}}centroid(){const i=this.polyCount.reduce((i,r)=>i+r.edges,0);return 0!==i?this.acc.div(i)._round():new u(0,0)}span(){return new u(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((i,r)=>i+ +(r[0]!==Number.MAX_VALUE),0)}}class ah{constructor(i){this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.hasPattern=!1,this.layoutVertexArray=new nQ,this.centroidVertexArray=new ow,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=i.enableTerrain}populate(i,r,n,o){for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of(this.features=[],this.hasPattern=s3("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(i){const r=Math.exp(Math.PI*(1-i.y/(1<i.x<=0)||l.every(i=>i.x>=8192)||l.every(i=>i.y<=0)||l.every(i=>i.y>=8192))continue;for(let p=0;p=1){const y=f[_-1];if((g.x!==y.x||!(g.x<0)&&!(g.x>8192))&&(g.y!==y.y||!(g.y<0)&&!(g.y>8192))){c&&c.append(g,y),d.vertexLength+4>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const x=g.sub(y)._perp(),v=x.x/(Math.abs(x.x)+Math.abs(x.y)),b=x.y>0?1:0,w=y.dist(g);m+w>32768&&(m=0),al(this.layoutVertexArray,g.x,g.y,v,b,0,0,m),al(this.layoutVertexArray,g.x,g.y,v,b,0,1,m),m+=w,al(this.layoutVertexArray,y.x,y.y,v,b,0,0,m),al(this.layoutVertexArray,y.x,y.y,v,b,0,1,m);const T=d.vertexLength;this.indexArray.emplaceBack(T,T+2,T+1),this.indexArray.emplaceBack(T+1,T+2,T+3),d.vertexLength+=4,d.primitiveLength+=2}}}}if(d.vertexLength+u>o0.MAX_VERTEX_ARRAY_LENGTH&&(d=this.segments.prepareSegment(u,this.layoutVertexArray,this.indexArray)),"Polygon"!==aa[i.type])continue;const E=[],S=[],I=d.vertexLength;for(let M=0;M0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const D=c.borders,L=this.featuresOnBorder.push(c)-1;for(let B=0;B<4;B++)D[B][0]!==Number.MAX_VALUE&&this.borders[B].push(L)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}sortBorders(){for(let i=0;i<4;i++)this.borders[i].sort((r,n)=>this.featuresOnBorder[r].borders[i][0]-this.featuresOnBorder[n].borders[i][0])}encodeCentroid(i,r,n=!0){let o,s;if(i){if(0!==i.y){const a=r.span()._mult(this.tileToMeter);o=(Math.max(i.x,1)<<3)+Math.min(7,Math.round(a.x/10)),s=(Math.max(i.y,1)<<3)+Math.min(7,Math.round(a.y/10))}else o=Math.ceil(7*(i.x+450)),s=0}else o=0,s=+n;let l=n?this.centroidVertexArray.length:r.vertexArrayOffset;for(const c of r.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*c.edges+c.top);for(let h=0;h<2*c.edges;h++)this.centroidVertexArray.emplace(l++,0,s),this.centroidVertexArray.emplace(l++,o,s);for(let u=0;ui.id),this.index=i.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new n0,this.layoutVertexArray2=new n1,this.indexArray=new oe,this.programConfigurations=new o$(i.layers,i.zoom),this.segments=new o0,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(i,r,n,o){this.hasPattern=s3("line",this.layers,r);const s=this.layers[0].layout.get("line-sort-key"),a=[];for(const{feature:l,id:c,index:h,sourceLayerIndex:u}of i){const d=this.layers[0]._featureFilter.needGeometry,p=si(l,d);if(!this.layers[0]._featureFilter.filter(new nk(this.zoom),p,n))continue;const f=s?s.evaluate(p,{},n):void 0,m={id:c,properties:l.properties,type:l.type,sourceLayerIndex:u,index:h,geometry:d?p.geometry:st(l,n,o),patterns:{},sortKey:f};a.push(m)}s&&a.sort((i,r)=>i.sortKey-r.sortKey);const{lineAtlas:_,featureIndex:g}=r,y=this.addConstantDashes(_);for(const x of a){const{geometry:v,index:b,sourceLayerIndex:w}=x;if(y&&this.addFeatureDashes(x,_),this.hasPattern){const T=s5("line",this.layers,x,this.zoom,r);this.patternFeatures.push(T)}else this.addFeature(x,v,b,n,_.positions,r.availableImages);g.insert(i[b].feature,v,b,w,this.index)}}addConstantDashes(i){let r=!1;for(const n of this.layers){const o=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"!==o.kind||"constant"!==s.kind)r=!0;else{const a=s.value,l=o.value;if(!l)continue;i.addDash(l.from,a),i.addDash(l.to,a),l.other&&i.addDash(l.other,a)}}return r}addFeatureDashes(i,r){const n=this.zoom;for(const o of this.layers){let s,a,l,c,h,u;const d=o.paint.get("line-dasharray").value,p=o.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===p.kind)continue;if("constant"===d.kind){const f=d.value;if(!f)continue;s=f.other||f.to,a=f.to,l=f.from}else s=d.evaluate({zoom:n-1},i),a=d.evaluate({zoom:n},i),l=d.evaluate({zoom:n+1},i);"constant"===p.kind?c=h=u=p.value:(c=p.evaluate({zoom:n-1},i),h=p.evaluate({zoom:n},i),u=p.evaluate({zoom:n+1},i)),r.addDash(s,c),r.addDash(a,h),r.addDash(l,u);const m=r.getKey(s,c),_=r.getKey(a,h),g=r.getKey(l,u);i.patterns[o.id]={min:m,mid:_,max:g}}}update(i,r,n,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(i,r,this.stateDependentLayers,n,o)}addFeatures(i,r,n,o){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,r,n,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(i){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=i.createVertexBuffer(this.layoutVertexArray2,ay)),this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,a_),this.indexBuffer=i.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(i),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(i){if(i.properties&&i.properties.hasOwnProperty("mapbox_clip_start")&&i.properties.hasOwnProperty("mapbox_clip_end"))return{start:+i.properties.mapbox_clip_start,end:+i.properties.mapbox_clip_end}}addFeature(i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(i,{}),h=l.get("line-cap").evaluate(i,{}),u=l.get("line-miter-limit"),d=l.get("line-round-limit");for(const p of(this.lineClips=this.lineFeatureClips(i),r))this.addLine(p,i,c,h,u,d);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,n,s,a,o)}addLine(i,r,n,o,s,a){let l,c,h,u,d;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let p=0;p=2&&i[m-1].equals(i[m-2]);)m--;let _=0;for(;_0;if(S&&x>_){const M=l.dist(c);if(M>2*g){const A=l.sub(l.sub(c)._mult(g/M)._round());this.updateDistance(c,A),this.addCurrentVertex(A,u,0,0,y),c=A}}const C=c&&h;let z=C?n:f?"butt":o;if(C&&"round"===z&&(Ts&&(z="bevel"),"bevel"===z&&(T>2&&(z="flipbevel"),T100)v=d.mult(-1);else{const k=T*u.add(d).mag()/u.sub(d).mag();v._perp()._mult(k*(I?-1:1))}this.addCurrentVertex(l,v,0,0,y),this.addCurrentVertex(l,v.mult(-1),0,0,y)}else if("bevel"===z||"fakeround"===z){const P=-Math.sqrt(T*T-1),D=I?P:0,L=I?0:P;if(c&&this.addCurrentVertex(l,u,D,L,y),"fakeround"===z){const B=Math.round(180*E/Math.PI/20);for(let R=1;R2*g){const j=l.add(h.sub(l)._mult(g/N)._round());this.updateDistance(l,j),this.addCurrentVertex(j,d,0,0,y),l=j}}}}addCurrentVertex(i,r,n,o,s,a=!1){const l=r.y*o-r.x,c=-r.y-r.x*o;this.addHalfVertex(i,r.x+r.y*n,r.y-r.x*n,a,!1,n,s),this.addHalfVertex(i,l,c,a,!0,-o,s)}addHalfVertex({x:i,y:r},n,o,s,a,l,c){this.layoutVertexArray.emplaceBack((i<<1)+(s?1:0),(r<<1)+(a?1:0),Math.round(63*n)+128,Math.round(63*o)+128,1+(0===l?0:l<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const h=c.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,h),c.primitiveLength++),a?this.e2=h:this.e1=h}updateScaledDistance(){if(this.lineClips){const i=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=i*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(i,r){this.distance+=i.dist(r),this.updateScaledDistance()}}r$("LineBucket",ab,{omit:["layers","patternFeatures"]});const aw=new n$({"line-cap":new nN(tr.layout_line["line-cap"]),"line-join":new nN(tr.layout_line["line-join"]),"line-miter-limit":new nV(tr.layout_line["line-miter-limit"]),"line-round-limit":new nV(tr.layout_line["line-round-limit"]),"line-sort-key":new nN(tr.layout_line["line-sort-key"])});var aT={paint:new n$({"line-opacity":new nN(tr.paint_line["line-opacity"]),"line-color":new nN(tr.paint_line["line-color"]),"line-translate":new nV(tr.paint_line["line-translate"]),"line-translate-anchor":new nV(tr.paint_line["line-translate-anchor"]),"line-width":new nN(tr.paint_line["line-width"]),"line-gap-width":new nN(tr.paint_line["line-gap-width"]),"line-offset":new nN(tr.paint_line["line-offset"]),"line-blur":new nN(tr.paint_line["line-blur"]),"line-dasharray":new nj(tr.paint_line["line-dasharray"]),"line-pattern":new nj(tr.paint_line["line-pattern"]),"line-gradient":new nZ(tr.paint_line["line-gradient"])}),layout:aw};const aE=new class extends nN{possiblyEvaluate(i,r){return r=new nk(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(i,r)}evaluate(i,r,n,o){return r=J({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(i,r,n,o)}}(aT.paint.properties["line-width"].specification);aE.useIntegerZoom=!0;const aS=nK([{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),aI=nK([{name:"a_projected_pos",components:3,type:"Float32"}],4);nK([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aM=nK([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),aA=nK([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);nK([{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 aC=nK([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),az=nK([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ak(i,r){const{expression:n}=r;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new nk(i+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:s}=n;let a=0;for(;a":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var aR=function(i,r,n,o,s){var a,l,c=8*s-o-1,h=(1<>1,d=-7,p=n?s-1:0,f=n?-1:1,m=i[r+p];for(p+=f,a=m&(1<<-d)-1,m>>=-d,d+=c;d>0;a=256*a+i[r+p],p+=f,d-=8);for(l=a&(1<<-d)-1,a>>=-d,d+=o;d>0;l=256*l+i[r+p],p+=f,d-=8);if(0===a)a=1-u;else{if(a===h)return l?NaN:1/0*(m?-1:1);l+=Math.pow(2,o),a-=u}return(m?-1:1)*l*Math.pow(2,a-o)},aF=function(i,r,n,o,s,a){var l,c,h,u=8*a-s-1,d=(1<>1,f=23===s?5960464477539062e-23:0,m=o?0:a-1,_=o?1:-1,g=r<0||0===r&&1/r<0?1:0;for(isNaN(r=Math.abs(r))||r===1/0?(c=isNaN(r)?1:0,l=d):(l=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-l))<1&&(l--,h*=2),(r+=l+p>=1?f/h:f*Math.pow(2,1-p))*h>=2&&(l++,h/=2),l+p>=d?(c=0,l=d):l+p>=1?(c=(r*h-1)*Math.pow(2,s),l+=p):(c=r*Math.pow(2,p-1)*Math.pow(2,s),l=0));s>=8;i[n+m]=255&c,m+=_,c/=256,s-=8);for(l=l<0;i[n+m]=255&l,m+=_,l/=256,u-=8);i[n+m-_]|=128*g};function aO(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}aO.Varint=0,aO.Fixed64=1,aO.Bytes=2,aO.Fixed32=5;var aU="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function aV(i){return i.type===aO.Bytes?i.readVarint()+i.pos:i.pos+1}function aN(i,r,n){var o=r<=16383?1:r<=2097151?2:r<=268435455?3:Math.floor(Math.log(r)/(7*Math.LN2));n.realloc(o);for(var s=n.pos-1;s>=i;s--)n.buf[s+o]=n.buf[s]}function aj(i,r){for(var n=0;n>>8,i[n+2]=r>>>16,i[n+3]=r>>>24}function aQ(i,r){return(i[r]|i[r+1]<<8|i[r+2]<<16)+(i[r+3]<<24)}function a0(i,r,n){r.glyphs=[],1===i&&n.readMessage(a1,r)}function a1(i,r,n){if(3===i){const{id:o,bitmap:s,width:a,height:l,left:c,top:h,advance:u}=n.readMessage(a2,{});r.glyphs.push({id:o,bitmap:new sA({width:a+6,height:l+6},s),metrics:{width:a,height:l,left:c,top:h,advance:u}})}else 4===i?r.ascender=n.readSVarint():5===i&&(r.descender=n.readSVarint())}function a2(i,r,n){1===i?r.id=n.readVarint():2===i?r.bitmap=n.readBytes():3===i?r.width=n.readVarint():4===i?r.height=n.readVarint():5===i?r.left=n.readSVarint():6===i?r.top=n.readSVarint():7===i&&(r.advance=n.readVarint())}function a3(i){let r=0,n=0;for(const o of i)r+=o.w*o.h,n=Math.max(n,o.w);i.sort((i,r)=>r.h-i.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(r/.95)),n),h:1/0}];let a=0,l=0;for(const c of i)for(let h=s.length-1;h>=0;h--){const u=s[h];if(!(c.w>u.w||c.h>u.h)){if(c.x=u.x,c.y=u.y,l=Math.max(l,c.y+c.h),a=Math.max(a,c.x+c.w),c.w===u.w&&c.h===u.h){const d=s.pop();h>3,a=this.pos;this.type=7&o,i(s,r,this),this.pos===a&&this.skip(o)}return r},readMessage:function(i,r){return this.readFields(i,r,this.readVarint()+this.pos)},readFixed32:function(){var i=aY(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=aQ(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aY(this.buf,this.pos+4);return this.pos+=8,i},readSFixed64:function(){var i=aY(this.buf,this.pos)+4294967296*aQ(this.buf,this.pos+4);return this.pos+=8,i},readFloat:function(){var i=aR(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=aR(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var r,n,o=this.buf;return r=127&(n=o[this.pos++]),n<128?r:(r|=(127&(n=o[this.pos++]))<<7,n<128?r:(r|=(127&(n=o[this.pos++]))<<14,n<128?r:(r|=(127&(n=o[this.pos++]))<<21,n<128?r:function(i,r,n){var o,s,a,l=n.buf;if(s=(112&(a=l[n.pos++]))>>4,a<128||(s|=(127&(a=l[n.pos++]))<<3,a<128)||(s|=(127&(a=l[n.pos++]))<<10,a<128)||(s|=(127&(a=l[n.pos++]))<<17,a<128)||(s|=(127&(a=l[n.pos++]))<<24,a<128)||(s|=(1&(a=l[n.pos++]))<<31,a<128))return o=s,r?4294967296*o+(i>>>0):4294967296*(o>>>0)+(i>>>0);throw Error("Expected varint not more than 10 bytes")}(r|=(15&(n=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?-((i+1)/2):i/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var i,r=this.readVarint()+this.pos,n=this.pos;return this.pos=r,r-n>=12&&aU?(i=this.buf,aU.decode(i.subarray(n,r))):function(i,r,n){for(var o="",s=r;s239?4:h>223?3:h>191?2:1;if(s+d>n)break;1===d?h<128&&(u=h):2===d?128==(192&(a=i[s+1]))&&(u=(31&h)<<6|63&a)<=127&&(u=null):3===d?(l=i[s+2],128==(192&(a=i[s+1]))&&128==(192&l)&&((u=(15&h)<<12|(63&a)<<6|63&l)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(l=i[s+2],c=i[s+3],128==(192&(a=i[s+1]))&&128==(192&l)&&128==(192&c)&&((u=(15&h)<<18|(63&a)<<12|(63&l)<<6|63&c)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,o+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),o+=String.fromCharCode(u),s+=d}return o}(this.buf,n,r)},readBytes:function(){var i=this.readVarint()+this.pos,r=this.buf.subarray(this.pos,i);return this.pos=i,r},readPackedVarint:function(i,r){if(this.type!==aO.Bytes)return i.push(this.readVarint(r));var n=aV(this);for(i=i||[];this.pos127;);else if(r===aO.Bytes)this.pos=this.readVarint()+this.pos;else if(r===aO.Fixed32)this.pos+=4;else{if(r!==aO.Fixed64)throw Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(i,r){this.writeVarint(i<<3|r)},realloc:function(i){for(var r=this.length||16;r268435455||i<0?function(i,r){var n,o,s,a,l,c,h;if(i>=0?(n=i%4294967296|0,o=i/4294967296|0):(o=~(-i/4294967296),4294967295^(n=~(-i%4294967296))?n=n+1|0:(n=0,o=o+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");r.realloc(10),s=n,(a=r).buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,s>>>=7,a.buf[a.pos++]=127&s|128,a.buf[a.pos]=127&(s>>>=7),l=o,c=r,h=(7&l)<<4,c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?-(2*i)-1:2*i)},writeBoolean:function(i){this.writeVarint(Boolean(i))},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var r=this.pos;this.pos=function(i,r,n){for(var o,s,a=0;a55295&&o<57344){if(!s){o>56319||a+1===r.length?(i[n++]=239,i[n++]=191,i[n++]=189):s=o;continue}if(o<56320){i[n++]=239,i[n++]=191,i[n++]=189,s=o;continue}o=s-55296<<10|o-56320|65536,s=null}else s&&(i[n++]=239,i[n++]=191,i[n++]=189,s=null);o<128?i[n++]=o:(o<2048?i[n++]=o>>6|192:(o<65536?i[n++]=o>>12|224:(i[n++]=o>>18|240,i[n++]=o>>12&63|128),i[n++]=o>>6&63|128),i[n++]=63&o|128)}return n}(this.buf,i,this.pos);var n=this.pos-r;n>=128&&aN(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeFloat:function(i){this.realloc(4),aF(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),aF(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var r=i.length;this.writeVarint(r),this.realloc(r);for(var n=0;n=128&&aN(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,r,n){this.writeTag(i,aO.Bytes),this.writeRawMessage(r,n)},writePackedVarint:function(i,r){r.length&&this.writeMessage(i,aj,r)},writePackedSVarint:function(i,r){r.length&&this.writeMessage(i,aG,r)},writePackedBoolean:function(i,r){r.length&&this.writeMessage(i,aq,r)},writePackedFloat:function(i,r){r.length&&this.writeMessage(i,aZ,r)},writePackedDouble:function(i,r){r.length&&this.writeMessage(i,a$,r)},writePackedFixed32:function(i,r){r.length&&this.writeMessage(i,aX,r)},writePackedSFixed32:function(i,r){r.length&&this.writeMessage(i,aW,r)},writePackedFixed64:function(i,r){r.length&&this.writeMessage(i,aH,r)},writePackedSFixed64:function(i,r){r.length&&this.writeMessage(i,aK,r)},writeBytesField:function(i,r){this.writeTag(i,aO.Bytes),this.writeBytes(r)},writeFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(i,r){this.writeTag(i,aO.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(i,r){this.writeTag(i,aO.Fixed64),this.writeSFixed64(r)},writeVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeVarint(r)},writeSVarintField:function(i,r){this.writeTag(i,aO.Varint),this.writeSVarint(r)},writeStringField:function(i,r){this.writeTag(i,aO.Bytes),this.writeString(r)},writeFloatField:function(i,r){this.writeTag(i,aO.Fixed32),this.writeFloat(r)},writeDoubleField:function(i,r){this.writeTag(i,aO.Fixed64),this.writeDouble(r)},writeBooleanField:function(i,r){this.writeVarintField(i,Boolean(r))}};class a5{constructor(i,{pixelRatio:r,version:n,stretchX:o,stretchY:s,content:a}){this.paddedRect=i,this.pixelRatio=r,this.stretchX=o,this.stretchY=s,this.content=a,this.version=n}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 a4{constructor(i,r){const n={},o={};this.haveRenderCallbacks=[];const s=[];this.addImages(i,n,s),this.addImages(r,o,s);const{w:a,h:l}=a3(s),c=new sC({width:a||1,height:l||1});for(const h in i){const u=i[h],d=n[h].paddedRect;sC.copy(u.data,c,{x:0,y:0},{x:d.x+1,y:d.y+1},u.data)}for(const p in r){const f=r[p],m=o[p].paddedRect,_=m.x+1,g=m.y+1,y=f.data.width,x=f.data.height;sC.copy(f.data,c,{x:0,y:0},{x:_,y:g},f.data),sC.copy(f.data,c,{x:0,y:x-1},{x:_,y:g-1},{width:y,height:1}),sC.copy(f.data,c,{x:0,y:0},{x:_,y:g+x},{width:y,height:1}),sC.copy(f.data,c,{x:y-1,y:0},{x:_-1,y:g},{width:1,height:x}),sC.copy(f.data,c,{x:0,y:0},{x:_+y,y:g},{width:1,height:x})}this.image=c,this.iconPositions=n,this.patternPositions=o}addImages(i,r,n){for(const o in i){const s=i[o],a={x:0,y:0,w:s.data.width+2,h:s.data.height+2};n.push(a),r[o]=new a5(a,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(o)}}patchUpdatedImages(i,r){for(const n in i.dispatchRenderCallbacks(this.haveRenderCallbacks),i.updatedImages)this.patchUpdatedImage(this.iconPositions[n],i.getImage(n),r),this.patchUpdatedImage(this.patternPositions[n],i.getImage(n),r)}patchUpdatedImage(i,r,n){if(!i||!r||i.version===r.version)return;i.version=r.version;const[o,s]=i.tl;n.update(r.data,void 0,{x:o,y:s})}}r$("ImagePosition",a5),r$("ImageAtlas",a4);const a6={horizontal:1,vertical:2,horizontalOnly:3};class a8{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(i,r){const n=new a8;return n.scale=i||1,n.fontStack=r,n}static forImage(i){const r=new a8;return r.imageName=i,r}}class a9{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(i,r){const n=new a9;for(let o=0;o=0&&o>=i&&le[this.text.charCodeAt(o)];o--)n--;this.text=this.text.substring(i,n),this.sectionIndex=this.sectionIndex.slice(i,n)}substring(i,r){const n=new a9;return n.text=this.text.substring(i,r),n.sectionIndex=this.sectionIndex.slice(i,r),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((i,r)=>Math.max(i,this.sections[r].scale),0)}addTextSection(i,r){this.text+=i.text,this.sections.push(a8.forText(i.scale,i.fontStack||r));const n=this.sections.length-1;for(let o=0;o=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function a7(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){let y;const x=a9.fromFeature(i,s);p===a6.vertical&&x.verticalizePunctuation(f);const{processBidirectionalText:v,processStyledBidirectionalText:b}=nz;if(v&&1===x.sections.length){y=[];const w=v(x.toString(),lo(x,u,a,r,o,m,_));for(const T of w){const E=new a9;E.text=T,E.sections=x.sections;for(let S=0;S0&&$>C&&(C=$)}else{const q=n[D.fontStack];if(!q)continue;q[B]&&(O=q[B]);const X=r[D.fontStack];if(!X)continue;const W=X.glyphs[B];if(!W)continue;if(F=W.metrics,V=8203!==B?24:0,y){const H=void 0!==X.ascender?Math.abs(X.ascender):0,K=void 0!==X.descender?Math.abs(X.descender):0,Y=(H+K)*R;z=0;let d=0;for(let p=0;p-n/2;){if(--l<0)return!1;c-=i[l].dist(a),a=i[l]}c+=i[l].dist(i[l+1]),l++;const h=[];let u=0;for(;co;)u-=h.shift().angleDelta;if(u>s)return!1;l++,c+=d.dist(p)}return!0}function lu(i){let r=0;for(let n=0;n=o&&f.x>=o||(p.x>=o?p=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round():f.x>=o&&(f=new u(o,p.y+(o-p.x)/(f.x-p.x)*(f.y-p.y))._round()),p.y>=s&&f.y>=s||(p.y>=s?p=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round():f.y>=s&&(f=new u(p.x+(s-p.y)/(f.y-p.y)*(f.x-p.x),s)._round()),c&&p.equals(c[c.length-1])||(c=[p],a.push(c)),c.push(f)))))}}return a}function lf(i,r,n,o,s,a,l,c,h){for(let u=r;u-1)a[++h]=c,l[h]=u,l[h+1]=1e20}for(let f=0,m=0;f{let o=this.entries[i];o||(o=this.entries[i]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=o.glyphs[r];if(void 0!==s)return void n(null,{stack:i,id:r,glyph:s});if(s=this._tinySDF(o,i,r))return o.glyphs[r]=s,void n(null,{stack:i,id:r,glyph:s});const a=Math.floor(r/256);if(256*a>65535)return void n(Error("glyphs > 65535 not supported"));if(o.ranges[a])return void n(null,{stack:i,id:r,glyph:s});let l=o.requests[a];l||(l=o.requests[a]=[],lg.loadGlyphRange(i,a,this.url,this.requestManager,(i,r)=>{if(r){for(const n in o.ascender=r.ascender,o.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+n)||(o.glyphs[+n]=r.glyphs[+n]);o.ranges[a]=!0}for(const s of l)s(i,r);delete o.requests[a]})),l.push((o,s)=>{o?n(o):s&&n(null,{stack:i,id:r,glyph:s.glyphs[r]||null})})},(i,n)=>{if(i)r(i);else if(n){const o={};for(const{stack:s,id:a,glyph:l}of n)void 0===o[s]&&(o[s]={}),void 0===o[s].glyphs&&(o[s].glyphs={}),o[s].glyphs[a]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},o[s].ascender=this.entries[s].ascender,o[s].descender=this.entries[s].descender;r(null,o)}})}_doesCharSupportLocalGlyph(i){return this.localGlyphMode!==l_.none&&(this.localGlyphMode===l_.all?!!this.localFontFamily:!!this.localFontFamily&&(nn(i)||na(i)||r4(i)||r6(i))||r5(i))}_tinySDF(i,r,n){const o=this.localFontFamily;if(!o||!this._doesCharSupportLocalGlyph(n))return;let s=i.tinySDF;if(!s){let a="400";/bold/i.test(r)?a="900":/medium/i.test(r)?a="500":/light/i.test(r)&&(a="200"),(s=i.tinySDF=new lg.TinySDF({fontFamily:o,fontWeight:a,fontSize:48,buffer:6,radius:16})).fontWeight=a}if(this.localGlyphs[s.fontWeight][n])return this.localGlyphs[s.fontWeight][n];const l=String.fromCharCode(n),{data:c,width:h,height:u,glyphWidth:d,glyphHeight:p,glyphLeft:f,glyphTop:m,glyphAdvance:_}=s.draw(l);return this.localGlyphs[s.fontWeight][n]={id:n,bitmap:new sA({width:h,height:u},c),metrics:{width:d/2,height:p/2,left:f/2,top:m/2-27,advance:_/2,localGlyph:!0}}}}function ly(i,r,n,o){const s=[],a=i.image,l=a.pixelRatio,c=a.paddedRect.w-2,h=a.paddedRect.h-2,d=i.right-i.left,p=i.bottom-i.top,f=a.stretchX||[[0,c]],m=a.stretchY||[[0,h]],_=(i,r)=>i+r[1]-r[0],g=f.reduce(_,0),y=m.reduce(_,0),x=c-g,v=h-y;let b=0,w=g,T=0,E=y,S=0,I=x,M=0,A=v;if(a.content&&o){const C=a.content;b=lx(f,0,C[0]),T=lx(m,0,C[1]),w=lx(f,C[0],C[2]),E=lx(m,C[1],C[3]),S=C[0]-b,M=C[1]-T,I=C[2]-C[0]-w,A=C[3]-C[1]-E}const z=(o,s,c,h)=>{const f=(o.stretch-b)/w*d+i.left,m=o.fixed-S-I*o.stretch/g,_=(s.stretch-T)/E*p+i.top,x=s.fixed-M-A*s.stretch/y,v=(c.stretch-b)/w*d+i.left,C=c.fixed-S-I*c.stretch/g,z=(h.stretch-T)/E*p+i.top,k=h.fixed-M-A*h.stretch/y,P=new u(f,_),D=new u(v,_),L=new u(v,z),B=new u(f,z),R=new u(m/l,x/l),F=new u(C/l,k/l),O=r*Math.PI/180;if(O){const U=Math.sin(O),V=Math.cos(O),N=[V,-U,U,V];P._matMult(N),D._matMult(N),B._matMult(N),L._matMult(N)}const j=o.stretch+o.fixed,G=s.stretch+s.fixed;return{tl:P,tr:D,bl:B,br:L,tex:{x:a.paddedRect.x+1+j,y:a.paddedRect.y+1+G,w:c.stretch+c.fixed-j,h:h.stretch+h.fixed-G},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:F,minFontScaleX:I/l/d,minFontScaleY:A/l/p,isSDF:n}};if(o&&(a.stretchX||a.stretchY)){const k=lv(f,x,g),P=lv(m,v,y);for(let D=0;D{if(i)s(i);else if(r){const n={},o=new aO(r).readFields(a0,{});for(const a of o.glyphs)n[a.id]=a;s(null,{glyphs:n,ascender:o.ascender,descender:o.descender})}})},lg.TinySDF=class{constructor({fontSize:i=24,buffer:r=3,radius:n=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:a="normal",fontStyle:l="normal"}){this.buffer=r,this.cutoff=o,this.radius=n;const c=this.size=i+4*r,h=this._createCanvas(c),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${l} ${a} ${i}px ${s}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(i){const r=document.createElement("canvas");return r.width=r.height=i,r}draw(i){const{width:r,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:a}=this.ctx.measureText(i),l=Math.floor(n),c=Math.min(this.size-this.buffer,Math.ceil(a-s)),h=Math.min(this.size-this.buffer,Math.ceil(n)+Math.ceil(o)),u=c+2*this.buffer,d=h+2*this.buffer,p=u*d,f=new Uint8ClampedArray(p),m={data:f,width:u,height:d,glyphWidth:c,glyphHeight:h,glyphTop:l,glyphLeft:0,glyphAdvance:r};if(0===c||0===h)return m;const{ctx:_,buffer:g,gridInner:y,gridOuter:x}=this;_.clearRect(g,g,c,h),_.fillText(i,g,g+l+1);const v=_.getImageData(g,g,c,h);x.fill(1e20,0,p),y.fill(0,0,p);for(let b=0;b0?S*S:0,y[E]=S<0?S*S:0}}lf(x,0,0,u,d,u,this.f,this.v,this.z),lf(y,g,g,c,h,u,this.f,this.v,this.z);for(let I=0;I0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const i=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:r,compare:n}=this,o=r[i];for(;i>0;){const s=i-1>>1,a=r[s];if(n(o,a)>=0)break;r[i]=a,i=s}r[i]=o}_down(i){const{data:r,compare:n}=this,o=this.length>>1,s=r[i];for(;in(r[c],l)&&(a=c,l=r[c]),n(l,s)>=0)break;r[i]=l,i=a}r[i]=s}}function lw(i,r){return ir?1:0}function lT(i,r){return r.max-i.max}function lE(i,r,n,o){this.p=new u(i,r),this.h=n,this.d=function(i,r){let n=!1,o=1/0;for(let s=0;si.y!=d.y>i.y&&i.x<(d.x-u.x)*(i.y-u.y)/(d.y-u.y)+u.x&&(n=!n),o=Math.min(o,sc(i,u,d))}}return(n?1:-1)*Math.sqrt(o)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}const lS=Number.POSITIVE_INFINITY,lI=Math.sqrt(2);function lM(i,r){return r[1]!==lS?function(i,r,n){let o=0,s=0;switch(r=Math.abs(r),n=Math.abs(n),i){case"top-right":case"top-left":case"top":s=n-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-n}switch(i){case"top-right":case"bottom-right":case"right":o=-r;break;case"top-left":case"bottom-left":case"left":o=r}return[o,s]}(i,r[0],r[1]):function(i,r){let n=0,o=0;r<0&&(r=0);const s=r/lI;switch(i){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-r;break;case"top":o=r-7}switch(i){case"top-right":case"bottom-right":n=-s;break;case"top-left":case"bottom-left":n=s;break;case"left":n=r;break;case"right":n=-r}return[n,o]}(i,r[0])}function lA(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function lC(i,r,n,o,s,a,l,c,h,d,p,f,m,_,g,y,x){const v=function(i,r,n,o,s,a,l,c){const h=[];if(0===r.positionedLines.length)return h;const d=o.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,p=function(i){const r=i[0],n=i[1],o=r*n;return o>0?[r,-n]:o<0?[-r,n]:0===r?[n,r]:[n,-r]}(n);let f=Math.abs(r.top-r.bottom);for(const m of r.positionedLines)f-=m.lineOffset;const _=r.positionedLines.length,g=f/_;let y=r.top-n[1];for(let x=0;x<_;++x){const v=r.positionedLines[x];for(const b of(y=function(i,r,n,o){const s=r+i.positionedLines[o].lineOffset;return 0===o?n+s/2:n+(s+(r+i.positionedLines[o-1].lineOffset))/2}(r,g,y,x),v.positionedGlyphs)){let w,T,E,S;if(!b.rect)continue;const I=b.rect||{};let M=4,A=!0,C=1,z=0;if(b.imageName){const k=l[b.imageName];if(!k)continue;if(k.sdf){eh("SDF images are not supported in formatted text and will be ignored.");continue}A=!1,M=1/(C=k.pixelRatio)}const P=(s||c)&&b.vertical,D=b.metrics.advance*b.scale/2,L=b.metrics,B=b.rect;if(null===B)continue;c&&r.verticalizable&&(z=b.imageName?D-b.metrics.width*b.scale/2:0);const R=s?[b.x+D,b.y]:[0,0];let F=[0,0],O=[0,0],U=!1;s||(P?(O=[b.x+D+p[0],b.y+p[1]-z],U=!0):F=[b.x+D+n[0],b.y+n[1]-z]);const V=B.w*b.scale/(C*(b.localGlyph?2:1)),N=B.h*b.scale/(C*(b.localGlyph?2:1));if(P){const j=b.y-y,G=new u(-D,D-j),Z=-Math.PI/2,$=new u(...O);(w=new u(-D+F[0],F[1]))._rotateAround(Z,G)._add($),w.x+=-j+D,w.y-=(L.left-M)*b.scale;const q=b.imageName?L.advance*b.scale:24*b.scale,X=String.fromCharCode(b.glyph);"︶"===X||"﹈"===X||"︸"===X||"﹄"===X||"﹂"===X||"︾"===X||"︼"===X||"︺"===X||"︘"===X||"﹀"===X||"︐"===X||"︓"===X||"︔"===X||"`"===X||" ̄"===X||"︑"===X||"︒"===X?w.x+=(1-M)*b.scale:"︵"===X||"﹇"===X||"︷"===X||"﹃"===X||"﹁"===X||"︽"===X||"︻"===X||"︹"===X||"︗"===X||"︿"===X?w.x+=q-L.height*b.scale+(-M-1)*b.scale:w.x+=b.imageName||L.width+2*M===B.w&&L.height+2*M===B.h?(q-N)/2:(q-(L.height+2*M)*b.scale)/2,T=new u(w.x,w.y-V),E=new u(w.x+N,w.y),S=new u(w.x+N,w.y-V)}else{const W=(L.left-M)*b.scale-D+F[0],H=(-L.top-M)*b.scale+F[1],K=W+V,Y=H+N;w=new u(W,H),T=new u(K,H),E=new u(W,Y),S=new u(K,Y)}if(d){let J;J=s?new u(0,0):U?new u(p[0],p[1]):new u(n[0],n[1]),w._rotateAround(d,J),T._rotateAround(d,J),E._rotateAround(d,J),S._rotateAround(d,J)}const Q=new u(0,0),ee=new u(0,0);h.push({tl:w,tr:T,bl:E,br:S,tex:I,writingMode:r.writingMode,glyphOffset:R,sectionIndex:b.sectionIndex,isSDF:A,pixelOffsetTL:Q,pixelOffsetBR:ee,minFontScaleX:0,minFontScaleY:0})}}return h}(0,o,h,a,l,c,s,i.allowVerticalPlacement),b=i.textSizeData;let w=null;for(const T of("source"===b.kind?(w=[128*a.layout.get("text-size").evaluate(c,{},x)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===b.kind&&((w=[128*g.compositeTextSizes[0].evaluate(c,{},x),128*g.compositeTextSizes[1].evaluate(c,{},x)])[0]>32640||w[1]>32640)&&eh(`${i.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),i.addSymbols(i.text,v,w,h,l,c,p,r,n,d.lineStartIndex,d.lineLength,_,y,x),f))m[T]=i.text.placedSymbolArray.length-1;return 4*v.length}function lz(i){for(const r in i)return i[r];return null}function lk(i,r,n,o,s,a,l,c,h,d){let p=l.top,f=l.bottom,m=l.left,_=l.right;const g=l.collisionPadding;if(g&&(m-=g[0],p-=g[1],_+=g[2],f+=g[3]),h){const y=new u(m,p),x=new u(_,p),v=new u(m,f),b=new u(_,f),w=h*N;let T=new u(0,0);d&&(T=new u(d[0],d[1])),y._rotateAround(w,T),x._rotateAround(w,T),v._rotateAround(w,T),b._rotateAround(w,T),m=Math.min(y.x,x.x,v.x,b.x),_=Math.max(y.x,x.x,v.x,b.x),p=Math.min(y.y,x.y,v.y,b.y),f=Math.max(y.y,x.y,v.y,b.y)}return i.emplaceBack(r.x,r.y,r.z,n.x,n.y,m,p,_,f,c,o,s,a),i.length-1}function lP(i){i.collisionPadding&&(i.top-=i.collisionPadding[1],i.bottom+=i.collisionPadding[3]);const r=i.bottom-i.top;return r>0?Math.max(10,r):null}const lD=as.VectorTileFeature.types,lL=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function lB(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=d?Math.min(32640,Math.round(d[0])):0,x=d?Math.min(32640,Math.round(d[1])):0;i.emplaceBack(r,n,Math.round(32*l),Math.round(32*c),h,u,(y<<1)+(p?1:0),x,16*f,16*m,256*_,256*g,o,s,a,0)}function lR(i,r,n){i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n),i.emplaceBack(r.x,r.y,n)}class lF{constructor(i){this.layoutVertexArray=new n5,this.indexArray=new oe,this.programConfigurations=i,this.segments=new o0,this.dynamicLayoutVertexArray=new n1,this.opacityVertexArray=new n4,this.placedSymbolArray=new of}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(i,r,n,o){this.isEmpty()||(n&&(this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,aS.members),this.indexBuffer=i.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=i.createVertexBuffer(this.dynamicLayoutVertexArray,aI.members,!0),this.opacityVertexBuffer=i.createVertexBuffer(this.opacityVertexArray,lL,!0),this.opacityVertexBuffer.itemSize=1),(n||o)&&this.programConfigurations.upload(i))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}r$("SymbolBuffers",lF);class lO{constructor(i,r,n){this.layoutVertexArray=new i,this.layoutAttributes=r,this.indexArray=new n,this.segments=new o0,this.collisionVertexArray=new n7,this.collisionVertexArrayExt=new n1}upload(i){this.layoutVertexBuffer=i.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=i.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=i.createVertexBuffer(this.collisionVertexArray,aM.members,!0),this.collisionVertexBufferExt=i.createVertexBuffer(this.collisionVertexArrayExt,aA.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}r$("CollisionBuffers",lO);class lU{constructor(i){this.collisionBoxArray=i.collisionBoxArray,this.zoom=i.zoom,this.overscaling=i.overscaling,this.layers=i.layers,this.layerIds=this.layers.map(i=>i.id),this.index=i.index,this.pixelRatio=i.pixelRatio,this.sourceLayerIndex=i.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=_([]),this.placementViewportMatrix=_([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ak(this.zoom,r["text-size"]),this.iconSizeData=ak(this.zoom,r["icon-size"]);const n=this.layers[0].layout,o=n.get("symbol-sort-key"),s=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&void 0!==o.constantOr(1),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(i=>a6[i]),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.sourceID=i.sourceID}createArrays(){this.text=new lF(new o$(this.layers,this.zoom,i=>/^text/.test(i))),this.icon=new lF(new o$(this.layers,this.zoom,i=>/^icon/.test(i))),this.glyphOffsetArray=new og,this.lineVertexArray=new oy,this.symbolInstances=new o_}calculateGlyphDependencies(i,r,n,o,s){for(let a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=r.iconDependencies,m=r.glyphDependencies,_=r.availableImages,g=new nk(this.zoom);for(const{feature:y,id:x,index:v,sourceLayerIndex:b}of i){let w,T;const E=s._featureFilter.needGeometry,S=si(y,E);if(!s._featureFilter.filter(g,S,n))continue;if(E||(S.geometry=st(y,n,o)),u){const I=s.getValueAndResolveTokens("text-field",S,n,_),M=tP.factory(I);(function(i){for(const r of i.sections)if(function(i){for(const r of i)if(ny(r.charCodeAt(0)))return!0;return!1}(r.text))return!0;return!1})(M)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===nA()||this.hasRTLText&&nz.isParsed())&&(w=function(i,r,n){return i.sections.forEach(i=>{i.text=function(i,r,n){const o=r.layout.get("text-transform").evaluate(n,{});return"uppercase"===o?i=i.toLocaleUpperCase():"lowercase"===o&&(i=i.toLocaleLowerCase()),nz.applyArabicShaping&&(i=nz.applyArabicShaping(i)),i}(i.text,r,n)}),i}(M,s,S))}if(d){const A=s.getValueAndResolveTokens("icon-image",S,n,_);T=A instanceof tD?A:tD.fromString(A)}if(!w&&!T)continue;const C=this.sortFeaturesByKey?p.evaluate(S,{},n):void 0;if(this.features.push({id:x,text:w,icon:T,index:v,sourceLayerIndex:b,geometry:S.geometry,properties:y.properties,type:lD[y.type],sortKey:C}),T&&(f[T.name]=!0),w){const z=l.evaluate(S,{},n).join(","),k="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");for(const P of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(a6.vertical)>=0,w.sections))if(P.image)f[P.image.name]=!0;else{const D=nm(w.toString()),L=P.fontStack||z,B=m[L]=m[L]||{};this.calculateGlyphDependencies(P.text,B,k,this.allowVerticalPlacement,D)}}}"line"===a.get("symbol-placement")&&(this.features=function(i){const r={},n={},o=[];let s=0;function a(r){o.push(i[r]),s++}function l(i,r,s){const a=n[i];return delete n[i],n[r]=a,o[a].geometry[0].pop(),o[a].geometry[0]=o[a].geometry[0].concat(s[0]),a}function c(i,n,s){const a=r[n];return delete r[n],r[i]=a,o[a].geometry[0].shift(),o[a].geometry[0]=s[0].concat(o[a].geometry[0]),a}function h(i,r,n){const o=n?r[0][r[0].length-1]:r[0][0];return`${i}:${o.x}:${o.y}`}for(let u=0;ui.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((i,r)=>i.sortKey-r.sortKey)}update(i,r,n,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(i,r,this.layers,n,o),this.icon.programConfigurations.updatePaintArrays(i,r,this.layers,n,o))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(i),this.iconCollisionBox.upload(i)),this.text.upload(i,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(i,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(i,r){const n=this.lineVertexArray.length;if(void 0!==i.segment){let o=i.dist(r[i.segment+1]),s=i.dist(r[i.segment]);const a={};for(let l=i.segment+1;l=0;c--)a[c]={x:r[c].x,y:r[c].y,tileUnitDistanceFromAnchor:s},c>0&&(s+=r[c-1].dist(r[c]));for(let h=0;h=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:o),a=aP(this.textSizeData,i,s)/24;return this.tilePixelRatio*a}getSymbolInstanceIconSize(i,r,n){const o=this.icon.placedSymbolArray.get(n),s=aP(this.iconSizeData,i,o);return this.tilePixelRatio*s}_commitDebugCollisionVertexUpdate(i,r,n){i.emplaceBack(r,-n,-n),i.emplaceBack(r,n,-n),i.emplaceBack(r,n,n),i.emplaceBack(r,-n,n)}_updateTextDebugCollisionBoxes(i,r,n,o,s,a){for(let l=o;l0}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(i,r){const n=i.placedSymbolArray.get(r),o=n.vertexStartIndex+4*n.numGlyphs;for(let s=n.vertexStartIndex;so[i]-o[r]||s[r]-s[i]),a}addToSortKeyRanges(i,r){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===r?n.symbolInstanceEnd=i+1:this.sortKeyRanges.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:i+1})}sortFeatures(i){if(this.sortFeaturesByY&&this.sortedAngle!==i&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const r of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(i),this.sortedAngle=i,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const n=this.symbolInstances.get(r);this.featureSortOrder.push(n.featureIndex),[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((i,r,n)=>{i>=0&&n.indexOf(i)===r&&this.addIndicesForPlacedSymbol(this.text,i)}),n.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,n.verticalPlacedTextSymbolIndex),n.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.placedIconSymbolIndex),n.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,n.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}r$("SymbolBucket",lU,{omit:["layers","collisionBoxArray","features","compareText"]}),lU.MAX_GLYPHS=65535,lU.addDynamicAttributes=lR;const lV=new n$({"symbol-placement":new nV(tr.layout_symbol["symbol-placement"]),"symbol-spacing":new nV(tr.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new nV(tr.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nN(tr.layout_symbol["symbol-sort-key"]),"symbol-z-order":new nV(tr.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new nV(tr.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new nV(tr.layout_symbol["icon-ignore-placement"]),"icon-optional":new nV(tr.layout_symbol["icon-optional"]),"icon-rotation-alignment":new nV(tr.layout_symbol["icon-rotation-alignment"]),"icon-size":new nN(tr.layout_symbol["icon-size"]),"icon-text-fit":new nV(tr.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nV(tr.layout_symbol["icon-text-fit-padding"]),"icon-image":new nN(tr.layout_symbol["icon-image"]),"icon-rotate":new nN(tr.layout_symbol["icon-rotate"]),"icon-padding":new nV(tr.layout_symbol["icon-padding"]),"icon-keep-upright":new nV(tr.layout_symbol["icon-keep-upright"]),"icon-offset":new nN(tr.layout_symbol["icon-offset"]),"icon-anchor":new nN(tr.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new nV(tr.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new nV(tr.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new nV(tr.layout_symbol["text-rotation-alignment"]),"text-field":new nN(tr.layout_symbol["text-field"]),"text-font":new nN(tr.layout_symbol["text-font"]),"text-size":new nN(tr.layout_symbol["text-size"]),"text-max-width":new nN(tr.layout_symbol["text-max-width"]),"text-line-height":new nN(tr.layout_symbol["text-line-height"]),"text-letter-spacing":new nN(tr.layout_symbol["text-letter-spacing"]),"text-justify":new nN(tr.layout_symbol["text-justify"]),"text-radial-offset":new nN(tr.layout_symbol["text-radial-offset"]),"text-variable-anchor":new nV(tr.layout_symbol["text-variable-anchor"]),"text-anchor":new nN(tr.layout_symbol["text-anchor"]),"text-max-angle":new nV(tr.layout_symbol["text-max-angle"]),"text-writing-mode":new nV(tr.layout_symbol["text-writing-mode"]),"text-rotate":new nN(tr.layout_symbol["text-rotate"]),"text-padding":new nV(tr.layout_symbol["text-padding"]),"text-keep-upright":new nV(tr.layout_symbol["text-keep-upright"]),"text-transform":new nN(tr.layout_symbol["text-transform"]),"text-offset":new nN(tr.layout_symbol["text-offset"]),"text-allow-overlap":new nV(tr.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new nV(tr.layout_symbol["text-ignore-placement"]),"text-optional":new nV(tr.layout_symbol["text-optional"])});var lN={paint:new n$({"icon-opacity":new nN(tr.paint_symbol["icon-opacity"]),"icon-color":new nN(tr.paint_symbol["icon-color"]),"icon-halo-color":new nN(tr.paint_symbol["icon-halo-color"]),"icon-halo-width":new nN(tr.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nN(tr.paint_symbol["icon-halo-blur"]),"icon-translate":new nV(tr.paint_symbol["icon-translate"]),"icon-translate-anchor":new nV(tr.paint_symbol["icon-translate-anchor"]),"text-opacity":new nN(tr.paint_symbol["text-opacity"]),"text-color":new nN(tr.paint_symbol["text-color"],{runtimeType:tm,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new nN(tr.paint_symbol["text-halo-color"]),"text-halo-width":new nN(tr.paint_symbol["text-halo-width"]),"text-halo-blur":new nN(tr.paint_symbol["text-halo-blur"]),"text-translate":new nV(tr.paint_symbol["text-translate"]),"text-translate-anchor":new nV(tr.paint_symbol["text-translate-anchor"])}),layout:lV};class lj{constructor(i){this.type=i.property.overrides?i.property.overrides.runtimeType:tu,this.defaultValue=i}evaluate(i){if(i.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(i.formattedSection))return r.getOverride(i.formattedSection)}return i.feature&&i.featureState?this.defaultValue.evaluate(i.feature,i.featureState):this.defaultValue.property.specification.default}eachChild(i){this.defaultValue.isConstant()||i(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}r$("FormatSectionOverride",lj,{omit:["defaultValue"]});class lG extends oY{constructor(i){super(i,lN)}recalculate(i,r){super.recalculate(i,r),"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 n=this.layout.get("text-writing-mode");if(n){const o=[];for(const s of n)0>o.indexOf(s)&&o.push(s);this.layout._values["text-writing-mode"]=o}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(i,r,n,o){var s;const a=this.layout.get(i).evaluate(r,{},n,o),l=this._unevaluatedLayout._values[i];return l.isDataDriven()||i8(l.value)||!a?a:(s=r.properties,a.replace(/{([^{}]+)}/g,(i,r)=>r in s?String(s[r]):""))}createBucket(i){return new lU(i)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const i of lN.paint.overridableProperties){if(!lG.hasPaintOverride(this.layout,i))continue;const r=this.paint.get(i),n=new lj(r),o=new i6(n,r.property.specification);let s=null;s="constant"===r.value.kind||"source"===r.value.kind?new i7("source",o):new re("composite",o,r.value.zoomStops,r.value._interpolationType),this.paint._values[i]=new nO(r.property,s,r.parameters)}}_handleOverridablePaintPropertyUpdate(i,r,n){return!(!this.layout||r.isDataDriven()||n.isDataDriven())&&lG.hasPaintOverride(this.layout,i)}static hasPaintOverride(i,r){const n=i.get("text-field"),o=lN.paint.properties[r];let s=!1;const a=i=>{for(const r of i)if(o.overrides&&o.overrides.hasOverride(r))return void(s=!0)};if("constant"===n.value.kind&&n.value.value instanceof tP)a(n.value.value.sections);else if("source"===n.value.kind){const l=i=>{s||(i instanceof tO&&tR(i.value)===tx?a(i.value.sections):i instanceof tj?a(i.sections):i.eachChild(l))},c=n.value;c._styleExpression&&l(c._styleExpression.expression)}return s}getProgramConfiguration(i){return new oZ(this,i)}}var lZ={paint:new n$({"background-color":new nV(tr.paint_background["background-color"]),"background-pattern":new nG(tr.paint_background["background-pattern"]),"background-opacity":new nV(tr.paint_background["background-opacity"])})},l$={paint:new n$({"raster-opacity":new nV(tr.paint_raster["raster-opacity"]),"raster-hue-rotate":new nV(tr.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new nV(tr.paint_raster["raster-brightness-min"]),"raster-brightness-max":new nV(tr.paint_raster["raster-brightness-max"]),"raster-saturation":new nV(tr.paint_raster["raster-saturation"]),"raster-contrast":new nV(tr.paint_raster["raster-contrast"]),"raster-resampling":new nV(tr.paint_raster["raster-resampling"]),"raster-fade-duration":new nV(tr.paint_raster["raster-fade-duration"])})};class lq extends oY{constructor(i){super(i,{}),this.implementation=i}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(i){this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)}onRemove(i){this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)}}var lX={paint:new n$({"sky-type":new nV(tr.paint_sky["sky-type"]),"sky-atmosphere-sun":new nV(tr.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new nV(tr.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new nV(tr.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new nV(tr.paint_sky["sky-gradient-radius"]),"sky-gradient":new nZ(tr.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new nV(tr.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new nV(tr.paint_sky["sky-atmosphere-color"]),"sky-opacity":new nV(tr.paint_sky["sky-opacity"])})};function lW(i,r,n){var o,s,a,l,c,h,u,d;const p=S(0,0,1),f=O(F());return o=f,s=(n?-(i*N)+Math.PI:i*N)*.5,a=f[0],l=f[1],c=f[2],h=f[3],u=Math.sin(s),d=Math.cos(s),o[0]=a*d-c*u,o[1]=l*d+h*u,o[2]=c*d+a*u,o[3]=h*d-l*u,U(f,f,-(r*N)),B(p,p,f),k(p,p)}const lH={circle:class extends oY{constructor(i){super(i,sy)}createBucket(i){return new sn(i)}queryRadius(i){return sp("circle-radius",this,i)+sp("circle-stroke-width",this,i)+sf(this.paint.get("circle-translate"))}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=s_(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(r,n)+this.paint.get("circle-stroke-width").evaluate(r,n);return sb(i,o,a,l,c,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getProgramConfiguration(i){return new oZ(this,i)}},heatmap:class extends oY{createBucket(i){return new sE(i)}constructor(i){super(i,sz),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){"heatmap-color"===i&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sk({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(i){return sp("heatmap-radius",this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c){const h=this.paint.get("heatmap-radius").evaluate(r,n);return sb(i,o,a,l,c,!0,!0,new u(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(i){return new oZ(this,i)}},hillshade:class extends oY{constructor(i){super(i,sP)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(i){return new oZ(this,i)}},fill:class extends oY{constructor(i){super(i,s8)}getProgramIds(){const i=this.paint.get("fill-pattern"),r=i&&i.constantOr(1),n=[r?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(r&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(i){return new oZ(this,i)}recalculate(i,r){super.recalculate(i,r);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new s4(i)}queryRadius(){return sf(this.paint.get("fill-translate"))}queryIntersectsFeature(i,r,n,o,s,a){return!i.queryGeometry.isAboveHorizon&&ss(sm(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),o)}isTileClipped(){return!0}},"fill-extrusion":class extends oY{constructor(i){super(i,au)}createBucket(i){return new ah(i)}queryRadius(){return sf(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(i){return new oZ(this,i)}queryIntersectsFeature(i,r,n,o,s,a,l,c,h){var d,p;const f=s_(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),m=this.paint.get("fill-extrusion-height").evaluate(r,n),_=this.paint.get("fill-extrusion-base").evaluate(r,n),g=[0,0],y=c&&a.elevation,x=a.elevation?a.elevation.exaggeration():1;if(y){const v=i.tile.getBucket(this).centroidVertexArray,b=h+1;if(b0?n+2*r:r),s=sp("line-offset",this,i);return o/2+Math.abs(s)+sf(this.paint.get("line-translate"))}queryIntersectsFeature(i,r,n,o,s,a){var l,c;if(i.queryGeometry.isAboveHorizon)return!1;const h=sm(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,i.pixelToTileUnitsFactor),d=i.pixelToTileUnitsFactor/2*(l=this.paint.get("line-width").evaluate(r,n),(c=this.paint.get("line-gap-width").evaluate(r,n))>0?c+2*l:l),p=this.paint.get("line-offset").evaluate(r,n);return p&&(o=function(i,r){const n=[],o=new u(0,0);for(let s=0;s=3){for(let a=0;a1){if(sa(i,r))return!0;for(let o=0;o1&&(c=i[++l]);const d=Math.abs(h-c.left),p=Math.abs(h-c.right),f=Math.min(d,p),m=s/n*(o+1);if(c.isDash){const _=o-Math.abs(m);u=Math.sqrt(f*f+_*_)}else u=o-Math.sqrt(f*f+m*m);this.image.data[a+h]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(i,r){for(let n=i.length-1;n>=0;--n){const o=i[n],s=i[n+1];o.zeroLength?i.splice(n,1):s&&s.isDash===o.isDash&&(s.left=o.left,i.splice(n,1))}const a=i[0],l=i[i.length-1];a.isDash===l.isDash&&(a.left=l.left-this.width,l.right=a.right+this.width);const c=this.width*this.nextRow;let h=0,u=i[0];for(let d=0;d1&&(u=i[++h]);const p=Math.abs(d-u.left),f=Math.abs(d-u.right),m=Math.min(p,f);this.image.data[c+d]=Math.max(0,Math.min(255,(u.isDash?m:-m)+r+128))}}addDash(i,r){const n=this.getKey(i,r);if(this.positions[n])return this.positions[n];const o="round"===r,s=o?7:0,a=2*s+1;if(this.nextRow+a>this.height)return eh("LineAtlas out of space"),null;0===i.length&&i.push(1);let l=0;for(let c=0;c{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=()=>{}}}const l5=p.performance;function l4(i){const r=i?i.url.toString():void 0;return l5.getEntriesByName(r)}class l6{constructor(){this.tasks={},this.taskQueue=[],en(["process"],this),this.invoker=new l3(this.process),this.nextId=0}add(i,r){const n=this.nextId++,o=function({type:i,isSymbolTile:r,zoom:n}){return n=n||0,"message"===i?0:"maybePrepare"!==i||r?"parseTile"!==i||r?"parseTile"===i&&r?300-n:"maybePrepare"===i&&r?400-n:500:200-n:100-n}(r);return 0===o?(ed(),i(),{cancel(){}}):(this.tasks[n]={fn:i,metadata:r,priority:o,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}})}process(){ed();{if(this.taskQueue=this.taskQueue.filter(i=>!!this.tasks[i]),!this.taskQueue.length)return;const i=this.pick();if(null===i)return;const r=this.tasks[i];if(delete this.tasks[i],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}}pick(){let i=null,r=1/0;for(let n=0;n0;a--)s+=(r&(o=1<this.canonical.z?new ce(i,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ce(i,this.wrap,i,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(i,r=!0){if(this.overscaledZ===i&&r)return this.key;if(i>this.canonical.z)return ct(this.wrap*+r,i,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-i;return ct(this.wrap*+r,i,i,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(i){if(i.wrap!==this.wrap)return!1;const r=this.canonical.z-i.canonical.z;return 0===i.overscaledZ||i.overscaledZ>r&&i.canonical.y===this.canonical.y>>r}children(i){if(this.overscaledZ>=i)return[new ce(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,n=2*this.canonical.x,o=2*this.canonical.y;return[new ce(r,this.wrap,r,n,o),new ce(r,this.wrap,r,n+1,o),new ce(r,this.wrap,r,n,o+1),new ce(r,this.wrap,r,n+1,o+1)]}isLessThan(i){return this.wrapi.wrap)&&(this.overscaledZi.overscaledZ)&&(this.canonical.xi.canonical.x)&&this.canonical.yMath.abs(o[l])){if(n[l]r[l])return null}else{const c=1/o[l];let h=(i[l]-n[l])*c,u=(r[l]-n[l])*c;if(h>u){const d=h;h=u,u=d}if(h>s&&(s=h),ua)return null}return s}function cu(i,r,n,o,s,a,l,c,h,u,d){const p=o-i,f=s-r,m=a-n,_=l-i,g=c-r,y=h-n,x=d[1]*y-d[2]*g,v=d[2]*_-d[0]*y,b=d[0]*g-d[1]*_,w=p*x+f*v+m*b;if(1e-15>Math.abs(w))return null;const T=1/w,E=u[0]-i,S=u[1]-r,I=u[2]-n,M=(E*x+S*v+I*b)*T;if(M<0||M>1)return null;const A=S*m-I*f,C=I*p-E*m,z=E*f-S*p,k=(d[0]*A+d[1]*C+d[2]*z)*T;return k<0||M+k>1?null:(_*A+g*C+y*z)*T}function cd(i,r,n,o,s,a,l,c,h){const u=1<{const a=o?1:0;s[0]=i*n,s[1]=r*n,s[2]=(i+1)*n-a,s[3]=(r+1)*n-a};let l=new cc(o);const c=[];for(let h=0;h=1;o/=2){const m=n[n.length-1];l=new cc(o);for(let _=0;_0;){const{idx:m,t:_,nodex:g,nodey:y,depth:x}=f.pop();if(this.leaves[m]){cd(g,y,x,i,r,n,o,d,p);const v=1<=B[2])return _}continue}let R=0;for(let F=0;F=h[u[V]]&&(u.splice(V,0,F),U=!0);U||(u[R]=F),R++}}for(let N=0;N=this.dim+1||r<-1||r>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(i+1)}_unpackMapbox(i,r,n){return(256*i*256+256*r+n)/10-1e4}_unpackTerrarium(i,r,n){return 256*i+r+n/256-32768}static pack(i,r){const n=[0,0,0,0],o=cg.getUnpackVector(r);let s=Math.floor((i+o[3])/o[2]);return n[2]=s%256,s=Math.floor(s/256),n[1]=s%256,s=Math.floor(s/256),n[0]=s,n}getPixels(){return new sC({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,r,n){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let o=r*this.dim,s=r*this.dim+this.dim,a=n*this.dim,l=n*this.dim+this.dim;switch(r){case -1:o=s-1;break;case 1:s=o+1}switch(n){case -1:a=l-1;break;case 1:l=a+1}const c=-r*this.dim,h=-n*this.dim;for(let u=a;u{this.remove(i,s)},n)),this.data[o].push(s),this.order.push(o),this.order.length>this.max){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const r=this.data[i].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),r.value}getByKey(i){const r=this.data[i];return r?r[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,r){if(!this.has(i))return this;const n=i.wrapped().key,o=void 0===r?0:this.data[n].indexOf(r),s=this.data[n][o];return this.data[n].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(s.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(i){const r=[];for(const n in this.data)for(const o of this.data[n])i(o.value)||r.push(o);for(const s of r)this.remove(s.value.tileID,s)}}class cx extends ti{constructor(i,r,n){super(),this.id=i,this._onlySymbols=n,r.on("data",i=>{"source"===i.dataType&&"metadata"===i.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===i.dataType&&"content"===i.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new cy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new cl}onAdd(i){this.map=i,this._minTileCacheSize=i?i._minTileCacheSize:null,this._maxTileCacheSize=i?i._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles){const r=this._tiles[i];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(i,r){return i.isSymbolTile=this._onlySymbols,this._source.loadTile(i,r)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i,()=>{})}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i,()=>{})}serialize(){return this._source.serialize()}prepare(i){for(const r in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const n=this._tiles[r];n.upload(i),n.prepare(this.map.style.imageManager)}}getIds(){return Y(this._tiles).map(i=>i.tileID).sort(cv).map(i=>i.key)}getRenderableIds(i){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,i)&&r.push(this._tiles[n]);return i?r.sort((i,r)=>{const n=i.tileID,o=r.tileID,s=new u(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),a=new u(o.canonical.x,o.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(i=>i.tileID.key):r.map(i=>i.tileID).sort(cv).map(i=>i.key)}hasRenderableParent(i){const r=this.findLoadedParent(i,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(i,r){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(r||!this._tiles[i].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const i in this._cache.reset(),this._tiles)"errored"!==this._tiles[i].state&&this._reloadTile(+i,"reloading")}_reloadTile(i,r){const n=this._tiles[i];n&&("loading"!==n.state&&(n.state=r),this._loadTile(n,this._tileLoaded.bind(this,n,i,r)))}_tileLoaded(i,r,n,o){if(o){if(i.state="errored",404!==o.status)this._source.fire(new tt(o,{tile:i}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const s=this.map.painter.terrain;this.update(this.transform,s.getScaledDemTileSize(),!0),s.resetTileLookupCache(this.id)}else this.update(this.transform)}else i.timeAdded=ev.now(),"expired"===n&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(r,i),"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null),this._source.fire(new te("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id}))}_backfillDEM(i){const r=this.getRenderableIds();for(let n=0;n1||(Math.abs(n)>1&&(1===Math.abs(n+s)?n+=s:1===Math.abs(n-s)&&(n-=s)),r.dem&&i.dem&&(i.dem.backfillBorder(r.dem,n,o),i.neighboringTiles&&i.neighboringTiles[a]&&(i.neighboringTiles[a].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,r,n,o){for(const s in this._tiles){let a=this._tiles[s];if(o[s]||!a.hasData()||a.tileID.overscaledZ<=r||a.tileID.overscaledZ>n)continue;let l=a.tileID;for(;a&&a.tileID.overscaledZ>r+1;){const c=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[c.key])&&a.hasData()&&(l=c)}let h=l;for(;h.overscaledZ>r;)if(i[(h=h.scaledTo(h.overscaledZ-1)).key]){o[l.key]=l;break}}}findLoadedParent(i,r){if(i.key in this._loadedParentTiles){const n=this._loadedParentTiles[i.key];return n&&n.tileID.overscaledZ>=r?n:null}for(let o=i.overscaledZ-1;o>=r;o--){const s=i.scaledTo(o),a=this._getLoadedTile(s);if(a)return a}}_getLoadedTile(i){const r=this._tiles[i.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,r){r=r||this._source.tileSize;const n=Math.ceil(i.width/r)+1,o=Math.ceil(i.height/r)+1,s=Math.floor(n*o*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,l="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(l)}handleWrapJump(i){const r=Math.round((i-(void 0===this._prevLng?i:this._prevLng))/360);if(this._prevLng=i,r){const n={};for(const o in this._tiles){const s=this._tiles[o];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+r),n[s.tileID.key]=s}for(const a in this._tiles=n,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const l in this._tiles)this._setTileReloadTimer(+l,this._tiles[l])}}update(i,r,n){let o;if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;this.updateCacheSize(i,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(i=>new ce(i.canonical.z,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y)):(o=i.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter(i=>this._source.hasTile(i)))):o=[];const s=this._updateRetainedTiles(o);if(cb(this._source.type)&&0!==o.length){const a={},l={},c=Object.keys(s);for(const h of c){const u=s[h],d=this._tiles[h];if(!d||d.fadeEndTime&&d.fadeEndTime<=ev.now())continue;const p=this.findLoadedParent(u,Math.max(u.overscaledZ-cx.maxOverzooming,this._source.minzoom));p&&(this._addTile(p.tileID),a[p.tileID.key]=p.tileID),l[h]=u}const f=o[o.length-1].overscaledZ;for(const m in this._tiles){const _=this._tiles[m];if(s[m]||!_.hasData())continue;let g=_.tileID;for(;g.overscaledZ>f;){g=g.scaledTo(g.overscaledZ-1);const y=this._tiles[g.key];if(y&&y.hasData()&&l[g.key]){s[m]=_.tileID;break}}}for(const x in a)s[x]||(this._coveredTiles[x]=!0,s[x]=a[x])}for(const v in s)this._tiles[v].clearFadeHold();const b=function(i,r){const n=[];for(const o in i)o in r||n.push(o);return n}(this._tiles,s);for(const w of b){const T=this._tiles[w];T.hasSymbolBuckets&&!T.holdingForFade()?T.setHoldDuration(this.map._fadeDuration):T.hasSymbolBuckets&&!T.symbolFadeFinished()||this._removeTile(+w)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const r={};if(0===i.length)return r;const n={},o=i.reduce((i,r)=>Math.min(i,r.overscaledZ),1/0),s=i[0].overscaledZ,a=Math.max(s-cx.maxOverzooming,this._source.minzoom),l=Math.max(s+cx.maxUnderzooming,this._source.minzoom),c={};for(const h of i){const u=this._addTile(h);r[h.key]=h,u.hasData()||o=this._source.maxzoom){const f=d.children(this._source.maxzoom)[0],m=this.getTile(f);if(m&&m.hasData()){r[f.key]=f;continue}}else{const _=d.children(this._source.maxzoom);if(r[_[0].key]&&r[_[1].key]&&r[_[2].key]&&r[_[3].key])continue}let g=p.wasRequested();for(let y=d.overscaledZ-1;y>=a;--y){const x=d.scaledTo(y);if(n[x.key]||(n[x.key]=!0,(p=this.getTile(x))||!g||(p=this._addTile(x)),p&&(r[x.key]=x,g=p.wasRequested(),p.hasData())))break}}return r}_updateLoadedParentTileCache(){for(const i in this._loadedParentTiles={},this._tiles){const r=[];let n,o=this._tiles[i].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){n=this._loadedParentTiles[o.key];break}r.push(o.key);const s=o.scaledTo(o.overscaledZ-1);if(n=this._getLoadedTile(s))break;o=s}for(const a of r)this._loadedParentTiles[a]=n}}_addTile(i){let r=this._tiles[i.key];if(r)return r;(r=this._cache.getAndRemove(i))&&(this._setTileReloadTimer(i.key,r),r.tileID=i,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,r)));const n=Boolean(r);if(!n){const o=this.map?this.map.painter:null,s="raster"===this._source.type||"raster-dem"===this._source.type;r=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,o,s),this._loadTile(r,this._tileLoaded.bind(this,r,i.key,r.state))}return r?(r.uses++,this._tiles[i.key]=r,n||this._source.fire(new te("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(i,r){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const n=r.getExpiryTimeout();n&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},n))}_removeTile(i){const r=this._tiles[i];r&&(r.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),r.uses>0||(r.hasData()&&"reloading"!==r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){for(const i in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+i);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(i,r,n){const o=[],s=this.transform;if(!s)return o;for(const a in this._tiles){const l=this._tiles[a];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;const c=i.containsTile(l,s,r);c&&o.push(c)}return o}getVisibleCoordinates(i){const r=this.getRenderableIds(i).map(i=>this._tiles[i].tileID);for(const n of r)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(cb(this._source.type))for(const i in this._tiles){const r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=ev.now())return!0}return!1}setFeatureState(i,r,n){this._state.updateState(i=i||"_geojsonTileLayer",r,n)}removeFeatureState(i,r,n){this._state.removeFeatureState(i=i||"_geojsonTileLayer",r,n)}getFeatureState(i,r){return this._state.getState(i=i||"_geojsonTileLayer",r)}setDependencies(i,r,n){const o=this._tiles[i];o&&o.setDependencies(r,n)}reloadTilesForDependencies(i,r){for(const n in this._tiles)this._tiles[n].hasDependency(i,r)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(i,r))}_preloadTiles(i,r){const n=new Map,o=Array.isArray(i)?i:[i],s=this.map.painter.terrain,a=this.usedForTerrain&&s?s.getScaledDemTileSize():this._source.tileSize;for(const l of o){const c=l.coveringTiles({tileSize:a,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const h of c)n.set(h.key,h);this.usedForTerrain&&l.updateElevation(!1)}const u=Array.from(n.values()),d="raster"===this._source.type||"raster-dem"===this._source.type;K(u,(i,r)=>{const n=new c$(i,this._source.tileSize*i.overscaleFactor(),this.transform.tileZoom,this.map.painter,d);this._loadTile(n,i=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),r(i,n)})},r)}}function cv(i,r){const n=Math.abs(2*i.wrap)-+(i.wrap<0),o=Math.abs(2*r.wrap)-+(r.wrap<0);return i.overscaledZ-r.overscaledZ||o-n||r.canonical.y-i.canonical.y||r.canonical.x-i.canonical.x}function cb(i){return"raster"===i||"image"===i||"video"===i}cx.maxOverzooming=10,cx.maxUnderzooming=3;class cw{constructor(i,r,n){this._demTile=i,this._dem=this._demTile.dem,this._scale=r,this._offset=n}static create(i,r,n){const o=n||i.findDEMTileFor(r);if(!o||!o.dem)return;const s=o.dem,a=o.tileID,l=1<=0&&d[3]>=0&&c.insert(l,d[0],d[1],d[2],d[3])}}loadVTLayers(){if(!this.vtLayers)for(const i in this.vtLayers=new as.VectorTile(new aO(this.rawTileData)).layers,this.sourceLayerCoder=new cs(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[i]=[];return this.vtLayers}query(i,r,n,o){let s;this.loadVTLayers();const a=i.params||{},l=rh(a.filter),c=i.tileResult,h=i.transform,u=c.bufferedTilespaceBounds,d=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(i,r,n,o)=>sd(c.bufferedTilespaceGeometry,i,r,n,o));d.sort(cS);let p=null;h.elevation&&d.length>0&&(p=cw.create(h.elevation,this.tileID));const f={};for(let m=0;m(y||(y=st(r,this.tileID.canonical,i.tileTransform)),n.queryIntersectsFeature(c,r,o,y,this.z,i.transform,i.pixelPosMatrix,p,s)))}return f}loadMatchingFeature(i,r,n,o,s,a,l,c,h){const{featureIndex:u,bucketIndex:d,sourceLayerIndex:p,layoutVertexArrayOffset:f}=r,m=this.bucketLayerIDs[d];if(o&&!function(i,r){for(let n=0;n=0)return!0;return!1}(o,m))return;const _=this.sourceLayerCoder.decode(p),g=this.vtLayers[_].feature(u);if(n.needGeometry){const y=si(g,!0);if(!n.filter(new nk(this.tileID.overscaledZ),y,this.tileID.canonical))return}else if(!n.filter(new nk(this.tileID.overscaledZ),g))return;const x=this.getId(g,_);for(let v=0;vo.indexOf(b))continue;const w=a[b];if(!w)continue;let T={};void 0!==x&&c&&(T=c.getState(w.sourceLayer||"_geojsonTileLayer",x));const E=J({},l[b]);E.paint=cE(E.paint,w.paint,g,T,s),E.layout=cE(E.layout,w.layout,g,T,s);const S=!h||h(g,w,T,f);if(!S)continue;const I=new ca(g,this.z,this.x,this.y,x);I.layer=E;let M=i[b];void 0===M&&(M=i[b]=[]),M.push({featureIndex:u,feature:I,intersectionZ:S})}}lookupSymbolFeatures(i,r,n,o,s,a,l,c){const h={};this.loadVTLayers();const u=rh(s);for(const d of i)this.loadMatchingFeature(h,{bucketIndex:n,sourceLayerIndex:o,featureIndex:d,layoutVertexArrayOffset:0},u,a,l,c,r);return h}loadFeature(i){const{featureIndex:r,sourceLayerIndex:n}=i;this.loadVTLayers();const o=this.sourceLayerCoder.decode(n),s=this.vtFeatures[o];if(s[r])return s[r];const a=this.vtLayers[o].feature(r);return s[r]=a,a}hasLayer(i){for(const r of this.bucketLayerIDs)for(const n of r)if(i===n)return!0;return!1}getId(i,r){let n=i.id;return this.promoteId&&"boolean"==typeof(n=i.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[r]])&&(n=Number(n)),n}}function cE(i,r,n,o,s){return es(i,(i,a)=>{const l=r instanceof nU?r.get(a):null;return l&&l.evaluate?l.evaluate(n,o,s):l})}function cS(i,r){return r-i}r$("FeatureIndex",cT,{omit:["rawTileData","sourceLayerCoder"]});var cI=nK([{name:"a_pos",type:"Int16",components:2}]);const cM=new Uint16Array(8184);for(let cA=0;cA<2046;cA++){let cC=cA+2,cz=0,ck=0,cP=0,cD=0,cL=0,cB=0;for(1&cC?cP=cD=cL=32:cz=ck=cB=32;(cC>>=1)>1;){const cR=cz+cP>>1,cF=ck+cD>>1;1&cC?(cP=cz,cD=ck,cz=cL,ck=cB):(cz=cP,ck=cD,cP=cL,cD=cB),cL=cR,cB=cF}const cO=4*cA;cM[cO+0]=cz,cM[cO+1]=ck,cM[cO+2]=cP,cM[cO+3]=cD}const cU=new Uint16Array(2178),cV=new Uint8Array(1089),cN=new Uint16Array(1089);function cj(i){return 0===i?-.03125:32===i?.03125:0}var cG=nK([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const cZ={type:2,extent:8192,loadGeometry:()=>[[new u(0,0),new u(8193,0),new u(8193,8193),new u(0,8193),new u(0,0)]]};class c${constructor(i,r,n,o,s){this.tileID=i,this.uid=ee(),this.uses=0,this.tileSize=r,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,this.expiredRequestCount=0,this.state="loading",o&&o.transform&&(this.projection=o.transform.projection)}registerFadeDuration(i){const r=i+this.timeAdded;rr.getLayer(i)).filter(Boolean);if(0!==s.length)for(const a of(o.layers=s,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(i=>s.filter(r=>r.id===i)[0])),s))n[a.id]=o}return n}(i.buckets,r.style),this.hasSymbolBuckets=!1,this.buckets){const s=this.buckets[o];if(s instanceof lU){if(this.hasSymbolBuckets=!0,!n)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const l=this.buckets[a];if(l instanceof lU&&l.hasRTLText){this.hasRTLText=!0,nz.isLoading()||nz.isLoaded()||"deferred"!==nA()||nC();break}}for(const c in this.queryPadding=0,this.buckets){const h=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(c).queryRadius(h))}i.imageAtlas&&(this.imageAtlas=i.imageAtlas),i.glyphAtlasImage&&(this.glyphAtlasImage=i.glyphAtlasImage),i.lineAtlas&&(this.lineAtlas=i.lineAtlas)}else this.collisionBoxArray=new od}unloadVectorData(){if(this.hasData()){for(const i in this.buckets)this.buckets[i].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(i){return this.buckets[i.id]}upload(i){for(const r in this.buckets){const n=this.buckets[r];n.uploadPending()&&n.upload(i)}const o=i.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l1(i,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l1(i,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new l1(i,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(i){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(i,this.imageAtlasTexture)}queryRenderedFeatures(i,r,n,o,s,a,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:o,pixelPosMatrix:l,transform:a,params:s,tileTransform:this.tileTransform},i,r,n):{}}querySourceFeatures(i,r){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const o=n.loadVTLayers(),s=r?r.sourceLayer:"",a=o._geojsonTileLayer||o[s];if(!a)return;const l=rh(r&&r.filter),{z:c,x:h,y:u}=this.tileID.canonical,d={z:c,x:h,y:u};for(let p=0;po)s=!1;else if(r){if(this.expirationTime=0;d--){const p=4*d,f=cM[p+0],m=cM[p+1],_=cM[p+2],g=cM[p+3],y=f+_>>1,x=m+g>>1,v=y+x-m,b=x+f-y,w=33*m+f,T=33*g+_,E=33*x+y,S=Math.hypot((cU[2*w+0]+cU[2*T+0])/2-cU[2*E+0],(cU[2*w+1]+cU[2*T+1])/2-cU[2*E+1])>=16;if(cV[E]=cV[E]||(S?1:0),d<1022){const I=(m+b>>1)*33+(f+v>>1),M=(g+b>>1)*33+(_+v>>1);cV[E]=cV[E]||cV[I]||cV[M]}}const A=new nQ,C=new oe;let z=0;function k(i,r){const n=33*r+i;return 0===cN[n]&&(A.emplaceBack(cU[2*n+0],cU[2*n+1],8192*i/32,8192*r/32),cN[n]=++z),cN[n]-1}function P(i,r,n,o,s,a){const l=i+n>>1,c=r+o>>1;if(Math.abs(i-s)+Math.abs(r-a)>1&&cV[33*c+l])P(s,a,i,r,l,c),P(n,o,s,a,l,c);else{const h=k(i,r),u=k(n,o),d=k(s,a);C.emplaceBack(h,u,d)}}return P(0,0,32,32,32,0),P(32,32,0,0,0,32),{vertices:A,indices:C}}(this.tileID.canonical,r);n=a.vertices,o=a.indices}else{for(const{x:l,y:c}of(n=new nQ,o=new oe,s))n.emplaceBack(l,c,0,0);const h=sB(n.int16,void 0,4);for(let u=0;u{const o=65*n+r;i.emplaceBack(o+1,o,o+65),i.emplaceBack(o+65,o+65+1,o+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}getWirefameBuffer(i){if(!this.wireframeSegments){const r=this._createWireframeGrid();this.wireframeIndexBuffer=i.createIndexBuffer(r),this.wireframeSegments=o0.simpleSegment(0,0,4096,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const i=new oa,r=(r,n)=>{const o=65*n+r;i.emplaceBack(o,o+1),i.emplaceBack(o,o+65),i.emplaceBack(o,o+65+1)};for(let n=0;n<64;n++)for(let o=0;o<64;o++)r(o,n);return i}}function c8(i,r){if(!r.isReprojectedInTileSpace)return{scale:1<b&&(w(i,u,o,s,c,h),w(u,n,c,h,a,l))}w(p,f,o,a,s,a),w(f,m,s,a,s,l),w(m,_,s,l,o,l),w(_,p,o,l,o,a),g-=b,y-=b,x+=b,v+=b;const T=1/Math.max(x-g,v-y);return{scale:T,x:g*T,y:y*T,x2:x*T,y2:v*T,projection:r}}class c9{constructor(i){const r={},n=[];for(const o in i){const s=i[o],a=r[o]={};for(const l in s.glyphs){const c=s.glyphs[+l];if(!c||0===c.bitmap.width||0===c.bitmap.height)continue;const h=c.metrics.localGlyph?2:1,u={x:0,y:0,w:c.bitmap.width+2*h,h:c.bitmap.height+2*h};n.push(u),a[l]=u}}const{w:d,h:p}=a3(n),f=new sA({width:d||1,height:p||1});for(const m in i){const _=i[m];for(const g in _.glyphs){const y=_.glyphs[+g];if(!y||0===y.bitmap.width||0===y.bitmap.height)continue;const x=r[m][g],v=y.metrics.localGlyph?2:1;sA.copy(y.bitmap,f,{x:0,y:0},{x:x.x+v,y:x.y+v},y.bitmap)}}this.image=f,this.positions=r}}r$("GlyphAtlas",c9);class c7{constructor(i){this.tileID=new ce(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),this.tileZoom=i.tileZoom,this.uid=i.uid,this.zoom=i.zoom,this.canonical=i.tileID.canonical,this.pixelRatio=i.pixelRatio,this.tileSize=i.tileSize,this.source=i.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=i.showCollisionBoxes,this.collectResourceTiming=!!i.collectResourceTiming,this.returnDependencies=!!i.returnDependencies,this.promoteId=i.promoteId,this.enableTerrain=!!i.enableTerrain,this.isSymbolTile=i.isSymbolTile,this.tileTransform=c8(i.tileID.canonical,i.projection),this.projection=i.projection}parse(i,r,n,o,s){let a,l,c,h;this.status="parsing",this.data=i,this.collisionBoxArray=new od;const d=new cs(Object.keys(i.layers).sort()),p=new cT(this.tileID,this.promoteId);p.bucketLayerIDs=[];const f={},m=new l2(256,256),_={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:n},g=r.familiesBySource[this.source];for(const y in g){const x=i.layers[y];if(!x)continue;let v=!1,b=!1;for(const w of g[y])"symbol"===w[0].type?v=!0:b=!0;if(!0===this.isSymbolTile&&!v||!1===this.isSymbolTile&&!b)continue;1===x.version&&eh(`Vector tile source "${this.source}" layer "${y}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const T=d.encode(y),E=[];for(let S=0;S=C.maxzoom||"none"!==C.visibility&&(he(A,this.zoom,n),(f[C.id]=C.createBucket({index:p.bucketLayerIDs.length,layers:A,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:T,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:n})).populate(E,_,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(A.map(i=>i.id)))}}m.trim();const z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},k=es(_.glyphDependencies,i=>Object.keys(i).map(Number));Object.keys(k).length?o.send("getGlyphs",{uid:this.uid,stacks:k},(i,r)=>{a||(a=i,l=r,L.call(this))},void 0,!1,z):l={};const P=Object.keys(_.iconDependencies);P.length?o.send("getImages",{icons:P,source:this.source,tileID:this.tileID,type:"icons"},(i,r)=>{a||(a=i,c=r,L.call(this))},void 0,!1,z):c={};const D=Object.keys(_.patternDependencies);function L(){if(a)return s(a);if(l&&c&&h){const i=new c9(l),r=new a4(c,h);for(const o in f){const d=f[o];d instanceof lU?(he(d.layers,this.zoom,n),function(i,r,n,o,s,a,l,c,h,d){i.createArrays(),i.tilePixelRatio=8192/(512*i.overscaling),i.compareText={},i.iconsNeedLinear=!1;const p=i.layers[0].layout,f=i.layers[0]._unevaluatedLayout._values,m={};if("composite"===i.textSizeData.kind){const{minZoom:_,maxZoom:g}=i.textSizeData;m.compositeTextSizes=[f["text-size"].possiblyEvaluate(new nk(_),c),f["text-size"].possiblyEvaluate(new nk(g),c)]}if("composite"===i.iconSizeData.kind){const{minZoom:y,maxZoom:x}=i.iconSizeData;m.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new nk(y),c),f["icon-size"].possiblyEvaluate(new nk(x),c)]}m.layoutTextSize=f["text-size"].possiblyEvaluate(new nk(h+1),c),m.layoutIconSize=f["icon-size"].possiblyEvaluate(new nk(h+1),c),m.textMaxSize=f["text-size"].possiblyEvaluate(new nk(18),c);const v="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),b=p.get("text-size");for(const w of i.features){const T=p.get("text-font").evaluate(w,{},c).join(","),E=b.evaluate(w,{},c),S=m.layoutTextSize.evaluate(w,{},c),I=(m.layoutIconSize.evaluate(w,{},c),{horizontal:{},vertical:void 0}),M=w.text;let A,C=[0,0];if(M){const z=M.toString(),k=24*p.get("text-letter-spacing").evaluate(w,{},c),P=24*p.get("text-line-height").evaluate(w,{},c),D=!function(i){for(const r of i){var n;if(rJ(n=r.charCodeAt(0))||rQ(n)||r0(n)||nc(n)||np(n))return!1}return!0}(z)?0:k,L=p.get("text-anchor").evaluate(w,{},c),B=p.get("text-variable-anchor");if(!B){const R=p.get("text-radial-offset").evaluate(w,{},c);C=R?lM(L,[24*R,lS]):p.get("text-offset").evaluate(w,{},c).map(i=>24*i)}let F=v?"center":p.get("text-justify").evaluate(w,{},c);const O=p.get("symbol-placement"),U="point"===O,V="point"===O?24*p.get("text-max-width").evaluate(w,{},c):0,j=o=>{i.allowVerticalPlacement&&nm(z)&&(I.vertical=a7(M,r,n,s,T,V,P,L,o,D,C,a6.vertical,!0,O,S,E))};if(!v&&B){const G="auto"===F?B.map(i=>lA(i)):[F];let Z=!1;for(let $=0;$=0||!nm(z)){const W=a7(M,r,n,s,T,V,P,L,F,D,C,a6.horizontal,!1,O,S,E);W&&(I.horizontal[F]=W)}j("point"===O?"left":F)}}let H=!1;if(w.icon&&w.icon.name){const K=o[w.icon.name];K&&(A=function(i,r,n){const{horizontalAlign:o,verticalAlign:s}=ls(n),a=r[0]-i.displaySize[0]*o,l=r[1]-i.displaySize[1]*s;return{image:i,top:l,bottom:l+i.displaySize[1],left:a,right:a+i.displaySize[0]}}(s[w.icon.name],p.get("icon-offset").evaluate(w,{},c),p.get("icon-anchor").evaluate(w,{},c)),H=K.sdf,void 0===i.sdfIcons?i.sdfIcons=K.sdf:i.sdfIcons!==K.sdf&&eh("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(K.pixelRatio!==i.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(i.iconsNeedLinear=!0))}const Y=lz(I.horizontal)||I.vertical;i.iconsInText||(i.iconsInText=!!Y&&Y.iconsInText),(Y||A)&&function(i,r,n,o,s,a,l,c,h,d,p,f,m){let _,g=a.textMaxSize.evaluate(r,{},f);void 0===g&&(g=l);const y=i.layers[0].layout,x=y.get("icon-offset").evaluate(r,{},f),v=lz(n.horizontal)||n.vertical,b=l/24,w=i.tilePixelRatio*g/24,T=i.tilePixelRatio*y.get("symbol-spacing"),E=y.get("text-padding")*i.tilePixelRatio,S=y.get("icon-padding")*i.tilePixelRatio,I=y.get("text-max-angle")*N,M="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),A="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),C=y.get("symbol-placement"),z=T/2,k=y.get("icon-text-fit");o&&"none"!==k&&(i.allowVerticalPlacement&&n.vertical&&(_=ll(o,n.vertical,k,y.get("icon-text-fit-padding"),x,b)),v&&(o=ll(o,v,k,y.get("icon-text-fit-padding"),x,b)));const P=(l,c,u)=>{if(c.x<0||c.x>=8192||c.y<0||c.y>=8192)return;const{x:g,y:y,z:v}=m.projectTilePoint(c.x,c.y,u),b=new lc(g,y,v,0,void 0);!function(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I){const M=i.addToLineVertexArray(r,o);let A,C,z,k,P,D,L,B=0,R=0,F=0,O=0,U=-1,V=-1;const N={};let j=oM(""),G=0,Z=0;if(void 0===h._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=h.layout.get("text-offset").evaluate(w,{},I).map(i=>24*i):(G=24*h.layout.get("text-radial-offset").evaluate(w,{},I),Z=lS),i.allowVerticalPlacement&&s.vertical){const $=s.vertical;if(_)D=lP($),c&&(L=lP(c));else{const q=h.layout.get("text-rotate").evaluate(w,{},I)+90;z=lk(u,n,r,d,p,f,$,m,q,g),c&&(k=lk(u,n,r,d,p,f,c,x,q))}}if(a){const X=h.layout.get("icon-rotate").evaluate(w,{},I),W="none"!==h.layout.get("icon-text-fit"),H=ly(a,X,E,W),K=c?ly(c,X,E,W):void 0;C=lk(u,n,r,d,p,f,a,x,X),B=4*H.length;const Y=i.iconSizeData;let J=null;"source"===Y.kind?(J=[128*h.layout.get("icon-size").evaluate(w,{},I)])[0]>32640&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Y.kind&&((J=[128*T.compositeIconSizes[0].evaluate(w,{},I),128*T.compositeIconSizes[1].evaluate(w,{},I)])[0]>32640||J[1]>32640)&&eh(`${i.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),i.addSymbols(i.icon,H,J,b,v,w,!1,n,r,M.lineStartIndex,M.lineLength,-1,S,I),U=i.icon.placedSymbolArray.length-1,K&&(R=4*K.length,i.addSymbols(i.icon,K,J,b,v,w,a6.vertical,n,r,M.lineStartIndex,M.lineLength,-1,S,I),V=i.icon.placedSymbolArray.length-1)}for(const Q in s.horizontal){const ee=s.horizontal[Q];A||(j=oM(ee.text),_?P=lP(ee):A=lk(u,n,r,d,p,f,ee,m,h.layout.get("text-rotate").evaluate(w,{},I),g));const et=1===ee.positionedLines.length;if(F+=lC(i,n,r,ee,l,h,_,w,g,M,s.vertical?a6.horizontal:a6.horizontalOnly,et?Object.keys(s.horizontal):[Q],N,U,T,S,I),et)break}s.vertical&&(O+=lC(i,n,r,s.vertical,l,h,_,w,g,M,a6.vertical,["vertical"],N,V,T,S,I));let ei=-1;const er=(i,r)=>i?Math.max(i,r):r;ei=er(P,ei),ei=er(D,ei),ei=er(L,ei);const en=ei>-1?1:0;i.glyphOffsetArray.length>=lU.MAX_GLYPHS&&eh("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&i.addToSortKeyRanges(i.symbolInstances.length,w.sortKey),i.symbolInstances.emplaceBack(n.x,n.y,n.z,r.x,r.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,U,V,j,void 0!==A?A:i.collisionBoxArray.length,void 0!==A?A+1:i.collisionBoxArray.length,void 0!==z?z:i.collisionBoxArray.length,void 0!==z?z+1:i.collisionBoxArray.length,void 0!==C?C:i.collisionBoxArray.length,void 0!==C?C+1:i.collisionBoxArray.length,k||i.collisionBoxArray.length,k?k+1:i.collisionBoxArray.length,d,F,O,B,R,en,0,G,Z,ei)}(i,c,b,l,n,o,s,_,i.layers[0],i.collisionBoxArray,r.index,r.sourceLayerIndex,i.index,E,M,h,0,S,A,x,r,a,d,p,f)};if("line"===C)for(const D of lp(r.geometry,0,0,8192,8192)){const L=function(i,r,n,o,s,a,l,c,h){const u=o?.6*a*l:0,d=ld(o,s),p=d*l,f=0===i[0].x||i[0].x===h||0===i[0].y||i[0].y===h;return r-p=0&&T=0&&E=0&&m+d<=p){const S=new lc(T,E,0,b,g);S._round(),s&&!lh(r,S,l,s,a)||_.push(S)}}f+=v}return h||_.length||c||(_=i(r,f/2,o,s,a,l,c,!0,u)),_}(i,f?r/2*c%r:(d/2+2*a)*l*c%r,r,u,n,p,f,!1,h)}(D,T,I,n.vertical||v,o,24,w,i.overscaling,8192);for(const B of L)v&&function(i,r,n,o){const s=i.compareText;if(r in s){const a=s[r];for(let l=a.length-1;l>=0;l--)if(o.dist(a[l])1){const F=function(i,r,n,o,s,a){const l=n?.6*24*a:0,c=ld(n,o)*a;let h=0;const u=lu(i)/2;for(let d=0;du){const _=(u-h)/m,g=io(p.x,f.x,_),y=io(p.y,f.y,_),x=new lc(g,y,0,f.angleTo(p),d);return!l||lh(i,x,c,l,r)?x:void 0}h+=m}}(R,I,n.vertical||v,o,0,w);F&&P(R,F,f)}}else if("Polygon"===r.type)for(const O of s1(r.geometry,0)){const U=function(i,r=1,n=!1){let o=1/0,s=1/0,a=-1/0,l=-1/0;const c=i[0];for(let h=0;ha)&&(a=d.x),(!h||d.y>l)&&(l=d.y)}const p=Math.min(a-o,l-s);let f=p/2;const m=new lb([],lT);if(0===p)return new u(o,s);for(let _=o;_y.d||!y.d)&&(y=v,n&&console.log("found best %d after %d probes",Math.round(1e4*v.d)/1e4,x)),v.max-y.d<=r||(f=v.h/2,m.push(new lE(v.p.x-f,v.p.y-f,f,i)),m.push(new lE(v.p.x+f,v.p.y-f,f,i)),m.push(new lE(v.p.x-f,v.p.y+f,f,i)),m.push(new lE(v.p.x+f,v.p.y+f,f,i)),x+=4)}return n&&(console.log(`num probes: ${x}`),console.log(`best distance: ${y.d}`)),y.p}(O,16);P(O[0],new lc(U.x,U.y,0,0,void 0),f)}else if("LineString"===r.type)for(const V of r.geometry)P(V,new lc(V[0].x,V[0].y,0,0,void 0),f);else if("Point"===r.type)for(const j of r.geometry)for(const G of j)P([G],new lc(G.x,G.y,0,0,void 0),f)}(i,w,I,A,o,m,S,0,C,H,l,c,d)}a&&i.generateCollisionDebugBuffers(h,i.collisionBoxArray)}(d,l,i.positions,c,r.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof ab||d instanceof s4||d instanceof ah)&&(he(d.layers,this.zoom,n),d.addFeatures(_,this.tileID.canonical,r.patternPositions,n))}this.status="done",s(null,{buckets:Y(f).filter(i=>!i.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:m,imageAtlas:r,glyphMap:this.returnDependencies?l:null,iconMap:this.returnDependencies?c:null,glyphPositions:this.returnDependencies?i.positions:null})}}D.length?o.send("getImages",{icons:D,source:this.source,tileID:this.tileID,type:"patterns"},(i,r)=>{a||(a=i,h=r,L.call(this))},void 0,!1,z):h={},L.call(this)}}function he(i,r,n){const o=new nk(r);for(const s of i)s.recalculate(o,n)}class ht{constructor(i){this.entries={},this.scheduler=i}request(i,r,n,o){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[a,l]=s.result;return this.scheduler?this.scheduler.add(()=>{o(a,l)},r):o(a,l),()=>{}}return s.callbacks.push(o),s.cancel||(s.cancel=n((n,o)=>{for(const a of(s.result=[n,o],s.callbacks))this.scheduler?this.scheduler.add(()=>{a(n,o)},r):a(n,o);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(i=>i!==o),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}}function hi(i,r,n){const o=JSON.stringify(i.request);return i.data&&(this.deduped.entries[o]={result:[null,i.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom},r=>{const o=e3(i.request,(i,o,s,a)=>{i?r(i):o&&r(null,{vectorTile:n?void 0:new as.VectorTile(new aO(o)),rawData:o,cacheControl:s,expires:a})});return()=>{o.cancel(),r()}},r)}const hr=_(new Float64Array(16));class hn{constructor(i,r){this._tr=i,this._worldSize=r}createInversionMatrix(){return hr}createTileMatrix(i){let r,n,o;const s=i.canonical,a=_(new Float64Array(16)),l=this._tr.projection;if(l.isReprojectedInTileSpace){const c=c8(s,l);r=1,n=c.x+i.wrap*c.scale,o=c.y,x(a,a,[r/c.scale,r/c.scale,this._tr.pixelsPerMeter/this._worldSize])}else r=this._worldSize/this._tr.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return y(a,a,[n,o,0]),x(a,a,[r/8192,r/8192,1]),a}pointCoordinate(i,r,n){const o=this._tr.horizonLineFromTop(!1),s=new u(i,Math.max(o,r));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(s,n))}upVector(){return[0,0,1]}upVectorScale(){return 1}}const ho=Math.sqrt(3)/2,hs=Math.PI/2;function ha(i){return Math.tan((hs+i)/2)}const hl=85.051129*N,hc=85.051129*N,hh={albers:{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&&V(this.parallels,this.constants.parallels))return;const i=Math.sin(this.parallels[0]*N),r=(i+Math.sin(this.parallels[1]*N))/2,n=1+i*(2*r-i),o=Math.sqrt(n)/r;this.constants={n:r,c:n,r0:o,parallels:this.parallels}},project(i,r){this.initializeConstants();const n=(i-this.center[0])*N,{n:o,c:s,r0:a}=this.constants,l=Math.sqrt(s-2*o*Math.sin(r*N))/o;return{x:l*Math.sin(n*o),y:l*Math.cos(n*o)-a,z:0}},unproject(i,r){this.initializeConstants();const{n:n,c:o,r0:s}=this.constants,a=s+r;let l=Math.atan2(i,Math.abs(a))*Math.sign(a);a*n<0&&(l-=Math.PI*Math.sign(i)*Math.sign(a));const c=this.center[0]*N*n;l=H(l,-Math.PI-c,Math.PI-c);const h=l/n*j+this.center[0],u=Math.asin(X((o-(i*i+a*a)*n*n)/(2*n),-1,1)),d=X(u*j,-85.051129,85.051129);return new o2(h,d)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equalEarth:{name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r=r/180*Math.PI,i=i/180*Math.PI;const n=Math.asin(ho*Math.sin(r)),o=n*n,s=o*o*o;return{x:.5*(i*Math.cos(n)/(ho*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o)))/Math.PI+.5),y:1-.5*(n*(1.340264+-.081106*o+s*(893e-6+.003796*o))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=n*n,s=o*o*o;for(let a,l,c=0;c<12&&(l=n*(1.340264+-.081106*o+s*(893e-6+.003796*o))-r,s=(o=(n=X(n-(a=l/(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))),-Math.PI/3,Math.PI/3))*n)*o*o,!(1e-12>Math.abs(a)));++c);const h=ho*i*(1.340264+-.24331799999999998*o+s*(.0062510000000000005+.034164*o))/Math.cos(n),u=Math.asin(Math.sin(n)/ho),d=X(180*h/Math.PI,-180,180),p=X(180*u/Math.PI,-85.051129,85.051129);return new o2(d,p)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},equirectangular:{name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(i,r)=>({x:.5+i/360,y:.5-r/360,z:0}),unproject(i,r){const n=X(360*(.5-r),-85.051129,85.051129);return new o2(360*(i-.5),n)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},lambertConformalConic:{name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&V(this.parallels,this.constants.parallels))return;const i=this.parallels[0]*N,r=this.parallels[1]*N,n=Math.cos(i),o=i===r?Math.sin(i):Math.log(n/Math.cos(r))/Math.log(ha(r)/ha(i)),s=n*Math.pow(ha(i),o)/o;this.constants={n:o,f:s,parallels:this.parallels}},project(i,r){this.initializeConstants(),r*=N,i=(i-this.center[0])*N;const{n:n,f:o}=this.constants;o>0?r<-hs+1e-6&&(r=-hs+1e-6):r>hs-1e-6&&(r=hs-1e-6);const s=o/Math.pow(ha(r),n),a=s*Math.sin(n*i),l=o-s*Math.cos(n*i);return{x:.5*(a/Math.PI+.5),y:1-.5*(l/Math.PI+.5),z:0}},unproject(i,r){this.initializeConstants(),i=(2*i-.5)*Math.PI,r=(2*(1-r)-.5)*Math.PI;const{n:n,f:o}=this.constants,s=o-r,a=Math.sign(s),l=Math.sign(n)*Math.sqrt(i*i+s*s);let c=Math.atan2(i,Math.abs(s))*a;s*n<0&&(c-=Math.PI*Math.sign(i)*a);const h=X(c/n*j+this.center[0],-180,180),u=X((2*Math.atan(Math.pow(o/l,1/n))-hs)*j,-85.051129,85.051129);return new o2(h,u)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},mercator:{name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(i,r)=>({x:o4(i),y:o6(r),z:0}),unproject(i,r){const n=o8(i),o=o9(r);return new o2(n,o)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},naturalEarth:{name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(i,r){const n=(r*=N)*r,o=n*n;return{x:.5*((i*=N)*(.8707-.131979*n+o*(o*(.003971*n-.001529*o)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+n*(.015085+o*(.028874*n-.044475-.005916*o)))/Math.PI+1),z:0}},unproject(i,r){i=(2*i-.5)*Math.PI;let n=r=(2*(1-r)-1)*Math.PI,o=25,s=0,a=n*n;do{a=n*n;const l=a*a;s=(n*(1.007226+a*(.015085+l*(.028874*a-.044475-.005916*l)))-r)/(1.007226+a*(.045255+l*(.259866*a-.311325-.005916*11*l))),n=X(n-s,-hl,hl)}while(Math.abs(s)>1e-6&&--o>0)a=n*n;const c=X(i/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*j,-180,180),h=n*j;return new o2(c,h)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)},winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(i,r){r*=N,i*=N;const n=Math.cos(r),o=2/Math.PI,s=Math.acos(n*Math.cos(i/2)),a=Math.sin(s)/s,l=.5*(i*o+2*n*Math.sin(i/2)/a)||0,c=.5*(r+Math.sin(r)/a)||0;return{x:.5*(l/Math.PI+.5),y:1-.5*(c/Math.PI+1),z:0}},unproject(i,r){let n=i=(2*i-.5)*Math.PI,o=r=(2*(1-r)-1)*Math.PI,s=25,a=0,l=0;do{const c=Math.cos(o),h=Math.sin(o),u=2*h*c,d=h*h,p=c*c,f=Math.cos(n/2),m=Math.sin(n/2),_=2*f*m,g=m*m,y=1-p*f*f,x=y?1/y:0,v=y?Math.acos(c*f)*Math.sqrt(1/y):0,b=.5*(2*v*c*m+2*n/Math.PI)-i,w=.5*(v*h+o)-r,T=.5*x*(p*g+v*c*f*d)+1/Math.PI,E=x*(_*u/4-v*h*m),S=.125*x*(u*m-v*h*p*_),I=.5*x*(d*f+v*g*c)+.5,M=E*S-I*T;a=(w*E-b*I)/M,l=(b*S-w*T)/M,n=X(n-a,-Math.PI,Math.PI),o=X(o-l,-hc,hc)}while((Math.abs(a)>1e-6||Math.abs(l)>1e-6)&&--s>0)return new o2(n*j,o*j)},projectTilePoint:(i,r)=>({x:i,y:r,z:0}),locationPoint:(i,r)=>i._coordinatePoint(i.locationCoordinate(r),!1),pixelsPerMeter:(i,r)=>1/o5(i)*r,farthestPixelDistance(i){return cH(i,this.pixelsPerMeter(i.center.lat,i.worldSize))},createTileTransform:(i,r)=>new hn(i,r)}};i.ARRAY_TYPE=f,i.AUTH_ERR_MSG=ez,i.Aabb=sv,i.Actor=class{constructor(i,r,n){this.target=i,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},en(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ed()?i:p,this.scheduler=new l6}send(i,r,n,o,s=!1,a){const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=a,this.callbacks[l]=n);const c=ey(this.globalScope)?void 0:[];return this.target.postMessage({id:l,type:i,hasCallback:!!n,targetMapId:o,mustQueue:s,sourceMapId:this.mapId,data:rH(r,c)},c),{cancel:()=>{n&&delete this.callbacks[l],this.target.postMessage({id:l,type:"",targetMapId:o,sourceMapId:this.mapId})}}}receive(i){const r=i.data,n=r.id;if(n&&(!r.targetMapId||this.mapId===r.targetMapId)){if(""===r.type){const o=this.cancelCallbacks[n];delete this.cancelCallbacks[n],o&&o.cancel()}else if(r.mustQueue||ed()){const s=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,r),s&&s.metadata||{type:"message"})}else this.processTask(n,r)}}processTask(i,r){if(""===r.type){const n=this.callbacks[i];delete this.callbacks[i],n&&(r.error?n(rK(r.error)):n(null,rK(r.data)))}else{const o=ey(this.globalScope)?void 0:[],s=r.hasCallback?(r,n)=>{delete this.cancelCallbacks[i],this.target.postMessage({id:i,type:"",sourceMapId:this.mapId,error:r?rH(r):null,data:rH(n,o)},o)}:i=>{},a=rK(r.data);if(this.parent[r.type])this.parent[r.type](r.sourceMapId,a,s);else if(this.parent.getWorkerSource){const l=r.type.split(".");this.parent.getWorkerSource(r.sourceMapId,l[0],a.source)[l[1]](a,s)}else s(Error(`Could not find function ${r.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=l9,i.Color=tC,i.ColorMode=cn,i.CullFaceMode=co,i.DEMData=cg,i.DataConstantProperty=nV,i.DedupedRequest=ht,i.DepthMode=ci,i.EXTENT=8192,i.Elevation=class{getAtPointOrZero(i,r=0){return this.getAtPoint(i,r)||0}getAtPoint(i,r,n=!0){null==r&&(r=null);const o=this._source();if(!o||i.y<0||i.y>1)return r;const s=o.getSource().maxzoom,a=1<{const o=this.getAtTileOffset(i,n.x,n.y),s=r.upVector(i.canonical,n.x,n.y);return C(s,s,o*r.upVectorScale(i.canonical)),s}}getForTilePoints(i,r,n,o){const s=cw.create(this,i,o);return!!s&&(r.forEach(i=>{i[2]=this.exaggeration()*s.getElevationAt(i[0],i[1],n)}),!0)}getMinMaxForTile(i){const r=this.findDEMTileFor(i);if(!r||!r.dem)return null;const n=r.dem.tree,o=r.tileID,s=1<Math.abs(o))return!1;const s=((i[0]-this.pos[0])*r[0]+(i[1]-this.pos[1])*r[1]+(i[2]-this.pos[2])*r[2])/o;return n[0]=this.pos[0]+this.dir[0]*s,n[1]=this.pos[1]+this.dir[1]*s,n[2]=this.pos[2]+this.dir[2]*s,!0}closestPointOnSphere(i,r,n){var o,s,a,l,c,h,u;if(s=(o=this.pos)[0],a=o[1],l=o[2],c=i[0],h=i[1],u=i[2],Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(a-h)<=1e-6*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(l-u)<=1e-6*Math.max(1,Math.abs(l),Math.abs(u))||0===r)return n[0]=n[1]=n[2]=0,!1;const[d,p,f]=this.dir,m=this.pos[0]-i[0],_=this.pos[1]-i[1],g=this.pos[2]-i[2],y=d*d+p*p+f*f,x=2*(m*d+_*p+g*f),v=x*x-4*y*(m*m+_*_+g*g-r*r);if(v<0){const b=Math.max(-x/2,0),w=m+d*b,T=_+p*b,E=g+f*b,S=Math.hypot(w,T,E);return n[0]=w*r/S,n[1]=T*r/S,n[2]=E*r/S,!1}{const I=(-x-Math.sqrt(v))/(2*y);if(I<0){const M=Math.hypot(m,_,g);return n[0]=m*r/M,n[1]=_*r/M,n[2]=g*r/M,!1}return n[0]=m+d*I,n[1]=_+p*I,n[2]=g+f*I,!0}}},i.RequestManager=class{constructor(i,r,n){this._transformRequestFn=i,this._customAccessToken=r,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const i=function(){let i="";for(let r=0;r<10;r++)i+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",i].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,r){return this._transformRequestFn&&this._transformRequestFn(i,r)||{url:i}}normalizeStyleURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeSourceURL(i,r){if(!ek(i))return i;const n=eL(i);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),this._makeAPIURL(n,this._customAccessToken||r)}normalizeSpriteURL(i,r,n,o){const s=eL(i);return ek(i)?(s.path=`/styles/v1${s.path}/sprite${r}${n}`,this._makeAPIURL(s,this._customAccessToken||o)):(s.path+=`${r}${n}`,eB(s))}normalizeTileURL(i,r,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!ek(i))return i;const o=eL(i);o.path=o.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||n&&"raster"!==o.authority&&512===n?"@2x":""}${eE.supported?".webp":"$1"}`),"raster"===o.authority?o.path=`/${eb.RASTER_URL_PREFIX}${o.path}`:(o.path=o.path.replace(/^.+\/v4\//,"/"),o.path=`/${eb.TILE_URL_VERSION}${o.path}`);const s=this._customAccessToken||function(i){for(const r of i){const n=r.match(/^access_token=(.*)$/);if(n)return n[1]}return null}(o.params)||eb.ACCESS_TOKEN;return eb.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&o.params.push(`sku=${this._skuToken}`),this._makeAPIURL(o,s)}canonicalizeTileURL(i,r){const n=eL(i);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return i;let o="mapbox://";n.path.match(/^\/raster\/v1\//)?o+=`raster/${n.path.replace(`/${eb.RASTER_URL_PREFIX}/`,"")}`:o+=`tiles/${n.path.replace(`/${eb.TILE_URL_VERSION}/`,"")}`;let s=n.params;return r&&(s=s.filter(i=>!i.match(/^access_token=/))),s.length&&(o+=`?${s.join("&")}`),o}canonicalizeTileset(i,r){const n=!!r&&ek(r),o=[];for(const s of i.tiles||[])eP(s)?o.push(this.canonicalizeTileURL(s,n)):o.push(s);return o}_makeAPIURL(i,r){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",o=eL(eb.API_URL);if(i.protocol=o.protocol,i.authority=o.authority,"http"===i.protocol){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if("/"!==o.path&&(i.path=`${o.path}${i.path}`),!eb.REQUIRE_ACCESS_TOKEN)return eB(i);if(r=r||eb.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===r[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return i.params=i.params.filter(i=>-1===i.indexOf("access_token")),i.params.push(`access_token=${r||""}`),eB(i)}},i.ResourceType=eQ,i.SegmentVector=o0,i.SourceCache=cx,i.StencilMode=cr,i.StructArrayLayout1ui2=ol,i.StructArrayLayout2f1f2i16=n9,i.StructArrayLayout2i4=nJ,i.StructArrayLayout2ui4=oa,i.StructArrayLayout3f12=n1,i.StructArrayLayout3ui6=oe,i.StructArrayLayout4i8=nQ,i.Texture=l1,i.Tile=c$,i.Transitionable=nL,i.Uniform1f=oP,i.Uniform1i=class extends ok{constructor(i,r){super(i,r),this.current=0}set(i){this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},i.Uniform2f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1]))}},i.Uniform3f=class extends ok{constructor(i,r){super(i,r),this.current=[0,0,0]}set(i){i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2]))}},i.Uniform4f=oD,i.UniformColor=oL,i.UniformMatrix2f=class extends ok{constructor(i,r){super(i,r),this.current=oF}set(i){for(let r=0;r<4;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},i.UniformMatrix3f=class extends ok{constructor(i,r){super(i,r),this.current=oR}set(i){for(let r=0;r<9;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},i.UniformMatrix4f=class extends ok{constructor(i,r){super(i,r),this.current=oB}set(i){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let r=1;r<16;r++)if(i[r]!==this.current[r]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}},i.UnwrappedTileID=l7,i.ValidationError=tn,i.VectorTileWorkerSource=class extends ti{constructor(i,r,n,o,s){super(),this.actor=i,this.layerIndex=r,this.availableImages=n,this.loadVectorData=s||hi,this.loading={},this.loaded={},this.deduped=new ht(i.scheduler),this.isSpriteLoaded=o,this.scheduler=i.scheduler}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new c7(i);a.abort=this.loadVectorData(i,(l,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||l||!c)return a.status="done",h||(this.loaded[n]=a),r(l);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),a.vectorTile=c.vectorTile||new as.VectorTile(new aO(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,(i,n)=>{if(i||!n)return r(i);const a={};if(s){const l=l4(o);l.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(l)))}r(null,J({rawTileData:u.slice(0)},n,d,a))})};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(i,r){const n=this.loaded,o=i.uid,s=this;if(n&&n[o]){const a=n[o];a.showCollisionBoxes=i.showCollisionBoxes,a.enableTerrain=!!i.enableTerrain,a.projection=i.projection;const l=(i,n)=>{const o=a.reloadCallback;o&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,o)),r(i,n)};"parsing"===a.status?a.reloadCallback=l:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,l):l())}}abortTile(i,r){const n=i.uid,o=this.loading[n];o&&(o.abort&&o.abort(),delete this.loading[n]),r()}removeTile(i,r){const n=this.loaded,o=i.uid;n&&n[o]&&delete n[o],r()}},i.WritingMode=a6,i.ZoomHistory=rY,i.add=I,i.addDynamicAttributes=lR,i.adjoint=function(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=r[4],c=r[5],h=r[6],u=r[7],d=r[8];return i[0]=l*d-c*u,i[1]=s*u-o*d,i[2]=o*c-s*l,i[3]=c*h-a*d,i[4]=n*d-s*h,i[5]=s*a-n*c,i[6]=a*u-l*h,i[7]=o*h-n*u,i[8]=n*l-o*a,i},i.asyncAll=K,i.bezier=$,i.bindAll=en,i.boundsAttributes=cG,i.bufferConvexPolygon=function(i,r){const n=[];for(let o=0;oeH&&(i.getActor().send("enforceCacheSizeLimit",eW),eJ=0)},i.calculateGlobeMatrix=c4,i.calculateGlobeMercatorMatrix=function(i){const r=i.worldSize,n=X(i.center.lat,-85.051129,85.051129),o=new u(o4(i.center.lng)*r,o6(n)*r),s=1/o5(i.center.lat)*r,a=i.pixelsPerMeter,l=r/(s/i.pixelsPerMeter),c=_(new Float64Array(16));return y(c,c,[o.x,o.y,0]),x(c,c,[l,l,a]),c},i.clamp=X,i.clearTileCache=function(i){const r=p.caches.delete(e$);i&&r.catch(i).then(()=>i())},i.clipLine=lp,i.clone=function(i){var r=new f(16);return r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],r},i.clone$1=el,i.collisionCircleLayout=az,i.config=eb,i.conjugate=function(i,r){return i[0]=-r[0],i[1]=-r[1],i[2]=-r[2],i[3]=r[3],i},i.create=function(){var i=new f(16);return f!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},i.create$1=m,i.createExpression=i9,i.createLayout=nK,i.createStyleLayer=function(i){return"custom"===i.type?new lq(i):new lH[i.type](i)},i.cross=D,i.degToRad=function(i){return i*N},i.div=function(i,r,n){return i[0]=r[0]/n[0],i[1]=r[1]/n[1],i[2]=r[2]/n[2],i},i.dot=P,i.ease=q,i.easeCubicInOut=Z,i.emitValidationErrors=rU,i.endsWith=eo,i.enforceCacheSizeLimit=function(i){eK(),eq&&eq.then(r=>{r.keys().then(n=>{for(let o=0;oa&&(o+=(i[s]-a)*(i[s]-a)),r[s]Math.abs(r.parallels[0]+r.parallels[1])){let n=function(i){const r=Math.max(.01,Math.cos(i*N)),n=1/(2*Math.max(Math.PI*r,1/r));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(i,o){const s=Math.sin(o*N)/r;return{x:i*N*r*n+.5,y:-s*n+.5,z:0}},unproject(i,o){const s=X((i-.5)/n*j/r,-180,180),a=Math.asin(X(-(o-.5)/n*r,-1,1)),l=X(a*j,-85.051129,85.051129);return new o2(s,l)}}}(r.parallels[0]);if("lambertConformalConic"===r.name){const{project:o,unproject:s}=hh.mercator;n={wrap:!0,supportsWorldCopies:!0,project:o,unproject:s}}return J({},i,r,n)}return J({},i,r)}(r,i):r},i.getRTLTextPluginStatus=nA,i.getReferrer=e1,i.getTilePoint=function(i,{x:r,y:n},o=0){return new u(((r-o)*i.scale-i.x)*8192,(n*i.scale-i.y)*8192)},i.getTileVec3=function(i,r,n=0){return S(((r.x-n)*i.scale-i.x)*8192,(r.y*i.scale-i.y)*8192,r.z*o5(o9(r.y)))},i.getVideo=function(i,r){const n=p.document.createElement("video");n.muted=!0,n.onloadstart=function(){r(null,n)};for(let o=0;o0&&(l=1/Math.sqrt(l)),i[0]=n*l,i[1]=o*l,i[2]=s*l,i[3]=a*l,i},i.number=io,i.ortho=function(i,r,n,o,s,a,l){var c=1/(r-n),h=1/(o-s),u=1/(a-l);return i[0]=-2*c,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*h,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*u,i[11]=0,i[12]=(r+n)*c,i[13]=(s+o)*h,i[14]=(l+a)*u,i[15]=1,i},i.pbf=aO,i.perspective=function(i,r,n,o,s){var a,l=1/Math.tan(r/2);return i[0]=l/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,null!=s&&s!==1/0?(i[10]=(s+o)*(a=1/(o-s)),i[14]=2*s*o*a):(i[10]=-1,i[14]=-2*o),i},i.pick=function(i,r){const n={};for(let o=0;othis._layers[i.id]),h=c[0];if("none"===h.visibility)continue;const u=h.source||"";let d=this.familiesBySource[u];d||(d=this.familiesBySource[u]={});const p=h.sourceLayer||"_geojsonTileLayer";let f=d[p];f||(f=d[p]=[]),f.push(c)}}}const{ImageBitmap:n}=i.window;class o{loadTile(r,o){const{uid:s,encoding:a,rawImageData:l,padding:c,buildQuadTree:h}=r,u=n&&l instanceof n?this.getImageData(l,c):l;o(null,new i.DEMData(s,u,a,c<1,h))}getImageData(r,n){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(r.width,r.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=r.width,this.offscreenCanvas.height=r.height,this.offscreenCanvasContext.drawImage(r,0,0,r.width,r.height);const o=this.offscreenCanvasContext.getImageData(-n,-n,r.width+2*n,r.height+2*n);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:o.width,height:o.height},o.data)}}var s,a=function i(r,n){var o,s=r&&r.type;if("FeatureCollection"===s)for(o=0;o=Math.abs(c)?n-h+c:c-h+n,n=h}n+o>=0!=!!r&&i.reverse()}const h=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(r){this._feature=r,this.extent=i.EXTENT,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}loadGeometry(){if(1===this._feature.type){const r=[];for(const n of this._feature.geometry)r.push([new i.pointGeometry(n[0],n[1])]);return r}{const o=[];for(const s of this._feature.geometry){const a=[];for(const l of s)a.push(new i.pointGeometry(l[0],l[1]));o.push(a)}return o}}toGeoJSON(i,r,n){return h.call(this,i,r,n)}}class d{constructor(r){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=r.length,this._features=r}feature(i){return new u(this._features[i])}}var p=i.vectorTile.VectorTileFeature;function f(i,r){this.options=r||{},this.features=i,this.length=i.length}function m(i,r){this.id="number"==typeof i.id?i.id:void 0,this.type=i.type,this.rawGeometry=1===i.type?[i.geometry]:i.geometry,this.properties=i.tags,this.extent=r||4096}f.prototype.feature=function(i){return new m(this.features[i],this.options.extent)},m.prototype.loadGeometry=function(){var r=this.rawGeometry;this.geometry=[];for(var n=0;n>31),r.writeVarint(m<<1^m>>31),s+=f,a+=m}3===o&&r.writeVarint(15)}}function w(i,r){var n=typeof i;"string"===n?r.writeStringField(1,i):"boolean"===n?r.writeBooleanField(7,i):"number"===n&&(i%1!=0?r.writeDoubleField(3,i):i<0?r.writeSVarintField(6,i):r.writeVarintField(5,i))}function T(i,r,n,o){E(i,n,o),E(r,2*n,2*o),E(r,2*n+1,2*o+1)}function E(i,r,n){const o=i[r];i[r]=i[n],i[n]=o}function S(i,r,n,o){const s=i-n,a=r-o;return s*s+a*a}_.fromVectorTileJs=g,_.fromGeojsonVt=function(i,r){r=r||{};var n={};for(var o in i)n[o]=new f(i[o].features,r),n[o].name=o,n[o].version=r.version,n[o].extent=r.extent;return g({layers:n})},_.GeoJSONWrapper=f;const I=i=>i[0],M=i=>i[1];class A{constructor(i,r=I,n=M,o=64,s=Float64Array){this.nodeSize=o,this.points=i;const a=i.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(i.length),c=this.coords=new s(2*i.length);for(let h=0;h>1;(function i(r,n,o,s,a,l){for(;a>s;){if(a-s>600){const c=a-s+1,h=o-s+1,u=Math.log(c),d=.5*Math.exp(2*u/3),p=.5*Math.sqrt(u*d*(c-d)/c)*(h-c/2<0?-1:1);i(r,n,o,Math.max(s,Math.floor(o-h*d/c+p)),Math.min(a,Math.floor(o+(c-h)*d/c+p)),l)}const f=n[2*o+l];let m=s,_=a;for(T(r,n,s,o),n[2*a+l]>f&&T(r,n,s,a);m<_;){for(T(r,n,m,_),m++,_--;n[2*m+l]f;)_--}n[2*s+l]===f?T(r,n,s,_):T(r,n,++_,a),_<=o&&(s=_+1),o<=_&&(a=_-1)}})(r,n,c,s,a,l%2),i(r,n,o,s,c-1,l+1),i(r,n,o,c+1,a,l+1)}(l,c,o,0,l.length-1,0)}range(i,r,n,o){return function(i,r,n,o,s,a,l){let c,h;const u=[0,i.length-1,0],d=[];for(;u.length;){const p=u.pop(),f=u.pop(),m=u.pop();if(f-m<=l){for(let _=m;_<=f;_++)c=r[2*_],h=r[2*_+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[_]);continue}const g=Math.floor((m+f)/2);c=r[2*g],h=r[2*g+1],c>=n&&c<=s&&h>=o&&h<=a&&d.push(i[g]);const y=(p+1)%2;(0===p?n<=c:o<=h)&&(u.push(m),u.push(g-1),u.push(y)),(0===p?s>=c:a>=h)&&(u.push(g+1),u.push(f),u.push(y))}return d}(this.ids,this.coords,i,r,n,o,this.nodeSize)}within(i,r,n){return function(i,r,n,o,s,a){const l=[0,i.length-1,0],c=[],h=s*s;for(;l.length;){const u=l.pop(),d=l.pop(),p=l.pop();if(d-p<=a){for(let f=p;f<=d;f++)S(r[2*f],r[2*f+1],n,o)<=h&&c.push(i[f]);continue}const m=Math.floor((p+d)/2),_=r[2*m],g=r[2*m+1];S(_,g,n,o)<=h&&c.push(i[m]);const y=(u+1)%2;(0===u?n-s<=_:o-s<=g)&&(l.push(p),l.push(m-1),l.push(y)),(0===u?n+s>=_:o+s>=g)&&(l.push(m+1),l.push(d),l.push(y))}return c}(this.ids,this.coords,i,r,n,this.nodeSize)}}const C={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:i=>i},z=Math.fround||(s=new Float32Array(1),i=>(s[0]=+i,s[0]));class k{constructor(i){this.options=R(Object.create(C),i),this.trees=Array(this.options.maxZoom+1)}load(i){const{log:r,minZoom:n,maxZoom:o,nodeSize:s}=this.options;r&&console.time("total time");const a=`prepare ${i.length} points`;r&&console.time(a),this.points=i;let l=[];for(let c=0;c=n;h--){const u=+Date.now();l=this._cluster(l,h),this.trees[h]=new A(l,F,O,s,Float32Array),r&&console.log("z%d: %d clusters in %dms",h,l.length,+Date.now()-u)}return r&&console.timeEnd("total time"),this}getClusters(i,r){let n=((i[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,i[1]));let s=180===i[2]?180:((i[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,i[3]));if(i[2]-i[0]>=360)n=-180,s=180;else if(n>s){const l=this.getClusters([n,o,180,a],r),c=this.getClusters([-180,o,s,a],r);return l.concat(c)}const h=this.trees[this._limitZoom(r)],u=h.range(L(n),B(a),L(s),B(o)),d=[];for(const p of u){const f=h.points[p];d.push(f.numPoints?P(f):this.points[f.index])}return d}getChildren(i){const r=this._getOriginId(i),n=this._getOriginZoom(i),o="No cluster with the specified id.",s=this.trees[n];if(!s)throw Error(o);const a=s.points[r];if(!a)throw Error(o);const l=this.options.radius/(this.options.extent*Math.pow(2,n-1)),c=s.within(a.x,a.y,l),h=[];for(const u of c){const d=s.points[u];d.parentId===i&&h.push(d.numPoints?P(d):this.points[d.index])}if(0===h.length)throw Error(o);return h}getLeaves(i,r,n){const o=[];return this._appendLeaves(o,i,r=r||10,n=n||0,0),o}getTile(i,r,n){const o=this.trees[this._limitZoom(i)],s=Math.pow(2,i),{extent:a,radius:l}=this.options,c=l/a,h=(n-c)/s,u=(n+1+c)/s,d={features:[]};return this._addTileFeatures(o.range((r-c)/s,h,(r+1+c)/s,u),o.points,r,n,s,d),0===r&&this._addTileFeatures(o.range(1-c/s,h,1,u),o.points,s,n,s,d),r===s-1&&this._addTileFeatures(o.range(0,h,c/s,u),o.points,-1,n,s,d),d.features.length?d:null}getClusterExpansionZoom(i){let r=this._getOriginZoom(i)-1;for(;r<=this.options.maxZoom;){const n=this.getChildren(i);if(r++,1!==n.length)break;i=n[0].properties.cluster_id}return r}_appendLeaves(i,r,n,o,s){const a=this.getChildren(r);for(const l of a){const c=l.properties;if(c&&c.cluster?s+c.point_count<=o?s+=c.point_count:s=this._appendLeaves(i,c.cluster_id,n,o,s):sr&&(m+=g.numPoints||1)}if(m>f&&m>=l){var y,x,v,b;let w=u.x*f,T=u.y*f,E=a&&f>1?this._map(u,!0):null;const S=(h<<5)+(r+1)+this.points.length;for(const I of p){const M=d.points[I];if(M.zoom<=r)continue;M.zoom=r;const A=M.numPoints||1;w+=M.x*A,T+=M.y*A,M.parentId=S,a&&(E||(E=this._map(u,!0)),a(E,this._map(M)))}u.parentId=S,n.push((y=w/m,x=T/m,v=m,b=E,{x:z(y),y:z(x),zoom:1/0,id:S,parentId:-1,numPoints:v,properties:b}))}else if(n.push(u),m>1)for(const C of p){const k=d.points[C];k.zoom<=r||(k.zoom=r,n.push(k))}}return n}_getOriginId(i){return i-this.points.length>>5}_getOriginZoom(i){return(i-this.points.length)%32}_map(i,r){if(i.numPoints)return r?R({},i.properties):i.properties;const n=this.points[i.index].properties,o=this.options.map(n);return r&&o===n?R({},o):o}}function P(i){return{type:"Feature",id:i.id,properties:D(i),geometry:{type:"Point",coordinates:[360*(i.x-.5),function(i){const r=(180-360*i)*Math.PI/180;return 360*Math.atan(Math.exp(r))/Math.PI-90}(i.y)]}}}function D(i){const r=i.numPoints,n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r;return R(R({},i.properties),{cluster:!0,cluster_id:i.id,point_count:r,point_count_abbreviated:n})}function L(i){return i/360+.5}function B(i){const r=Math.sin(i*Math.PI/180),n=.5-.25*Math.log((1+r)/(1-r))/Math.PI;return n<0?0:n>1?1:n}function R(i,r){for(const n in r)i[n]=r[n];return i}function F(i){return i.x}function O(i){return i.y}function U(i,r,n,o){var s={id:void 0===i?null:i,type:r,geometry:n,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(i){var r=i.geometry,n=i.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)V(i,r);else if("Polygon"===n||"MultiLineString"===n)for(var o=0;o0&&(l+=o?(s*u-h*a)/2:Math.sqrt(Math.pow(h-s,2)+Math.pow(u-a,2))),s=h,a=u}var d=r.length-3;r[2]=1,function i(r,n,o,s){for(var a,l=s,c=o-n>>1,h=o-n,u=r[n],d=r[n+1],p=r[o],f=r[o+1],m=n+3;m1?(n=s,o=a):h>0&&(n+=l*h,o+=c*h)}return(l=i-n)*l+(c=r-o)*c}(r[m],r[m+1],u,d,p,f);if(_>l)a=m,l=_;else if(_===l){var g=Math.abs(m-c);gs&&(a-n>3&&i(r,n,a,s),r[a+2]=l,o-a>3&&i(r,a,o,s))}(r,0,d,n),r[d+2]=1,r.size=Math.abs(l),r.start=0,r.end=r.size}function Z(i,r,n,o){for(var s=0;s1?1:n}function q(i,r,n,o,s,a,l,c){if(o/=r,a>=(n/=r)&&l=o)return null;for(var h=[],u=0;u=n&&_=o)){var g=[];if("Point"===f||"MultiPoint"===f)(function(i,r,n,o,s){for(var a=0;a=n&&l<=o&&(r.push(i[a]),r.push(i[a+1]),r.push(i[a+2]))}})(p,g,n,o,s);else if("LineString"===f)X(p,g,n,o,s,!1,c.lineMetrics);else if("MultiLineString"===f)H(p,g,n,o,s,!1);else if("Polygon"===f)H(p,g,n,o,s,!0);else if("MultiPolygon"===f)for(var y=0;yn&&(h=d(u,m,_,y,x,n),l&&(u.start=p+c*h)):v>o?b=n&&(h=d(u,m,_,y,x,n),w=!0),b>o&&v<=o&&(h=d(u,m,_,y,x,o),w=!0),!a&&w&&(l&&(u.end=p+c*h),r.push(u),u=W(i)),l&&(p+=c)}var T=i.length-3;m=i[T],_=i[T+1],g=i[T+2],(v=0===s?m:_)>=n&&v<=o&&K(u,m,_,g),T=u.length-3,a&&T>=3&&(u[T]!==u[0]||u[T+1]!==u[1])&&K(u,u[0],u[1],u[2]),u.length&&r.push(u)}function W(i){var r=[];return r.size=i.size,r.start=i.start,r.end=i.end,r}function H(i,r,n,o,s,a){for(var l=0;l0&&r.size<(s?l:o))n.numPoints+=r.length/3;else{for(var c=[],h=0;hl)&&(n.numSimplified++,c.push(r[h]),c.push(r[h+1])),n.numPoints++;s&&function(i,r){for(var n=0,o=0,s=i.length,a=s-2;o0===r)for(o=0,s=i.length;o24)throw Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw Error("promoteId and generateId cannot be used together.");var u=function(i,r){var n=[];if("FeatureCollection"===i.type)for(var o=0;o1&&console.time("creation"),f=this.tiles[p]=function(i,r,n,o,s){for(var a=r===s.maxZoom?0:s.tolerance/((1<l.maxX&&(l.maxX=d),p>l.maxY&&(l.maxY=p)}return l}(i,r,n,o,h),this.tileCoords.push({z:r,x:n,y:o}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",r,n,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var m="z"+r;this.stats[m]=(this.stats[m]||0)+1,this.total++}if(f.source=i,s){if(r===h.maxZoom||r===s)continue;var _=1<1&&console.time("clipping");var g,y,x,v,b,w,T=.5*h.buffer/h.extent,E=.5-T,S=.5+T,I=1+T;g=y=x=v=null,b=q(i,d,n-T,n+S,0,f.minX,f.maxX,h),w=q(i,d,n+E,n+I,0,f.minX,f.maxX,h),i=null,b&&(g=q(b,d,o-T,o+S,1,f.minY,f.maxY,h),y=q(b,d,o+E,o+I,1,f.minY,f.maxY,h),b=null),w&&(x=q(w,d,o-T,o+S,1,f.minY,f.maxY,h),v=q(w,d,o+E,o+I,1,f.minY,f.maxY,h),w=null),u>1&&console.timeEnd("clipping"),c.push(g||[],r+1,2*n,2*o),c.push(y||[],r+1,2*n,2*o+1),c.push(x||[],r+1,2*n+1,2*o),c.push(v||[],r+1,2*n+1,2*o+1)}}},en.prototype.getTile=function(i,r,n){var o=this.options,s=o.extent,a=o.debug;if(i<0||i>24)return null;var l=1<1&&console.log("drilling down to z%d-%d-%d",i,r,n);for(var h,u=i,d=r,p=n;!h&&u>0;)u--,d=Math.floor(d/2),p=Math.floor(p/2),h=this.tiles[eo(u,d,p)];return h&&h.source?(a>1&&console.log("found parent tile z%d-%d-%d",u,d,p),a>1&&console.time("drilling down"),this.splitTile(h.source,u,d,p,i,r,n),a>1&&console.timeEnd("drilling down"),this.tiles[c]?et(this.tiles[c],s):null):null};class ea extends i.VectorTileWorkerSource{constructor(i,r,n,o,s){super(i,r,n,o,es),s&&(this.loadGeoJSON=s)}loadData(r,n){const o=r&&r.request,s=o&&o.collectResourceTiming;this.loadGeoJSON(r,(l,c)=>{if(l||!c)return n(l);if("object"!=typeof c)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{a(c,!0);try{var h,u;if(r.filter){const d=i.createExpression(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===d.result)throw Error(d.value.map(i=>`${i.key}: ${i.message}`).join(", "));const p=c.features.filter(i=>d.value.evaluate({zoom:0},i));c={type:"FeatureCollection",features:p}}this._geoJSONIndex=r.cluster?new k(function({superclusterOptions:r,clusterProperties:n}){if(!n||!r)return r;const o={},s={},a={accumulated:null,zoom:0},l={properties:null},c=Object.keys(n);for(const h of c){const[u,d]=n[h],p=i.createExpression(d),f=i.createExpression("string"==typeof u?[u,["accumulated"],["get",h]]:u);o[h]=p.value,s[h]=f.value}return r.map=i=>{l.properties=i;const r={};for(const n of c)r[n]=o[n].evaluate(a,l);return r},r.reduce=(i,r)=>{for(const n of(l.properties=r,c))a.accumulated=i[n],i[n]=s[n].evaluate(a,l)},r}(r)).load(c.features):(h=c,u=r.geojsonVtOptions,new en(h,u))}catch(f){return n(f)}this.loaded={};const m={};if(s){const _=i.getPerformanceMeasurement(o);_&&(m.resourceTiming={},m.resourceTiming[r.source]=JSON.parse(JSON.stringify(_)))}n(null,m)}})}reloadTile(i,r){const n=this.loaded;return n&&n[i.uid]?super.reloadTile(i,r):this.loadTile(i,r)}loadGeoJSON(r,n){if(r.request)i.getJSON(r.request,n);else{if("string"!=typeof r.data)return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(r.data))}catch(o){return n(Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(i,r){try{r(null,this._geoJSONIndex.getClusterExpansionZoom(i.clusterId))}catch(n){r(n)}}getClusterChildren(i,r){try{r(null,this._geoJSONIndex.getChildren(i.clusterId))}catch(n){r(n)}}getClusterLeaves(i,r){try{r(null,this._geoJSONIndex.getLeaves(i.clusterId,i.limit,i.offset))}catch(n){r(n)}}}class el{constructor(r){this.self=r,this.actor=new i.Actor(r,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:ea},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(i,r)=>{if(this.workerSourceTypes[i])throw Error(`Worker source with name "${i}" already registered.`);this.workerSourceTypes[i]=r},this.self.registerRTLTextPlugin=r=>{if(i.plugin.isParsed())throw Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=r.applyArabicShaping,i.plugin.processBidirectionalText=r.processBidirectionalText,i.plugin.processStyledBidirectionalText=r.processStyledBidirectionalText}}clearCaches(i,r,n){delete this.layerIndexes[i],delete this.availableImages[i],delete this.workerSources[i],delete this.demWorkerSources[i],n()}checkIfReady(i,r,n){n()}setReferrer(i,r){this.referrer=r}spriteLoaded(r,n){for(const o in this.isSpriteLoaded[r]=n,this.workerSources[r]){const s=this.workerSources[r][o];for(const a in s)s[a]instanceof i.VectorTileWorkerSource&&(s[a].isSpriteLoaded=n,s[a].fire(new i.Event("isSpriteLoaded")))}}setImages(i,r,n){for(const o in this.availableImages[i]=r,this.workerSources[i]){const s=this.workerSources[i][o];for(const a in s)s[a].availableImages=r}n()}enableTerrain(i,r,n){this.terrain=r,n()}setProjection(r,n){this.projections[r]=i.getProjection(n)}setLayers(i,r,n){this.getLayerIndex(i).replace(r),n()}updateLayers(i,r,n){this.getLayerIndex(i).update(r.layers,r.removedIds),n()}loadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).loadTile(s,o)}loadDEMTile(r,n,o){const s=this.enableTerrain?i.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(r,n.source).loadTile(s,o)}reloadTile(r,n,o){const s=this.enableTerrain?i.extend({enableTerrain:this.terrain},n):n;s.projection=this.projections[r]||this.defaultProjection,this.getWorkerSource(r,n.type,n.source).reloadTile(s,o)}abortTile(i,r,n){this.getWorkerSource(i,r.type,r.source).abortTile(r,n)}removeTile(i,r,n){this.getWorkerSource(i,r.type,r.source).removeTile(r,n)}removeSource(i,r,n){if(!this.workerSources[i]||!this.workerSources[i][r.type]||!this.workerSources[i][r.type][r.source])return;const o=this.workerSources[i][r.type][r.source];delete this.workerSources[i][r.type][r.source],void 0!==o.removeSource?o.removeSource(r,n):n()}loadWorkerSource(i,r,n){try{this.self.importScripts(r.url),n()}catch(o){n(o.toString())}}syncRTLPluginState(r,n,o){try{i.plugin.setState(n);const s=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&null!=s){this.self.importScripts(s);const a=i.plugin.isParsed();o(a?void 0:Error(`RTL Text Plugin failed to import scripts from ${s}`),a)}}catch(l){o(l.toString())}}getAvailableImages(i){let r=this.availableImages[i];return r||(r=[]),r}getLayerIndex(i){let n=this.layerIndexes[i];return n||(n=this.layerIndexes[i]=new r),n}getWorkerSource(i,r,n){return this.workerSources[i]||(this.workerSources[i]={}),this.workerSources[i][r]||(this.workerSources[i][r]={}),this.workerSources[i][r][n]||(this.workerSources[i][r][n]=new this.workerSourceTypes[r]({send:(r,n,o,s,a,l)=>{this.actor.send(r,n,o,i,a,l)},scheduler:this.actor.scheduler},this.getLayerIndex(i),this.getAvailableImages(i),this.isSpriteLoaded[i])),this.workerSources[i][r][n]}getDEMWorkerSource(i,r){return this.demWorkerSources[i]||(this.demWorkerSources[i]={}),this.demWorkerSources[i][r]||(this.demWorkerSources[i][r]=new o),this.demWorkerSources[i][r]}enforceCacheSizeLimit(r,n){i.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(i,r,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new el(self)),el}),s(["./shared"],function(i){let r,n,o,s;function a(i){var r;return"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 i,r,n=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(n);try{r=new Worker(o),i=!0}catch(s){i=!1}return r&&r.terminate(),URL.revokeObjectURL(o),i}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var i=document.createElement("canvas");i.width=i.height=1;var r=i.getContext("2d");if(!r)return!1;var n=r.getImageData(0,0,1,1);return n&&n.width===i.width}()&&(void 0===l[r=i&&i.failIfMajorPerformanceCaveat]&&(l[r]=function(i){var r,n,o,s=(r=document.createElement("canvas"),(n=Object.create(a.webGLContextAttributes)).failIfMajorPerformanceCaveat=i,r.getContext("webgl",n)||r.getContext("experimental-webgl",n));if(!s)return!1;try{o=s.createShader(s.VERTEX_SHADER)}catch(l){return!1}return!(!o||s.isContextLost())&&(s.shaderSource(o,"void main() {}"),s.compileShader(o),!0===s.getShaderParameter(o,s.COMPILE_STATUS))}(r)),!!l[r]&&!document.documentMode)}var l={};function c(i,r){var n=r[0],o=r[1],s=r[2],a=r[3],l=n*a-s*o;return l?(i[0]=a*(l=1/l),i[1]=-o*l,i[2]=-s*l,i[3]=n*l,i):null}function h(i,r){if(Array.isArray(i)){if(!Array.isArray(r)||i.length!==r.length)return!1;for(let n=0;n{i.window.removeEventListener("click",f,!0)},0)},u.mousePos=function(i,r){const n=i.getBoundingClientRect();return m(i,n,r)},u.touchPos=function(i,r){const n=i.getBoundingClientRect(),o=[];for(let s=0;s=0?0:r.button};class _ extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(i){if(this.loaded!==i&&(this.loaded=i,i)){for(const{ids:r,callback:n}of this.requestors)this._notify(r,n);this.requestors=[]}}getImage(i){return this.images[i]}addImage(i,r){this._validate(i,r)&&(this.images[i]=r)}_validate(r,n){let o=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new i.ErrorEvent(Error(`Image "${r}" has invalid "content" value`))),o=!1),o}_validateStretch(i,r){if(!i)return!0;let n=0;for(const o of i){if(o[0]{this.ready=!0})}broadcast(r,n,o){i.asyncAll(this.actors,(i,o)=>{i.send(r,n,o)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}function C(r,n,o){return n*(i.EXTENT/(r.tileSize*Math.pow(2,o-r.tileID.overscaledZ)))}A.Actor=i.Actor;class z{constructor(i,r,n){this.context=i;const o=i.gl;this.buffer=o.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const k={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class P{constructor(i,r,n,o){this.length=r.length,this.attributes=n,this.itemSize=r.bytesPerElement,this.dynamicDraw=o,this.context=i;const s=i.gl;this.buffer=s.createBuffer(),i.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete r.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,r){for(let n=0;no.pointCoordinate3D(i)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(r,n){let o,s;if(r instanceof i.pointGeometry||"number"==typeof r[0]){const a=i.pointGeometry.convert(r);o=[i.pointGeometry.convert(r)],s=n.isPointAboveHorizon(a)}else{const l=i.pointGeometry.convert(r[0]),c=i.pointGeometry.convert(r[1]);o=[l,c],s=i.polygonizeBounds(l,c).every(i=>n.isPointAboveHorizon(i))}return new eg(o,n.getCameraPoint(),s,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(r){return i.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const n=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],s=i.polygonizeBounds(n,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(s[3]=this.cameraPoint)),i.bufferConvexPolygon(s,r)}containsTile(r,n,o){var s;const a=r.queryPadding+1,l=r.tileID.wrap,c=o?this._bufferedCameraMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)):this._bufferedScreenMercator(a,n).map(n=>i.getTilePoint(r.tileTransform,n,l)),h=this.screenGeometryMercator.map(n=>i.getTileVec3(r.tileTransform,n,l)),u=h.map(r=>new i.pointGeometry(r[0],r[1])),d=n.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),p=i.getTileVec3(r.tileTransform,d,l),f=h.map(r=>{const n=i.sub(r,r,p);return i.normalize(n,n),new i.Ray(p,n)}),m=C(r,1,n.zoom);if(i.polygonIntersectsBox(c,0,0,i.EXTENT,i.EXTENT))return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:((s=i.getBounds(c)).min.x=i.clamp(s.min.x,0,i.EXTENT),s.min.y=i.clamp(s.min.y,0,i.EXTENT),s.max.x=i.clamp(s.max.x,0,i.EXTENT),s.max.y=i.clamp(s.max.y,0,i.EXTENT),s),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(i,r){const n=100*i|0;if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{const o=this.bufferedScreenGeometry(i).map(i=>r.pointCoordinate3D(i));return this._screenRaycastCache[n]=o,o}}_bufferedCameraMercator(i,r){const n=100*i|0;if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{const o=this.bufferedCameraGeometry(i).map(i=>r.pointCoordinate3D(i));return this._cameraRaycastCache[n]=o,o}}}function ey(r,n,o){const s=function(s,a){if(s)return o(s);if(a){const l=i.pick(i.extend(a,r),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);a.vector_layers&&(l.vectorLayers=a.vector_layers,l.vectorLayerIds=l.vectorLayers.map(i=>i.id)),l.tiles=n.canonicalizeTileset(l,r.url),o(null,l)}};return r.url?i.getJSON(n.transformRequest(n.normalizeSourceURL(r.url),i.ResourceType.Source),s):i.exported.frame(()=>s(null,r))}class ex{constructor(r,n,o){this.bounds=i.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(i){return Array.isArray(i)&&4===i.length?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}contains(r){const n=Math.pow(2,r.z),o=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*n),s=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*n),a=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*n),l=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*n);return r.x>=o&&r.x=s&&r.y{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(r,n){const o=i.exported.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(o,s,a,l)=>{if(delete r.request,r.aborted)r.state="unloaded",n(null);else if(o)r.state="errored",n(o);else if(s){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:a,expires:l});const c=this.map.painter.context,h=c.gl;r.texture=this.map.painter.getTileTexture(s.width),r.texture?r.texture.update(s,{useMipmap:!0}):(r.texture=new i.Texture(c,s,h.RGBA,{useMipmap:!0}),r.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),r.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),n(null)}})}abortTile(i,r){i.request&&(i.request.cancel(),delete i.request),r()}unloadTile(i,r){i.texture&&this.map.painter.saveTileTexture(i.texture),r()}hasTransition(){return!1}}function eb(r,n,o,s,a,l,c,h){const u=[r,o,a,n,s,l,1,1,1],d=[c,h,1],p=i.adjoint([],u),[f,m,_]=i.transformMat3(d,d,i.transpose(p,p));return i.multiply(u,[f,0,0,0,m,0,0,0,_],u)}class ew extends i.Evented{constructor(i,r,n,o){super(),this.id=i,this.dispatcher=n,this.coordinates=r.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=r}load(r,n){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(o,s)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):s&&(this.image=i.exported.getImageData(s),this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),n&&n(),this._finishLoading())})}loaded(){return this._loaded}updateImage(i){return this.image&&i.url&&(this.options.url=i.url,this.load(i.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(i){this.map=i,this.load()}setCoordinates(r){this.coordinates=r,delete this._boundsArray;const n=r.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(r){let n=1/0,o=1/0,s=-1/0,a=-1/0;for(const l of r)n=Math.min(n,l.x),o=Math.min(o,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);const c=Math.max(s-n,a-o),h=Math.max(0,Math.floor(-Math.log(c)/Math.LN2)),u=Math.pow(2,h);return new i.CanonicalTileID(h,Math.floor((n+s)/2*u),Math.floor((o+a)/2*u))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const r=i.tileTransform(this.tileID,this.map.transform.projection),[n,o,s,a]=this.coordinates.map(n=>{const o=r.projection.project(n[0],n[1]);return i.getTilePoint(r,o)._round()});return this.perspectiveTransform=function(r,n,o,s,a,l,c,h,u,d){const p=eb(0,0,r,0,0,n,r,n),f=eb(o,s,a,l,c,h,u,d);return i.multiply(f,i.adjoint(p,p),f),[f[6]/f[8]*r/i.EXTENT,f[7]/f[8]*n/i.EXTENT]}(this.width,this.height,n.x,n.y,o.x,o.y,a.x,a.y,s.x,s.y),this._boundsArray=new i.StructArrayLayout4i8,this._boundsArray.emplaceBack(n.x,n.y,0,0),this._boundsArray.emplaceBack(o.x,o.y,i.EXTENT,0),this._boundsArray.emplaceBack(a.x,a.y,0,i.EXTENT),this._boundsArray.emplaceBack(s.x,s.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const r=this.map.painter.context,n=r.gl;for(const o in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new i.Texture(r,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}loadTile(i,r){this.tileID&&this.tileID.equals(i.tileID.canonical)?(this.tiles[String(i.tileID.wrap)]=i,i.buckets={},r(null)):(i.state="errored",r(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const eT={vector:class extends i.Evented{constructor(r,n,o,s){if(super(),this.id=r,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(n,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ey(this._options,this.map._requestManager,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(i.extend(this,n),n.bounds&&(this.tileBounds=new ex(n.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}setSourceProperty(i){this._tileJSONRequest&&this._tileJSONRequest.cancel(),i();const r=this.map.style._getSourceCaches(this.id);for(const n of r)n.clearTiles();this.load()}setTiles(i){return this.setSourceProperty(()=>{this._options.tiles=i}),this}setUrl(i){return this.setSourceProperty(()=>{this.url=i,this._options.url=i}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(r,n){const o=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,i.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(s.request.collectResourceTiming=this._collectResourceTiming,r.actor&&"expired"!==r.state)"loading"===r.state?r.reloadCallback=n:r.request=r.actor.send("reloadTile",s,l.bind(this));else if(r.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",s,l.bind(this),void 0,!0);else{const a=i.loadVectorTile.call({deduped:this._deduped},s,(i,n)=>{i||!n?l.call(this,i):(s.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},r.actor&&r.actor.send("loadTile",s,l.bind(this),void 0,!0))},!0);r.request={cancel:a}}function l(o,s){return delete r.request,r.aborted?n(null):o&&404!==o.status?n(o):(s&&s.resourceTiming&&(r.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&r.setExpiryData(s),r.loadVectorData(s,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id})}unloadTile(i){i.unloadVectorData(),i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ev,"raster-dem":class extends ev{constructor(r,n,o,s){super(r,n,o,s),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(r,o){const s=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function a(i,n){i&&(r.state="errored",o(i)),n&&(r.dem=n,r.dem.onDeserialize(),r.needsHillshadePrepare=!0,r.needsDEMTextureUpload=!0,r.state="loaded",o(null))}r.request=i.getImage(this.map._requestManager.transformRequest(s,i.ResourceType.Tile),(function(s,l,c,h){if(delete r.request,r.aborted)r.state="unloaded",o(null);else if(s)r.state="errored",o(s);else if(l){this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:c,expires:h});const u=i.window.ImageBitmap&&l instanceof i.window.ImageBitmap&&(null==n&&(n=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof i.window.createImageBitmap),n),d=1-(l.width-i.prevPowerOfTwo(l.width))/2;d<1||r.neighboringTiles||(r.neighboringTiles=this._getNeighboringTiles(r.tileID));const p=u?l:i.exported.getImageData(l,d),f={uid:r.uid,coord:r.tileID,source:this.id,rawImageData:p,encoding:this.encoding,padding:d};r.actor&&"expired"!==r.state||(r.actor=this.dispatcher.getActor(),r.actor.send("loadDEMTile",f,a.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(r){const n=r.canonical,o=Math.pow(2,n.z),s=(n.x-1+o)%o,a=0===n.x?r.wrap-1:r.wrap,l=(n.x+1+o)%o,c=n.x+1===o?r.wrap+1:r.wrap,h={};return h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y).key]={backfilled:!1},n.y>0&&(h[new i.OverscaledTileID(r.overscaledZ,a,n.z,s,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,r.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},h[new i.OverscaledTileID(r.overscaledZ,c,n.z,l,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new i.ErrorEvent(r));else{const o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),this.fire(new i.Event("data",o)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(r,n){const o=r.actor?"reloadTile":"loadTile";r.actor=this.actor,r.request=this.actor.send(o,{type:this.type,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(i,s)=>(delete r.request,r.unloadVectorData(),r.aborted?n(null):i?n(i):(r.loadVectorData(s,this.map.painter,"reloadTile"===o),n(null))),void 0,"loadTile"===o)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.aborted=!0}unloadTile(i){i.unloadVectorData(),this.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ew{constructor(i,r,n,o){super(i,r,n,o),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const r=this.options;for(const n of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(n,i.ResourceType.Source).url);i.getVideo(this.urls,(r,n)=>{this._loaded=!0,r?this.fire(new i.ErrorEvent(r)):n&&(this.video=n,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(r){if(this.video){const n=this.video.seekable;rn.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=r}}getVideo(){return this.video}onAdd(i){this.map||(this.map=i,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 r=this.map.painter.context,n=r.gl;for(const o in this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(r,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=r.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const s=this.tiles[o];"loaded"!==s.state&&(s.state="loaded",s.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ew,canvas:class extends ew{constructor(r,n,o,s){super(r,n,o,s),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(i=>!Array.isArray(i)||2!==i.length||i.some(i=>"number"!=typeof i))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${r}`,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 i.ErrorEvent(new i.ValidationError(`sources.${r}`,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(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(i){this.map=i,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let r=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,r=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,r=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const n=this.map.painter.context,o=n.gl;for(const s in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,i.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(r||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(n,this.canvas,o.RGBA,{premultiply:!0}),this.tiles){const a=this.tiles[s];"loaded"!==a.state&&(a.state="loaded",a.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const i of[this.canvas.width,this.canvas.height])if(isNaN(i)||i<=0)return!0;return!1}}},eE=function(r,n,o,s){const a=new eT[n.type](r,n,o,s);if(a.id!==r)throw Error(`Expected Source id to be ${r} instead of ${a.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],a),a};function eS(i,r){const n=i.tileID,o=r.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function eI(){return null!=r$.workerClass?new r$.workerClass:new i.window.Worker(r$.workerUrl)}const eM="mapboxgl_preloaded_worker_pool";class eA{constructor(){this.active={}}acquire(i){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[eM]}numActive(){return Object.keys(this.active).length}}function eC(){return o||(o=new eA),o}function ez(r){r=r.slice();const n=Object.create(null);for(let o=0;o{i in n&&(o[i]=n[i])}),o}(r[s],n[r[s].ref]));return r}eA.workerCount=2;const ek={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function eP(i,r,n){n.push({command:ek.addSource,args:[i,r[i]]})}function eD(i,r,n){r.push({command:ek.removeSource,args:[i]}),n[i]=!0}function eL(i,r,n,o,s,a){let l;for(l in r=r||{},i=i||{})i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}));for(l in r)r.hasOwnProperty(l)&&!i.hasOwnProperty(l)&&(h(i[l],r[l])||n.push({command:a,args:[o,l,r[l],s]}))}function eB(i){return i.id}function eR(i,r){return i[r.id]=r,i}class eF{constructor(i,r){this.reset(i,r)}reset(i,r){this.points=i||[],this._distances=[0];for(let n=1;n0?(s-l)/c:0;return this.points[a].mult(1-h).add(this.points[n].mult(h))}}class eO{constructor(i,r,n){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(i/n),this.yCellCount=Math.ceil(r/n);for(let a=0;athis.width||o<0||r>this.height)return!s&&[];const l=[];if(i<=0&&r<=0&&this.width<=n&&this.height<=o){if(s)return!0;for(let c=0;c0:l}_queryCircle(i,r,n,o,s){const a=i-n,l=i+n,c=r-n,h=r+n;if(l<0||a>this.width||h<0||c>this.height)return!o&&[];const u=[];return this._forEachCell(a,c,l,h,this._queryCellCircle,u,{hitTest:o,circle:{x:i,y:r,radius:n},seenUids:{box:{},circle:{}}},s),o?u.length>0:u}query(i,r,n,o,s){return this._query(i,r,n,o,!1,s)}hitTest(i,r,n,o,s){return this._query(i,r,n,o,!0,s)}hitTestCircle(i,r,n,o){return this._queryCircle(i,r,n,!0,o)}_queryCell(i,r,n,o,s,a,l,c){const h=l.seenUids,u=this.boxCells[s];if(null!==u){const d=this.bboxes;for(const p of u)if(!h.box[p]){h.box[p]=!0;const f=4*p;if(i<=d[f+2]&&r<=d[f+3]&&n>=d[f+0]&&o>=d[f+1]&&(!c||c(this.boxKeys[p]))){if(l.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[p],x1:d[f],y1:d[f+1],x2:d[f+2],y2:d[f+3]})}}}const m=this.circleCells[s];if(null!==m){const _=this.circles;for(const g of m)if(!h.circle[g]){h.circle[g]=!0;const y=3*g;if(this._circleAndRectCollide(_[y],_[y+1],_[y+2],i,r,n,o)&&(!c||c(this.circleKeys[g]))){if(l.hitTest)return a.push(!0),!0;{const x=_[y],v=_[y+1],b=_[y+2];a.push({key:this.circleKeys[g],x1:x-b,y1:v-b,x2:x+b,y2:v+b})}}}}}_queryCellCircle(i,r,n,o,s,a,l,c){const h=l.circle,u=l.seenUids,d=this.boxCells[s];if(null!==d){const p=this.bboxes;for(const f of d)if(!u.box[f]){u.box[f]=!0;const m=4*f;if(this._circleAndRectCollide(h.x,h.y,h.radius,p[m+0],p[m+1],p[m+2],p[m+3])&&(!c||c(this.boxKeys[f])))return a.push(!0),!0}}const _=this.circleCells[s];if(null!==_){const g=this.circles;for(const y of _)if(!u.circle[y]){u.circle[y]=!0;const x=3*y;if(this._circlesCollide(g[x],g[x+1],g[x+2],h.x,h.y,h.radius)&&(!c||c(this.circleKeys[y])))return a.push(!0),!0}}}_forEachCell(i,r,n,o,s,a,l,c){const h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r),d=this._convertToXCellCoord(n),p=this._convertToYCellCoord(o);for(let f=h;f<=d;f++)for(let m=u;m<=p;m++)if(s.call(this,i,r,n,o,this.xCellCount*m+f,a,l,c))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,r,n,o,s,a){const l=o-i,c=s-r,h=n+a;return h*h>l*l+c*c}_circleAndRectCollide(i,r,n,o,s,a,l){const c=(a-o)/2,h=Math.abs(i-(o+c));if(h>c+n)return!1;const u=(l-s)/2,d=Math.abs(r-(s+u));if(d>u+n)return!1;if(h<=c||d<=u)return!0;const p=h-c,f=d-u;return p*p+f*f<=n*n}}const eU=Math.tan(85*Math.PI/180);function eV(r,n,o,s,a,l){let h=i.create();if(o){if("globe"===a.projection.name)h=i.calculateGlobeMatrix(a,a.worldSize/a._projectionScaler,[0,0]),i.multiply$1(h,h,i.globeDenormalizeECEF(i.globeTileBounds(n)));else{const u=c([],l);h[0]=u[0],h[1]=u[1],h[4]=u[2],h[5]=u[3]}s||i.rotateZ(h,h,a.angle)}else i.multiply$1(h,a.labelPlaneMatrix,r);return h}function eN(r,n,o,s,a,l){if(o){if("globe"===a.projection.name){const c=eV(r,n,o,s,a,l);return i.invert(c,c),i.multiply$1(c,r,c),c}{const h=i.clone(r),u=i.identity([]);return u[0]=l[0],u[1]=l[1],u[4]=l[2],u[5]=l[3],i.multiply$1(h,h,u),s||i.rotateZ(h,h,-a.angle),h}}return a.glCoordMatrix}function ej(r,n,o=0){const s=[r.x,r.y,o,1];o?i.transformMat4$1(s,s,n):eJ(s,s,n);const a=s[3];return{point:new i.pointGeometry(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function eG(i,r){return Math.min(.5+i/r*.5,1.5)}function eZ(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=c.glyphStartIndex+c.numGlyphs,y=c.lineStartIndex,x=c.lineStartIndex+c.lineLength,v=r.getoffsetX(c.glyphStartIndex),b=r.getoffsetX(g-1),w=eH(i*v,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);if(!w)return null;const T=eH(i*b,n,o,s,a,l,c.segment,y,x,h,u,d,p,f,!0,m,_);return T?{first:w,last:T}:null}function e$(r,n,o,s){return r.writingMode===i.WritingMode.horizontal&&Math.abs(o.y-n.y)>Math.abs(o.x-n.x)*s?{useVertical:!0}:r.writingMode===i.WritingMode.vertical?n.yeU}(n,o,s)?1===r.flipState?{needsFlipping:!0}:null:n.x>o.x?{needsFlipping:!0}:null}function eq(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){let v;const b=n/24,w=r.lineOffsetX*b,T=r.lineOffsetY*b;if(r.numGlyphs>1){const E=r.glyphStartIndex+r.numGlyphs,S=r.lineStartIndex,I=r.lineStartIndex+r.lineLength,M=eZ(b,h,w,T,o,p,f,r,u,l,m,g,!1,y,x);if(!M)return{notEnoughRoom:!0};const A=ej(M.first.point,c).point,C=ej(M.last.point,c).point;if(s&&!o){const z=e$(r,A,C,_);if(r.flipState=z&&z.needsFlipping?1:2,z)return z}v=[M.first];for(let k=r.glyphStartIndex+1;k0?B.point:eW(f,L,P,1,a,void 0,y,x.canonical),_);if(r.flipState=R&&R.needsFlipping?1:2,R)return R}const F=eH(b*h.getoffsetX(r.glyphStartIndex),w,T,o,p,f,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,u,l,m,g,!1,!1,y,x);if(!F)return{notEnoughRoom:!0};v=[F]}for(const O of v)i.addDynamicAttributes(d,O.point,O.angle);return{}}function eX(r,n,o,s,a){const l=s.projectTilePoint(r.x,r.y,n);if(!a)return ej(l,o,l.z);const c=a(r);return ej(new i.pointGeometry(l.x+c[0],l.y+c[1]),o,l.z+c[2])}function eW(i,r,n,o,s,a,l,c){const h=eX(i.add(i.sub(r)._unit()),c,s,l,a).point,u=n.sub(h);return n.add(u._mult(o/u.mag()))}function eH(r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=s?r-n:r+n;let b=v>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=b>0?h+c:h+c+1,E=a,S=a,I=0,M=0;const A=Math.abs(v),C=[],z=[];let k=l;const P=()=>{const r=T-b;return 0===I?l:new i.pointGeometry(d.getx(r),d.gety(r))},D=()=>eW(P(),k,S,A-I+1,p,m,y,x.canonical);for(;I+M<=A;){if((T+=b)=u)return null;if(S=E,C.push(E),_&&z.push(k||P()),void 0===(E=f[T])){k=new i.pointGeometry(d.getx(T),d.gety(T));const L=eX(k,x.canonical,p,y,m);E=L.signedDistanceFromCamera>0?f[T]=L.point:D()}else k=null;I+=M,M=S.dist(E)}g&&m&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),f[T]=E=void 0===f[T]?E:D(),M=S.dist(E));const B=(A-I)/M,R=E.sub(S),F=R.mult(B)._add(S);o&&F._add(R._unit()._perp()._mult(o*b));const O=w+Math.atan2(E.y-S.y,E.x-S.x);return C.push(F),_&&(k=k||new i.pointGeometry(d.getx(T),d.gety(T)),z.push(function(r,n,o){const s=1-o;return new i.pointGeometry(r.x*s+n.x*o,r.y*s+n.y*o)}(z.length>0?z[z.length-1]:k,k,B))),{point:F,angle:O,path:C,tilePath:z}}const eK=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function eY(i,r){for(let n=0;n[0,0,0],b=new i.pointGeometry(n.tileAnchorX,n.tileAnchorY),w=this.transform.projection.projectTilePoint(n.tileAnchorX,n.tileAnchorY,_.canonical),T=v(b),E=[w.x+T[0],w.y+T[1],w.z+T[2]],S=this.projectAndGetPerspectiveRatio(l,E[0],E[1],E[2],_),{perspectiveRatio:I}=S,M=(d?a/I:a*I)/i.ONE_EM,A=ej(new i.pointGeometry(E[0],E[1]),c,E[2]).point,C=S.signedDistanceFromCamera>0?eZ(M,s,n.lineOffsetX*M,n.lineOffsetY*M,!1,A,b,n,o,c,{},y&&!d?v:null,d&&!!y,this.transform.projection,_):null;let z=!1,k=!1,P=!0;if(C&&!S.aboveHorizon){const D=.5*f*I+m,L=new i.pointGeometry(-100,-100),B=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),R=new eF,F=C.first,O=C.last;let U=[];for(let V=F.path.length-1;V>=1;V--)U.push(F.path[V]);for(let N=1;N{const n=v(rej(i,h));U=G.some(i=>i.signedDistanceFromCamera<=0)?[]:G.map(i=>i.point)}let Z=[];if(U.length>0){const $=U[0].clone(),q=U[0].clone();for(let X=1;X=L.x&&q.x<=B.x&&$.y>=L.y&&q.y<=B.y?[U]:q.xB.x||q.yB.y?[]:i.clipLine([U],L.x,L.y,B.x,B.y)}for(const W of Z){R.reset(W,.25*D);let H=0;H=R.length<=.5*D?1:Math.ceil(R.paddedLength/j)+1;for(let K=0;K0){i.transformMat4$1(l,l,r);let h=!1;this.fogState&&a&&(h=function(r,n,o,s,a,l){const c=l.calculateFogTileMatrix(a),h=[n,o,s];return i.transformMat4(h,h,c),T(r,h,l.pitch,l._fov)}(this.fogState,n,o,s||0,a.toUnwrapped(),this.transform)>.9),c=l[2]>l[3]||h}else eJ(l,l,r);return{point:new i.pointGeometry((l[0]/l[3]+1)/2*this.transform.width+100,(-l[1]/l[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/l[3]*.5,1.5),signedDistanceFromCamera:l[3],aboveHorizon:c}}isOffscreen(i,r,n,o){return n<100||i>=this.screenRightBoundary||o<100||r>this.screenBottomBoundary}isInsideGrid(i,r,n,o){return n>=0&&i=0&&ri.collisionGroupID===r}}return this.collisionGroups[i]}}function e6(r,n,o,s,a){const{horizontalAlign:l,verticalAlign:c}=i.getAnchorAlignment(r),h=i.evaluateVariableOffset(r,s);return new i.pointGeometry(-(l-.5)*n+h[0]*a,-(c-.5)*o+h[1]*a)}function e8(r,n,o,s,a){const l=new i.pointGeometry(r,n);return o&&l._rotate(s?a:-a),l}class e9{constructor(i,r,n,o,s){this.transform=i.clone(),this.collisionIndex=new eQ(this.transform,s),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new e4(n),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,n,o,s){const a=o.getBucket(n),l=o.latestFeatureIndex;if(!a||!l||n.id!==a.layerIds[0])return;const c=a.layers[0].layout,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/i.EXTENT,p=o.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(p),m="map"===c.get("text-pitch-alignment"),_="map"===c.get("text-rotation-alignment");n.compileFilter();const g=n.dynamicFilter(),y=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(o),v=eV(f,o.tileID.canonical,m,_,this.transform,x);let b=null;if(m){const w=eN(f,o.tileID.canonical,m,_,this.transform,x);b=i.multiply$1([],this.transform.labelPlaneMatrix,w)}let T=null;g&&o.latestFeatureIndex&&(T={unwrappedTileID:p,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new e5(a.bucketInstanceId,l,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:c,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:T,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(s)for(const S of a.sortKeyRanges){const{sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A}=S;r.push({sortKey:I,symbolInstanceStart:M,symbolInstanceEnd:A,parameters:E})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E})}attemptAnchorPlacement(i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=[p.textOffset0,p.textOffset1],b=e6(i,n,o,v,s),w=this.collisionIndex.placeCollisionBox(s,r,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate);if((!g||0!==this.collisionIndex.placeCollisionBox(m.getSymbolInstanceIconSize(x,this.transform.zoom,f),g,e8(b.x,b.y,a,l,this.transform.angle),d,c,h,u.predicate).box.length)&&w.box.length>0){let T;return this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(T=this.prevPlacement.variableOffsets[p.crossTileID].anchor),this.variableOffsets[p.crossTileID]={textOffset:v,width:n,height:o,anchor:i,textScale:s,prevAnchor:T},this.markUsedJustification(m,i,p,_),m.allowVerticalPlacement&&(this.markUsedOrientation(m,_,p),this.placedOrientations[p.crossTileID]=_),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(r,n,o,s){const{bucket:a,layout:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:p,holdingForFade:f,collisionBoxArray:m,partiallyEvaluatedTextSize:_,partiallyEvaluatedIconSize:g,collisionGroup:y}=r.parameters,x=l.get("text-optional"),v=l.get("icon-optional"),b=l.get("text-allow-overlap"),w=l.get("icon-allow-overlap"),T="map"===l.get("text-rotation-alignment"),E="map"===l.get("text-pitch-alignment"),S="none"!==l.get("icon-text-fit"),I="viewport-y"===l.get("symbol-z-order"),M=b&&(w||!a.hasIconData()||v),A=w&&(b||!a.hasTextData()||x);!a.collisionArrays&&m&&a.deserializeCollisionBoxes(m),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,m);const C=(r,s,m)=>{if(d){const I={zoom:this.transform.zoom,pitch:this.transform.pitch};let C=null;if(d.dynamicFilterNeedsFeature){const z=this.retainedQueryData[a.bucketInstanceId];C=d.featureIndex.loadFeature({featureIndex:r.featureIndex,bucketIndex:z.bucketIndex,sourceLayerIndex:z.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,d.dynamicFilter)(I,C,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new i.pointGeometry(r.tileAnchorX,r.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[r.crossTileID]=new e2(!1,!1,!1,!0),void(n[r.crossTileID]=!0)}if(n[r.crossTileID])return;if(f)return void(this.placements[r.crossTileID]=new e2(!1,!1,!1));let k=!1,P=!1,D=!0,L=null,B={box:null,offscreen:null},R={box:null,offscreen:null},F=null,O=null,U=null,V=0,N=0,j=0;m.textFeatureIndex?V=m.textFeatureIndex:r.useRuntimeCollisionCircles&&(V=r.featureIndex),m.verticalTextFeatureIndex&&(N=m.verticalTextFeatureIndex);const G=i=>{i.tileID=this.retainedQueryData[a.bucketInstanceId].tileID,(this.transform.elevation||i.elevation)&&(i.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[a.bucketInstanceId].tileID,i.tileAnchorX,i.tileAnchorY):0)},Z=m.textBox;if(Z){G(Z);const $=n=>{let o=i.WritingMode.horizontal;if(a.allowVerticalPlacement&&!n&&this.prevPlacement){const s=this.prevPlacement.placedOrientations[r.crossTileID];s&&(this.placedOrientations[r.crossTileID]=s,o=s,this.markUsedOrientation(a,o,r))}return o},q=(n,o)=>{if(a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&m.verticalTextBox){for(const s of a.writingModes)if(s===i.WritingMode.vertical?R=B=o():B=n(),B&&B.box&&B.box.length)break}else B=n()};if(l.get("text-variable-anchor")){let X=l.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[r.crossTileID]){const W=this.prevPlacement.variableOffsets[r.crossTileID];X.indexOf(W.anchor)>0&&(X=X.filter(i=>i!==W.anchor)).unshift(W.anchor)}const H=(i,n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=(i.x2-i.x1)*l+2*i.padding,u=(i.y2-i.y1)*l+2*i.padding,d=S&&!w?n:null;d&&G(d);let f={box:[],offscreen:!1};const m=b?2*X.length:X.length;for(let x=0;x=X.length,r,s,a,o,d,_,g);if(v&&(f=v.placedGlyphBoxes)&&f.box&&f.box.length){k=!0,L=v.shift;break}}return f};q(()=>H(Z,m.iconBox,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return n&&G(n),a.allowVerticalPlacement&&!(B&&B.box&&B.box.length)&&r.numVerticalGlyphVertices>0&&n?H(n,m.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),B&&(k=B.box,D=B.offscreen);const K=$(B&&B.box);if(!k&&this.prevPlacement){const Y=this.prevPlacement.variableOffsets[r.crossTileID];Y&&(this.variableOffsets[r.crossTileID]=Y,this.markUsedJustification(a,Y.anchor,r,K))}}else{const J=(n,o)=>{const l=a.getSymbolInstanceTextSize(_,r,this.transform.zoom,s),h=this.collisionIndex.placeCollisionBox(l,n,new i.pointGeometry(0,0),b,p,c,y.predicate);return h&&h.box&&h.box.length&&(this.markUsedOrientation(a,o,r),this.placedOrientations[r.crossTileID]=o),h};q(()=>J(Z,i.WritingMode.horizontal),()=>{const n=m.verticalTextBox;return a.allowVerticalPlacement&&r.numVerticalGlyphVertices>0&&n?(G(n),J(n,i.WritingMode.vertical)):{box:null,offscreen:null}}),$(B&&B.box&&B.box.length)}}if(k=(F=B)&&F.box&&F.box.length>0,D=F&&F.offscreen,r.useRuntimeCollisionCircles){const Q=a.text.placedSymbolArray.get(r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex),ee=i.evaluateSizeForFeature(a.textSizeData,_,Q),et=l.get("text-padding");O=this.collisionIndex.placeCollisionCircles(b,Q,a.lineVertexArray,a.glyphOffsetArray,ee,c,h,u,o,E,y.predicate,r.collisionCircleDiameter*ee/i.ONE_EM,et,this.retainedQueryData[a.bucketInstanceId].tileID),k=b||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(m.iconFeatureIndex&&(j=m.iconFeatureIndex),m.iconBox){const ei=r=>{G(r);const n=S&&L?e8(L.x,L.y,T,E,this.transform.angle):new i.pointGeometry(0,0),o=a.getSymbolInstanceIconSize(g,this.transform.zoom,s);return this.collisionIndex.placeCollisionBox(o,r,n,w,p,c,y.predicate)};P=R&&R.box&&R.box.length&&m.verticalIconBox?(U=ei(m.verticalIconBox)).box.length>0:(U=ei(m.iconBox)).box.length>0,D=D&&U.offscreen}const er=x||0===r.numHorizontalGlyphVertices&&0===r.numVerticalGlyphVertices,en=v||0===r.numIconVertices;if(er||en?en?er||(P=P&&k):k=P&&k:P=k=P&&k,k&&F&&F.box&&this.collisionIndex.insertCollisionBox(F.box,l.get("text-ignore-placement"),a.bucketInstanceId,R&&R.box&&N?N:V,y.ID),P&&U&&this.collisionIndex.insertCollisionBox(U.box,l.get("icon-ignore-placement"),a.bucketInstanceId,j,y.ID),O&&(k&&this.collisionIndex.insertCollisionCircles(O.circles,l.get("text-ignore-placement"),a.bucketInstanceId,V,y.ID),o)){const eo=a.bucketInstanceId;let es=this.collisionCircleArrays[eo];void 0===es&&(es=this.collisionCircleArrays[eo]=new e3);for(let ea=0;ea=0;--k){const P=z[k];C(a.symbolInstances.get(P),P,a.collisionArrays[P])}}else for(let D=r.symbolInstanceStart;D=0&&(r.text.placedSymbolArray.get(c).crossTileID=a>=0&&c!==a?0:o.crossTileID)}markUsedOrientation(r,n,o){const s=n===i.WritingMode.horizontal||n===i.WritingMode.horizontalOnly?n:0,a=n===i.WritingMode.vertical?n:0,l=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const c of l)r.text.placedSymbolArray.get(c).placedOrientation=s;o.verticalPlacedTextSymbolIndex&&(r.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let n=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const o=r?r.symbolFadeChange(i):1,s=r?r.opacities:{},a=r?r.variableOffsets:{},l=r?r.placedOrientations:{};for(const c in this.placements){const h=this.placements[c],u=s[c];u?(this.opacities[c]=new e1(u,o,h.text,h.icon,null,h.clipped),n=n||h.text!==u.text.placed||h.icon!==u.icon.placed):(this.opacities[c]=new e1(null,o,h.text,h.icon,h.skipFade,h.clipped),n=n||h.text||h.icon)}for(const d in s){const p=s[d];if(!this.opacities[d]){const f=new e1(p,o,!1,!1);f.isHidden()||(this.opacities[d]=f,n=n||p.text.placed||p.icon.placed)}}for(const m in a)this.variableOffsets[m]||!this.opacities[m]||this.opacities[m].isHidden()||(this.variableOffsets[m]=a[m]);for(const _ in l)this.placedOrientations[_]||!this.opacities[_]||this.opacities[_].isHidden()||(this.placedOrientations[_]=l[_]);n?this.lastPlacementChangeTime=i:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:i)}updateLayerOpacities(i,r){const n={};for(const o of r){const s=o.getBucket(i);s&&o.latestFeatureIndex&&i.id===s.layerIds[0]&&this.updateBucketOpacities(s,n,o.collisionBoxArray)}}updateBucketOpacities(r,n,o){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const s=r.layers[0].layout,a=!!r.layers[0].dynamicFilter(),l=new e1(null,0,!1,!1,!0),c=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=s.get("text-variable-anchor"),d="map"===s.get("text-rotation-alignment"),p="map"===s.get("text-pitch-alignment"),f="none"!==s.get("icon-text-fit"),m=new e1(null,0,c&&(h||!r.hasIconData()||s.get("icon-optional")),h&&(c||!r.hasTextData()||s.get("text-optional")),!0);!r.collisionArrays&&o&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(o);const _=(i,r,n)=>{for(let o=0;o0||b>0,S=x.numIconVertices>0,I=this.placedOrientations[x.crossTileID],M=I===i.WritingMode.vertical,A=I===i.WritingMode.horizontal||I===i.WritingMode.horizontalOnly;if(!E&&!S||T.isHidden()||g++,E){const C=te(T.text);_(r.text,v,M?tt:C),_(r.text,b,A?tt:C);const z=T.text.isHidden();[x.rightJustifiedTextSymbolIndex,x.centerJustifiedTextSymbolIndex,x.leftJustifiedTextSymbolIndex].forEach(i=>{i>=0&&(r.text.placedSymbolArray.get(i).hidden=z||M?1:0)}),x.verticalPlacedTextSymbolIndex>=0&&(r.text.placedSymbolArray.get(x.verticalPlacedTextSymbolIndex).hidden=z||A?1:0);const k=this.variableOffsets[x.crossTileID];k&&this.markUsedJustification(r,k.anchor,x,I);const P=this.placedOrientations[x.crossTileID];P&&(this.markUsedJustification(r,"left",x,P),this.markUsedOrientation(r,P,x))}if(S){const D=te(T.icon);x.placedIconSymbolIndex>=0&&(_(r.icon,x.numIconVertices,M?tt:D),r.icon.placedSymbolArray.get(x.placedIconSymbolIndex).hidden=T.icon.isHidden()),x.verticalPlacedIconSymbolIndex>=0&&(_(r.icon,x.numVerticalIconVertices,A?tt:D),r.icon.placedSymbolArray.get(x.verticalPlacedIconSymbolIndex).hidden=T.icon.isHidden())}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const L=r.collisionArrays[y];if(L){let B=new i.pointGeometry(0,0),R=!0;if(L.textBox||L.verticalTextBox){if(u){const F=this.variableOffsets[w];F?(B=e6(F.anchor,F.width,F.height,F.textOffset,F.textScale),d&&B._rotate(p?this.transform.angle:-this.transform.angle)):R=!1}a&&(R=!T.clipped),L.textBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||M,B.x,B.y),L.verticalTextBox&&e7(r.textCollisionBox.collisionVertexArray,T.text.placed,!R||A,B.x,B.y)}const O=R&&Boolean(!A&&L.verticalIconBox);L.iconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,O,f?B.x:0,f?B.y:0),L.verticalIconBox&&e7(r.iconCollisionBox.collisionVertexArray,T.icon.placed,!O,f?B.x:0,f?B.y:0)}}}if(r.fullyClipped=0===g,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const U=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=U.invProjMatrix,r.placementViewportMatrix=U.viewportMatrix,r.collisionCircleArray=U.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(i){return 0===this.fadeDuration?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return this.stale||i-this.lastPlacementChangeTimei}setStale(){this.stale=!0}}function e7(i,r,n,o,s){i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0),i.emplaceBack(r?1:0,n?1:0,o||0,s||0)}function te(i){if(0===i.opacity&&!i.placed)return 0;if(1===i.opacity&&i.placed)return 4294967295;const r=i.placed?1:0,n=Math.floor(127*i.opacity);return 33554432*n+16777216*r+131072*n+65536*r+512*n+256*r+2*n+r}const tt=0;class ti{constructor(i){this._sortAcrossTiles="viewport-y"!==i.layout.get("symbol-z-order")&&void 0!==i.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(i,r,n,o,s){const a=this._bucketParts;for(;this._currentTileIndexi.sortKey-r.sortKey));this._currentPartIndex{const r=i.exported.now()-s;return!this._forceFullPlacement&&r>2};for(;this._currentPlacementIndex>=0;){const l=n[r[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=c)&&(!l.maxzoom||l.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new ti(l)),this._inProgressLayer.continuePlacement(o[l.source],this.placement,this._showCollisionBoxes,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const tn=512/i.EXTENT/2;class to{constructor(i,r,n){this.tileID=i,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let o=0;oi.overscaledZ)for(const c in l){const h=l[c];h.tileID.isChildOf(i)&&h.findMatches(r.symbolInstances,i,s)}else{const u=l[i.scaledTo(Number(a)).key];u&&u.findMatches(r.symbolInstances,i,s)}}for(let d=0;d{r[i]=!0}),this.layerIndexes)r[n]||delete this.layerIndexes[n]}}const tc=(r,n)=>i.emitValidationErrors(r,n&&n.filter(i=>"source.canvas"!==i.identifier)),th=i.pick(ek,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),tu=i.pick(ek,["setCenter","setZoom","setBearing","setPitch"]),td=function(){const r={},n=i.spec.$version;for(const o in i.spec.$root){const s=i.spec.$root[o];if(s.required){let a=null;null!=(a="version"===o?n:"array"===s.type?[]:{})&&(r[o]=a)}}return r}(),tp={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class tf extends i.Evented{constructor(r,n={}){super(),this.map=r,this.dispatcher=new A(eC(),this),this.imageManager=new _,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(r._requestManager,n.localFontFamily?i.LocalGlyphMode.all:n.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.lineAtlas=new i.LineAtlas(256,512),this.crossTileSymbolIndex=new tl,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const o=this;this._rtlTextPluginCallback=tf.registerForPluginStateChange(r=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:r.pluginStatus,pluginURL:r.pluginURL},(r,n)=>{if(i.triggerPluginCompletionEvent(r),n&&n.every(i=>i))for(const s in o._sourceCaches){const a=o._sourceCaches[s],l=a.getSource().type;"vector"!==l&&"geojson"!==l||a.reload()}})}),this.on("data",i=>{if("source"!==i.dataType||"metadata"!==i.sourceDataType)return;const r=this.getSource(i.sourceId);if(r&&r.vectorLayerIds)for(const n in this._layers){const o=this._layers[n];o.source===r.id&&this._validateLayer(o)}})}loadURL(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const o="boolean"==typeof n.validate?n.validate:!i.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,n.accessToken);const s=this.map._requestManager.transformRequest(r,i.ResourceType.Style);this._request=i.getJSON(s,(r,n)=>{this._request=null,r?this.fire(new i.ErrorEvent(r)):n&&this._load(n,o)})}loadJSON(r,n={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(r,!1!==n.validate)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(td,!1)}_updateLayerCount(i,r){const n=r?1:-1;i.is3D()&&(this._num3DLayers+=n),"circle"===i.type&&(this._numCircleLayers+=n),"symbol"===i.type&&(this._numSymbolLayers+=n)}_load(r,n){if(n&&tc(this,i.validateStyle(r)))return;for(const o in this._loaded=!0,this.stylesheet=r,this.updateProjection(),r.sources)this.addSource(o,r.sources[o],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const s=ez(this.stylesheet.layers);for(let a of(this._order=s.map(i=>i.id),this._layers={},this._serializedLayers={},s))(a=i.createStyleLayer(a)).setEventedParent(this,{layer:{id:a.id}}),this._layers[a.id]=a,this._serializedLayers[a.id]=a.serialize(),this._updateLayerCount(a,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new x(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(i){i?this.stylesheet.projection=i:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const i=this.map.transform.projection,r=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),n=this.map.transform.projection;if(this._loaded&&(n.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),r){if(n.isReprojectedInTileSpace||i.isReprojectedInTileSpace)for(const o in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[o].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(r){this._spriteRequest=function(r,n,o){let s,a,l;const c=i.exported.devicePixelRatio>1?"@2x":"";let h=i.getJSON(n.transformRequest(n.normalizeSpriteURL(r,c,".json"),i.ResourceType.SpriteJSON),(i,r)=>{h=null,l||(l=i,s=r,d())}),u=i.getImage(n.transformRequest(n.normalizeSpriteURL(r,c,".png"),i.ResourceType.SpriteImage),(i,r)=>{u=null,l||(l=i,a=r,d())});function d(){if(l)o(l);else if(s&&a){const r=i.exported.getImageData(a),n={};for(const c in s){const{width:h,height:u,x:d,y:p,sdf:f,pixelRatio:m,stretchX:_,stretchY:g,content:y}=s[c],x=new i.RGBAImage({width:h,height:u});i.RGBAImage.copy(r,x,{x:d,y:p},{x:0,y:0},{width:h,height:u}),n[c]={data:x,pixelRatio:m,sdf:f,stretchX:_,stretchY:g,content:y}}o(null,n)}}return{cancel(){h&&(h.cancel(),h=null),u&&(u.cancel(),u=null)}}}(r,this.map._requestManager,(r,n)=>{if(this._spriteRequest=null,r)this.fire(new i.ErrorEvent(r));else if(n)for(const o in n)this.imageManager.addImage(o,n[o]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(r){const n=this.getSource(r.source);if(!n)return;const o=r.sourceLayer;o&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(o))&&this.fire(new i.ErrorEvent(Error(`Source layer "${o}" does not exist on source "${n.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(i){const r=[];for(const n of i){const o=this._layers[n];"custom"!==o.type&&r.push(o.serialize())}return r}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(i){return!!this.terrain&&tp[i.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(r){if(!this._loaded)return;const n=this._changed;if(this._changed){const o=Object.keys(this._updatedLayers),s=Object.keys(this._removedLayers);for(const a in(o.length||s.length)&&this._updateWorkerLayers(o,s),this._updatedSources){const l=this._updatedSources[a];"reload"===l?this._reloadSource(a):"clear"===l&&this._clearSource(a)}for(const c in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[c].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const u in this._sourceCaches){const d=this._sourceCaches[u];h[u]=d.used,d.used=!1}for(const p of this._order){const f=this._layers[p];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const m=this._getLayerSourceCache(f);m&&(m.used=!0)}const _=this.map.painter;if(_){const g=f.getProgramIds();if(!g)continue;const y=f.getProgramConfiguration(r.zoom);for(const x of g)_.useProgram(x,y)}}for(const v in h){const b=this._sourceCaches[v];h[v]!==b.used&&b.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:b.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const i=Object.keys(this._changedImages);if(i.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],i);this._changedImages={}}}_updateWorkerLayers(i,r){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(i),removedIds:r})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tc(this,i.validateStyle(r)))return!1;(r=i.clone$1(r)).layers=ez(r.layers);const n=(function(i,r){if(!i)return[{command:ek.setStyle,args:[r]}];let n=[];try{if(!h(i.version,r.version))return[{command:ek.setStyle,args:[r]}];h(i.center,r.center)||n.push({command:ek.setCenter,args:[r.center]}),h(i.zoom,r.zoom)||n.push({command:ek.setZoom,args:[r.zoom]}),h(i.bearing,r.bearing)||n.push({command:ek.setBearing,args:[r.bearing]}),h(i.pitch,r.pitch)||n.push({command:ek.setPitch,args:[r.pitch]}),h(i.sprite,r.sprite)||n.push({command:ek.setSprite,args:[r.sprite]}),h(i.glyphs,r.glyphs)||n.push({command:ek.setGlyphs,args:[r.glyphs]}),h(i.transition,r.transition)||n.push({command:ek.setTransition,args:[r.transition]}),h(i.light,r.light)||n.push({command:ek.setLight,args:[r.light]}),h(i.fog,r.fog)||n.push({command:ek.setFog,args:[r.fog]}),h(i.projection,r.projection)||n.push({command:ek.setProjection,args:[r.projection]});const o={},s=[];!function(i,r,n,o){let s;for(s in r=r||{},i=i||{})i.hasOwnProperty(s)&&(r.hasOwnProperty(s)||eD(s,n,o));for(s in r){var a,l;r.hasOwnProperty(s)&&(i.hasOwnProperty(s)?h(i[s],r[s])||("geojson"===i[s].type&&"geojson"===r[s].type&&function(i,r,n){let o;for(o in i[n])if(i[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;for(o in r[n])if(r[n].hasOwnProperty(o)&&"data"!==o&&!h(i[n][o],r[n][o]))return!1;return!0}(i,r,s)?n.push({command:ek.setGeoJSONSourceData,args:[s,r[s].data]}):(a=s,l=r,eD(a,n,o),eP(a,l,n))):eP(s,r,n))}}(i.sources,r.sources,s,o);const a=[];i.layers&&i.layers.forEach(i=>{o[i.source]?n.push({command:ek.removeLayer,args:[i.id]}):a.push(i)});let l=i.terrain;l&&o[l.source]&&(n.push({command:ek.setTerrain,args:[void 0]}),l=void 0),n=n.concat(s),h(l,r.terrain)||n.push({command:ek.setTerrain,args:[r.terrain]}),function(i,r,n){let o,s,a,l,c,u,d;r=r||[];const p=(i=i||[]).map(eB),f=r.map(eB),m=i.reduce(eR,{}),_=r.reduce(eR,{}),g=p.slice(),y=Object.create(null);for(o=0,s=0;o!(i.command in tu));if(0===n.length)return!1;const o=n.filter(i=>!(i.command in th));if(o.length>0)throw Error(`Unimplemented: ${o.map(i=>i.command).join(", ")}.`);return n.forEach(i=>{"setTransition"!==i.command&&this[i.command].apply(this,i.args)}),this.stylesheet=r,this.updateProjection(),!0}addImage(r,n){if(this.getImage(r))return this.fire(new i.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(r,n),this._afterImageUpdated(r)}updateImage(i,r){this.imageManager.updateImage(i,r)}getImage(i){return this.imageManager.getImage(i)}removeImage(r){if(!this.getImage(r))return this.fire(new i.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(r),this._afterImageUpdated(r)}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,n,o={}){if(this._checkLoaded(),void 0!==this.getSource(r))throw Error("There is already a source with this ID");if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(i.validateStyle.source,`sources.${r}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const s=eE(r,n,this.dispatcher,this);s.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:s.serialize(),sourceId:r}));const a=n=>{const o=(n?"symbol:":"other:")+r,a=this._sourceCaches[o]=new i.SourceCache(o,s,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[r]=a,a.style=this,a.onAdd(this.map)};a(!1),"vector"!==n.type&&"geojson"!==n.type||a(!0),s.onAdd&&s.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const n=this.getSource(r);if(void 0===n)throw Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while layer "${o}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new i.ErrorEvent(Error(`Source "${r}" cannot be removed while terrain is using it.`)));const s=this._getSourceCaches(r);for(const a of s)delete this._sourceCaches[a.id],delete this._updatedSources[a.id],a.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles();delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(i,r){this._checkLoaded(),this.getSource(i).setData(r),this._changed=!0}getSource(i){const r=this._getSourceCache(i);return r&&r.getSource()}addLayer(r,n,o={}){let s;this._checkLoaded();const a=r.id;if(this.getLayer(a))return void this.fire(new i.ErrorEvent(Error(`Layer with id "${a}" already exists on this map`)));if("custom"===r.type){if(tc(this,i.validateCustomStyleLayer(r)))return;s=i.createStyleLayer(r)}else{if("object"==typeof r.source&&(this.addSource(a,r.source),r=i.clone$1(r),r=i.extend(r,{source:a})),this._validate(i.validateStyle.layer,`layers.${a}`,r,{arrayIndex:-1},o))return;s=i.createStyleLayer(r),this._validateLayer(s),s.setEventedParent(this,{layer:{id:a}}),this._serializedLayers[s.id]=s.serialize(),this._updateLayerCount(s,!0)}const l=n?this._order.indexOf(n):this._order.length;if(n&&-1===l)return void this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(l,0,a),this._layerOrderChanged=!0,this._layers[a]=s;const c=this._getLayerSourceCache(s);if(this._removedLayers[a]&&s.source&&c&&"custom"!==s.type){const h=this._removedLayers[a];delete this._removedLayers[a],h.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",c.pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,n){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===n)return;const o=this._order.indexOf(r);this._order.splice(o,1);const s=n?this._order.indexOf(n):this._order.length;n&&-1===s?this.fire(new i.ErrorEvent(Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const n=this._layers[r];if(!n)return void this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const o=this._order.indexOf(r);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=n,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(i){return this._layers[i]}hasLayer(i){return i in this._layers}hasLayerType(i){for(const r in this._layers)if(this._layers[r].type===i)return!0;return!1}setLayerZoomRange(r,n,o){this._checkLoaded();const s=this.getLayer(r);s?s.minzoom===n&&s.maxzoom===o||(null!=n&&(s.minzoom=n),null!=o&&(s.maxzoom=o),this._updateLayer(s)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,n,o={}){this._checkLoaded();const s=this.getLayer(r);if(s){if(!h(s.filter,n))return null==n?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(i.validateStyle.filter,`layers.${s.id}.filter`,n,{layerType:s.type},o)||(s.filter=i.clone$1(n),this._updateLayer(s)))}else this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){return i.clone$1(this.getLayer(r).filter)}setLayoutProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getLayoutProperty(n),o)||(a.setLayoutProperty(n,o,s),this._updateLayer(a)):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,n){const o=this.getLayer(r);if(o)return o.getLayoutProperty(n);this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,n,o,s={}){this._checkLoaded();const a=this.getLayer(r);a?h(a.getPaintProperty(n),o)||(a.setPaintProperty(n,o,s)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new i.ErrorEvent(Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(i,r){return this.getLayer(i).getPaintProperty(r)}setFeatureState(r,n){this._checkLoaded();const o=r.source,s=r.sourceLayer,a=this.getSource(o);if(void 0===a)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const l=a.type;if("geojson"===l&&s)return void this.fire(new i.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===l&&!s)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided.")));const c=this._getSourceCaches(o);for(const h of c)h.setFeatureState(s,r.id,n)}removeFeatureState(r,n){this._checkLoaded();const o=r.source,s=this.getSource(o);if(void 0===s)return void this.fire(new i.ErrorEvent(Error(`The source '${o}' does not exist in the map's style.`)));const a=s.type,l="vector"===a?r.sourceLayer:void 0;if("vector"===a&&!l)return void this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof r.id&&"number"!=typeof r.id)return void this.fire(new i.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const c=this._getSourceCaches(o);for(const h of c)h.removeFeatureState(l,r.id,n)}getFeatureState(r){this._checkLoaded();const n=r.source,o=r.sourceLayer,s=this.getSource(n);if(void 0!==s){if("vector"!==s.type||o)return void 0===r.id&&this.fire(new i.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(o,r.id);this.fire(new i.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const n in this._sourceCaches){const o=this._sourceCaches[n].getSource();r[o.id]||(r[o.id]=o.serialize())}return i.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:r,layers:this._serializeLayers(this._order)},i=>void 0!==i)}_updateLayer(i){this._updatedLayers[i.id]=!0;const r=this._getLayerSourceCache(i);i.source&&!this._updatedSources[i.source]&&r&&"raster"!==r.getSource().type&&(this._updatedSources[i.source]="reload",r.pause()),this._changed=!0,i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const r={},n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if("fill-extrusion"===this._layers[s].type)for(const a of(r[s]=o,i)){const l=a[s];if(l)for(const c of l)n.push(c)}}n.sort((i,r)=>r.intersectionZ-i.intersectionZ);const h=[];for(let u=this._order.length-1;u>=0;u--){const d=this._order[u];if("fill-extrusion"===this._layers[d].type)for(let p=n.length-1;p>=0;p--){const f=n[p].feature;if(r[f.layer.id]{const r=this.getLayer(i);return r&&r.is3D()}):this.has3DLayers(),u=eg.createFromScreenPoints(r,o);for(const d in this._sourceCaches){const p=this._sourceCaches[d].getSource().id;n.layers&&!s[p]||c.push(function(r,n,o,s,a,l,c,h=!1){const u=r.tilesIn(s,c,h);u.sort(eS);const d=[];for(const p of u)d.push({wrappedTileID:p.tile.tileID.wrapped().key,queryResults:p.tile.queryRenderedFeatures(n,o,r._state,p,a,l,function(r,n){const o=i.identity([]);return i.scale(o,o,[.5*r.width,-(.5*r.height),1]),i.translate(o,o,[1,-1,0]),i.multiply$1(o,o,r.calculateProjMatrix(n.toUnwrapped()))}(r.transform,p.tile.tileID),h)});const f=function(i){const r={},n={};for(const o of i){const s=o.queryResults,a=o.wrappedTileID,l=n[a]=n[a]||{};for(const c in s){const h=s[c],u=l[c]=l[c]||{},d=r[c]=r[c]||[];for(const p of h)u[p.featureIndex]||(u[p.featureIndex]=!0,d.push(p))}}return r}(d);for(const m in f)f[m].forEach(i=>{const n=i.feature,o=r.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o});return f}(this._sourceCaches[d],this._layers,this._serializedLayers,u,n,o,h,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,r,n,o,s,a,l){const c={},h=a.queryRenderedSymbols(o),u=[];for(const d of Object.keys(h).map(Number))u.push(l[d]);for(const p of(u.sort(eS),u)){const f=p.featureIndex.lookupSymbolFeatures(h[p.bucketInstanceId],r,p.bucketIndex,p.sourceLayerIndex,s.filter,s.layers,s.availableImages,i);for(const m in f){const _=c[m]=c[m]||[],g=f[m];for(const y of(g.sort((i,r)=>{const n=p.featureSortOrder;if(n){const o=n.indexOf(i.featureIndex);return n.indexOf(r.featureIndex)-o}return r.featureIndex-i.featureIndex}),g))_.push(y)}}for(const x in c)c[x].forEach(r=>{const o=r.feature,s=n(i[x]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=s});return c}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),u.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(r,n){n&&n.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this._getSourceCaches(r);let s=[];for(const a of o)s=s.concat(function(i,r){const n=i.getRenderableIds().map(r=>i.getTileByID(r)),o=[],s={};for(let a=0;a{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,o=n.get();for(const s in r)if(!h(r[s],o[s])){n.set(r),this.stylesheet.fog=r;const a={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};n.updateTransitions(a);break}}else this._createFog(r);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const i=this._order.filter(i=>this.isLayerDraped(this._layers[i])),r=this._order.filter(i=>!this.isLayerDraped(this._layers[i]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...r)}_createTerrain(r,n){const o=this.terrain=new w(r,n);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const s={now:i.exported.now(),transition:i.extend({duration:0},this.stylesheet.transition)};o.updateTransitions(s)}_force3DLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const r=this._layers[i];"symbol"===r.type&&this._updateLayer(r)}}_validate(r,n,o,s,a={}){return(!a||!1!==a.validate)&&tc(this,r.call(i.validateStyle,i.extend({key:n,style:this.serialize(),value:o,styleSpec:i.spec},s)))}_remove(){for(const r in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[r].setEventedParent(null);for(const n in this._sourceCaches)this._sourceCaches[n].clearTiles(),this._sourceCaches[n].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(i){const r=this._getSourceCaches(i);for(const n of r)n.clearTiles()}_reloadSource(i){const r=this._getSourceCaches(i);for(const n of r)n.resume(),n.reload()}_updateSources(i){for(const r in this._sourceCaches)this._sourceCaches[r].update(i)}_generateCollisionBoxes(){for(const i in this._sourceCaches){const r=this._sourceCaches[i];r.resume(),r.reload()}}_updatePlacement(r,n,o,s,a=!1){let l=!1,c=!1;const h={};for(const u of this._order){const d=this._layers[u];if("symbol"!==d.type)continue;if(!h[d.source]){const p=this._getLayerSourceCache(d);if(!p)continue;h[d.source]=p.getRenderableIds(!0).map(i=>p.getTileByID(i)).sort((i,r)=>r.tileID.overscaledZ-i.tileID.overscaledZ||(i.tileID.isLessThan(r.tileID)?-1:1))}const f=this.crossTileSymbolIndex.addLayer(d,h[d.source],r.center.lng,r.projection);l=l||f}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),a=a||this._layerOrderChanged||0===o,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),r.zoom))&&(this.pauseablePlacement=new tr(r,this._order,a,n,o,s,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l)for(const m of this._order){const _=this._layers[m];"symbol"===_.type&&this.placement.updateLayerOpacities(_,h[_.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}getImages(i,r,n){this.imageManager.getImages(r.icons,n),this._updateTilesForChangedImages();const o=i=>{i&&i.setDependencies(r.tileID.key,r.type,r.icons)};o(this._otherSourceCaches[r.source]),o(this._symbolSourceCaches[r.source])}getGlyphs(i,r,n){this.glyphManager.getGlyphs(r.stacks,n)}getResource(r,n,o){return i.makeRequest(n,o)}_getSourceCache(i){return this._otherSourceCaches[i]}_getLayerSourceCache(i){return"symbol"===i.type?this._symbolSourceCaches[i.source]:this._otherSourceCaches[i.source]}_getSourceCaches(i){const r=[];return this._otherSourceCaches[i]&&r.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&r.push(this._symbolSourceCaches[i]),r}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)}}tf.getSourceType=function(i){return eT[i]},tf.setSourceType=function(i,r){eT[i]=r},tf.registerForPluginStateChange=i.registerForPluginStateChange;var tm="\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",t_="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 tg={},ty={};tg=tb("","\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),ty=tb("#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 tx=tb("\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.");var tv={background:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("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:tb("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:tb("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:tb("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:tb("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:tb("#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:tb("#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:tb("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:tb("#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:tb("\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}",t_),skyboxGradient:tb("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}",t_),skyboxCapture:tb("\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:tb("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:tb("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 tb(i,r,n){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,a=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),l=i.match(s),c=r.match(s),h=tm.match(s);let u=c?c.concat(l):l;n||(tg.staticUniforms&&(u=tg.staticUniforms.concat(u)),ty.staticUniforms&&(u=ty.staticUniforms.concat(u))),u&&(u=u.concat(h));const d={};return{fragmentSource:i=i.replace(o,(i,r,n,o,s)=>(d[s]=!0,"define"===r?` #ifndef HAS_UNIFORM_u_${s} varying ${n} ${o} ${s}; #else diff --git a/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js b/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js index 7d0e57ce736f..62e93e750d67 100644 --- a/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js +++ b/crates/swc_ecma_minifier/tests/full/issue-5912-bigdecimal/output.js @@ -1,3 +1 @@ -!function(n){if(void 0===t)var t={};if(void 0===e)var e={};if(e.document||(e.document=t),void 0===r)var r={};function i(){}function o(t){var r=e.bigdecimal[t],i=r;if(r.__init__){for(var o in(i=function(){var n=Array.prototype.slice.call(arguments);return r.__init__(n)}).prototype=r.prototype,r)if(r.hasOwnProperty(o)){if("function"==typeof r[o]&&o.match(/_va$/)){var u=o.replace(/_va$/,"");i[u]=function n(){var t=Array.prototype.slice.call(arguments);return n.inner_method(t)},i[u].inner_method=r[o]}else i[o]=r[o]}}var f=i.prototype;for(var o in f)if(f.hasOwnProperty(o)&&"function"==typeof f[o]&&o.match(/_va$/)){var u=o.replace(/_va$/,"");f[u]=function n(){var t=Array.prototype.slice.call(arguments);return n.inner_method.apply(this,[t])},f[u].inner_method=f[o],delete f[o]}n[t]=i}r.userAgent||(r.userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22"),function(){var n,t,o=e,u=o.document,f=o.__gwtStatsEvent?function(n){return o.__gwtStatsEvent(n)}:null,c=o.__gwtStatsSessionId?o.__gwtStatsSessionId:null;function s(){}function a(){}function h(){}function b(){}function l(){}function g(){}function w(){}function d(){}function _(){}function v(){}function m(){}function y(){}function C(){}function S(){}function M(){}function x(){}function B(){}function A(){}function N(){}function I(){}function E(){}function R(){}function O(){}function D(){}function k(){}function L(){}function U(){}function P(){}function Q(){}function T(){nX()}function j(){nZ()}function F(){tD()}function H(){ej()}function $(){ej()}function V(){ej()}function q(){ej()}function G(){ej()}function z(){ej()}function J(){nW()}function K(){nc(this)}function W(){nc(this)}function Z(n){iP(this,n)}function X(n){this.c=n}function Y(n){this.b=n}function nn(n){this.b=n}function nt(n){this.b=n}function ne(n){ej(),this.f=n}function nr(n){ne.call(this,n)}function ni(n){ne.call(this,n)}function no(n){ne.call(this,n)}function nu(n){ne.call(this,n)}function nf(n){ne.call(this,n)}function nc(n){n.b=new C}function ns(){this.b=new C}function na(){na=l,ut=new w}function nh(){nh=l,t=new nY}function nb(n,t){nh(),n[oy]=t}function nl(n,t){nh(),function(n,t){var e,r,i,u,f,c,s,a,h,b;for(f=0,s=i_(n,om,0),c=o;ft?n:t}function n_(n,t){return!rA(n,t)}function nv(n){this.b=new iS(n)}function nm(){this.b=(rj(),uj)}function ny(){this.b=(iB(),u2)}function nC(n,e){var r;nh(),r=t.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tg(n){return nG(n,15)?n:new n1(n)}function tw(){try{null.a()}catch(n){return n}}function td(n){var t;return(t=new N).d=i$+n,t.c=1,t}function tp(n,t){return nF(n)?n.eQ(t):n===t}function t_(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tv(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function tm(n,t,e){return(iH=new M).l=n,iH.m=t,iH.h=e,iH}function ty(n,t){return nT(n)===nT(t)||null!=n&&tp(n,t)}function tC(n,t){throw new nu("Index: "+n+", Size: "+t)}function tS(n,t){if(!n)throw new G;this.f=t,tR(this,n)}function tM(n,t){if(!n)throw new G;this.f=t,tR(this,n)}function tx(n,t,e,r){ez.call(this,n,t,e),ic(this,r)}function tB(n,t){ez.call(this,n,0,n.length),ic(this,t)}function tA(n,t){ez.call(this,t6(n),0,n.length),ic(this,t)}function tN(n){ne.call(this,"String index out of range: "+n)}function tI(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tE(n,t){ry(n.b,n.b,n.e,t.b,t.e),tW(n),n.c=-2}function tR(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=rr(eA(t)))}function tO(){tO=l,ue=[],ur=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new S,ue,ur)}function tD(){uy||(uy=!0,new T,new j,function(){if(nl(ox,i$),o.bigdecimal.BigDecimal)var n=o.bigdecimal.BigDecimal;o.bigdecimal.BigDecimal=ff(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fD?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new ng,nb(this.__gwt_instance,this))});var t=o.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)o.bigdecimal.BigDecimal[p]=n[p];o.bigdecimal.BigDecimal.ROUND_CEILING=2,o.bigdecimal.BigDecimal.ROUND_DOWN=1,o.bigdecimal.BigDecimal.ROUND_FLOOR=3,o.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,o.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,o.bigdecimal.BigDecimal.ROUND_HALF_UP=4,o.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,o.bigdecimal.BigDecimal.ROUND_UP=0,o.bigdecimal.BigDecimal.__init__=ff(function(n){var t=function(n){var t,e;if(iU(),(e=iI(n))==i8)t=new nk(new nq(n[0].toString()));else if("BigInteger number"==e)t=new tS(new nq(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new te(new nq(n[0].toString()),n[1],new iS(n[2].toString()));else if("BigInteger MathContext"==e)t=new n4(new nq(n[0].toString()),new iS(n[1].toString()));else if(e==oS)t=new n2(t6(n[0].toString()));else if("array number number"==e)t=new ez(t6(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tx(t6(n[0].toString()),n[1],n[2],new iS(n[3].toString()));else if("array MathContext"==e)t=new tB(t6(n[0].toString()),new iS(n[1].toString()));else if(e==ok)t=new eu(n[0]);else if(e==oL)t=new ep(n[0],new iS(n[1].toString()));else if(e==oF)t=new Z(n[0].toString());else if("string MathContext"==e)t=new tA(n[0].toString(),new iS(n[1].toString()));else throw new ne("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nL(t)}(n);return nE(t)}),t.abs_va=ff(function(n){return nE(this.__gwt_instance.s(n))}),t.add_va=ff(function(n){return nE(this.__gwt_instance.t(n))}),t.byteValueExact=ff(function(){return this.__gwt_instance.u()}),t.compareTo=ff(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=ff(function(n){return nE(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=ff(function(n){return nE(this.__gwt_instance.x(n))}),t.doubleValue=ff(function(){return this.__gwt_instance.z()}),t.equals=ff(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=ff(function(){return this.__gwt_instance.A()}),t.hashCode=ff(function(){return this.__gwt_instance.hC()}),t.intValue=ff(function(){return this.__gwt_instance.B()}),t.intValueExact=ff(function(){return this.__gwt_instance.C()}),t.max=ff(function(n){return nE(this.__gwt_instance.F(n.__gwt_instance))}),t.min=ff(function(n){return nE(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=ff(function(n){return nE(this.__gwt_instance.H(n))}),t.movePointRight=ff(function(n){return nE(this.__gwt_instance.I(n))}),t.multiply_va=ff(function(n){return nE(this.__gwt_instance.J(n))}),t.negate_va=ff(function(n){return nE(this.__gwt_instance.K(n))}),t.plus_va=ff(function(n){return nE(this.__gwt_instance.L(n))}),t.pow_va=ff(function(n){return nE(this.__gwt_instance.M(n))}),t.precision=ff(function(){return this.__gwt_instance.q()}),t.remainder_va=ff(function(n){return nE(this.__gwt_instance.N(n))}),t.round=ff(function(n){return nE(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=ff(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=ff(function(n){return nE(this.__gwt_instance.Q(n))}),t.setScale_va=ff(function(n){return nE(this.__gwt_instance.R(n))}),t.shortValueExact=ff(function(){return this.__gwt_instance.S()}),t.signum=ff(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=ff(function(){return nE(this.__gwt_instance.T())}),t.subtract_va=ff(function(n){return nE(this.__gwt_instance.U(n))}),t.toBigInteger=ff(function(){return nE(this.__gwt_instance.V())}),t.toBigIntegerExact=ff(function(){return nE(this.__gwt_instance.W())}),t.toEngineeringString=ff(function(){return this.__gwt_instance.X()}),t.toPlainString=ff(function(){return this.__gwt_instance.Y()}),t.toString=ff(function(){return this.__gwt_instance.tS()}),t.ulp=ff(function(){return nE(this.__gwt_instance.Z())}),t.unscaledValue=ff(function(){return nE(this.__gwt_instance.$())}),t.divideAndRemainder_va=ff(function(n){return nR(this.__gwt_instance.w(n))}),t.longValue=ff(function(){return this.__gwt_instance.E()}),t.longValueExact=ff(function(){return this.__gwt_instance.D()}),o.bigdecimal.BigDecimal.valueOf_va=ff(function(n){var t=function(n){var t,e;if(iU(),(e=iI(n))==ok)t=function(n){if(!isFinite(n)||isNaN(n))throw new nw(os);return new Z(i$+n)}(n[0]);else if(e==ok)t=tZ(e3(n[0]));else if(e==oU)t=ek(e3(n[0]),n[1]);else throw new ne("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nL(t)}(n);return nE(t)}),o.bigdecimal.BigDecimal.log=ff(function(n){iU(),typeof console!==oH&&console.log&&console.log(n)}),o.bigdecimal.BigDecimal.logObj=ff(function(n){iU(),typeof console!==oH&&console.log&&typeof JSON!==oH&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),o.bigdecimal.BigDecimal.ONE=ff(function(){var n=(iU(),new nL(ug));return nE(n)}),o.bigdecimal.BigDecimal.TEN=ff(function(){var n=(iU(),new nL(uw));return nE(n)}),o.bigdecimal.BigDecimal.ZERO=ff(function(){var n=(iU(),new nL(ud));return nE(n)}),nC(fD,o.bigdecimal.BigDecimal)}())}function tk(n,t,e){var r;return(r=new N).d=n+t,r.c=4,r.b=e,r}function tL(n,t,e,r,i){var o;return tJ(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tN(e)}(n.length,t,r),t4(n,t,r)}function tP(n,t){return ib(),t=n.c.c)throw new z;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tC(r,i),t.b[e]}function tj(n,t){return!!nG(t,1)&&String(n)==t}function tF(){ne.call(this,"Add not supported on this collection")}function tH(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function t$(n,t){rK(),this.f=n,this.e=1,this.b=tJ(fd,{6:1},-1,[t])}function tV(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tq(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tG(n,t,e,r){var i,o;return null==t&&(t=oD),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tz(n,t,e,r){var i;return ry(i=tL(fd,{6:1},-1,t,1),n,t,e,r),i}function tJ(n,t,e,r){return tO(),function(n,t,e){tO();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tZ(n){return rA(n,oz)&&n_(n,oX)?uc[nx(n)]:new eo(n,0)}function tX(n,t){return 0==t||0==n.f?n:t>0?e4(n,t):rX(n,-t)}function tY(n,t){return 0==t||0==n.f?n:t>0?rX(n,t):e4(n,-t)}function t1(n){var t;return 0==n.f?-1:((t=eg(n))<<5)+ec(n.b[t])}function t0(n){var t;return 0!=(t=nx(n))?ec(t):ec(nx(rJ(n,32)))+32}function t2(n,t){var e;return 0==(e=eR(n,t)).length?(new d).o(t):tl(e,1)}function t4(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t3(n,t,e,r){var i;return ih(i=tL(fd,{6:1},-1,t+1,1),n,t,e,r),i}function t6(n){var t,e;return t=tL(fJ,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nx(y=iE(ts(e3(b.b[0]),o3),ts(e3(l.b[0]),o3))),0==(C=nx(rU(y,32)))?new t$(v,S):new ti(v,2,tJ(fd,{6:1},-1,[S,C]))):(eq(b.b,g,l.b,w,d=tL(fd,{6:1},-1,_,1)),tW(m=new ti(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=is(t,a.eb(f)),o=is(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iC(iC(u=n(is(a,i),is(o,h)),s),r)).eb(f),iC(iC(s=s.eb(f<<1),u),r))}(n,t))}function et(n,t){var e;if(t.f<=0)throw new nr(oe);return(e=rF(n,t)).f<0?iC(e,t):e}function ee(n){var t;t=new nz,n.d&&n6(t,new nt(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nB(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eU(n.g)),n.d).r()}function ed(n){return n.b<54?new tr(-n.g,n.f):new tM((n.d||(n.d=eU(n.g)),n.d).cb(),n.f)}function ep(n,t){if(!isFinite(n)||isNaN(n))throw new nw(os);iP(this,n.toPrecision(20)),ic(this,t)}function e_(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function ev(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function em(n,t){var e,r;return t?((e=t[oy])||(e=new(r=t.gC(),t9(er(n.b,r)))(t),t[oy]=e),e):null}function ey(n){var t,e;return 32==(e=rH(n.h))?32==(t=rH(n.m))?rH(n.l)+32:t+20-10:e-12}function eC(n){return tm(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eS(){eS=l,ui=tm(4194303,4194303,524287),uo=tm(0,0,524288),uu=e3(1),e3(2),uf=e3(0)}function eM(n,t){ih(n.b,n.b,n.e,t.b,t.e),n.e=nd(np(n.e,t.e)+1,n.b.length),tW(n),n.c=-2}function ex(n,t){var e;e=~~t>>5,n.e+=e+(rH(n.b[n.e-1])-(31&t)>=0?0:1),rC(n.b,n.b,e,31&t),tW(n),n.c=-2}function eB(n,t){var e,r;e=~~t>>5,n.e>>r:0,tW(n))}function eA(n){var t;return t=n.e>1?ta(rL(e3(n.b[1]),32),ts(e3(n.b[0]),o3)):ts(e3(n.b[0]),o3),iE(e3(n.f),t)}function eN(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:n_(ts(e3(n[r]),o3),ts(e3(t[r]),o3))?-1:1}function eI(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eE(n,t,e,r){if(iF=t,n)try{ff(im)()}catch(i){n(t)}else ff(im)()}function eR(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eo(oz,2147483647):new eo(oz,-2147483648)}function eU(n){return(rK(),n<0)?-1!=n?new ro(-1,-n):uC:n<=10?uM[ei(n)]:new ro(1,n)}function eP(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,tm(t,e,r)}function eQ(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function eT(n){var t,e,r;for(r=0,e=tL(fC,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rB(ts(e3(n[r]),o3),ts(e3(i[r]),o3));break}}return u=new ti(1,o+1,n),e&&tE(u,t),tW(u),u}(o,e)}function e$(n,t){var e;return n===t||!!nG(t,17)&&(e=tQ(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eV(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&eg(n)==n.e-1&&(e=~~(e-1)),t-=rH(e))}function eq(n,t,e,r,i){ib(),0!=t&&0!=r&&(1==t?i[r]=rf(i,e,r,n[0]):1==r?i[t]=rf(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nT(n)===nT(t)&&r==i){io(n,r,e);return}for(f=0;f2147483647))return ei(n);throw new nr("Underflow")}function eK(n,t){if(rj(),n<0)throw new no("Digits < 0");if(!t)throw new nf("null RoundingMode");this.b=n,this.c=t}function eW(n){return(rK(),n_(n,oz))?tv(n,oG)?new ri(-1,eP(n)):uC:rB(n,oZ)?new ri(1,n):uM[nx(n)]}function eZ(n){var t;return n_(n,oz)&&(n=tm(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nx(rJ(n,32)))?rH(t):rH(nx(n))+32)}function eX(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),tm(4194303&e,4194303&r,1048575&i)}function eY(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),tm(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-np(e,n.bb())}function e0(n,t){var e;return n===t||!!nG(t,16)&&(e=tQ(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e2(n,t,e){var r,i,o;for(o=oz,r=t-1;r>=0;--r)i=r0(eX(rL(o,32),ts(e3(n[r]),o3)),e),o=e3(nx(rJ(i,32)));return nx(o)}function e4(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rC(r=tL(fd,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tW(o=new ti(n.f,i,r)),o}function e3(n){var t,e;return n>-129&&n<128?(t=n+128,null==o8&&(o8=tL(fE,{6:1},2,256,0)),(e=o8[t])||(e=o8[t]=eC(n)),e):eC(n)}function e6(n){var t,e;return(rK(),n>5)+1,1))[t]=1<<(31&n),new ti(1,t+1,e))}function e5(n){rK(),0==n.length?(this.f=0,this.e=1,this.b=tJ(fd,{6:1},-1,[0])):(this.f=1,this.e=n.length,this.b=n,tW(this))}function e9(n){return 0==n.length||n[0]>iV&&n[n.length-1]>iV?n:n.replace(/^(\s*)/,i$).replace(/\s*$/,i$)}function e7(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function e8(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==l||nH(e,1)))throw new $}return n[t]=e}function rn(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=eH(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=eH(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tL(f5,{6:1},17,8,0),a=n,e8(s,0,t),h=eH(t,t,r,i),u=1;u<=7;++u)e8(s,u,eH(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=eH(a,a,r,i);return a}(f,r,t,e,o),eH(u,(rK(),uS),e,o)}function rs(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nw("Radix out of range");if(0==n.length)throw new nw("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(iM(),uU)[e])),0!=(d=l%u)&&++o,c=tL(fd,{6:1},-1,o,1),r=uL[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:n_(ts(e3(n[i]),o3),ts(e3(t[i]),o3))?-1:1}function rl(n,t){var e,r,i;for(r=tL(fd,{6:1},-1,i=n.e,1),nd(eg(n),eg(t)),e=0;e999999999)throw new nr(oa);return e=n.f*t,0==n.b&&-1!=n.g?eL(e):new tS((n.d||(n.d=eU(n.g)),n.d).db(t),eJ(e))}function rd(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fo[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fi[n]=t,t*=.5}function r_(){r_=l,uR=tJ(fJ,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rv(n){var t;return 0!=n.c?n.c:n.b<54?(t=r2(n.g),n.c=nx(ts(t,oG)),n.c=33*n.c+nx(ts(rJ(t,32),oG)),n.c=17*n.c+ei(n.f),n.c):(n.c=17*n.d.hC()+ei(n.f),n.c)}function rm(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=e_(n*t,0),0!=u&&(i=e_((u<=0?0-u:u)*2,t<=0?0-t:t),o+=r8(1&ei(o),f*(5+i),r)),new tr(o,e)}function ry(n,t,e,r,i){var o,u;for(u=0,o=oz;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rO(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=ei(nU(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eZ(r2(n))}function rE(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eW(rN(eA(e),eA(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rx(n,e),rx(t,r),1==rn(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eW(rN(eA(n),eA(t)));break}if(t.e>1.2*n.e)0!=(t=rF(t,n)).r()&&rx(t,t.bb());else do tE(t,n),rx(t,t.bb());while(rn(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?ex(f,i):(rx(c,r-e0&&ex(f,i-r+e)),e+=i),0!=(i=e1(h,u))&&(ex(h,i),r>=e?ex(c,i):(rx(f,e-r0&&ex(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)):e<=r?(r$(s,h),r$(f,c)):(r$(h,s),r$(c,f)),0==h.r()||0==s.r())throw new nr(ot);return eO(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():is(t,f)),0>f.r()&&(f=iC(f,t)),f}(n,t);for(o=32*t.e,h=eh(t),u=np((b=eh(n)).e,h.e),c=new ti(1,1,tL(fd,{6:1},-1,u+1,1)),(s=new ti(1,1,tL(fd,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rx(h,r),rx(b,i),ex(c,i),e+=r-i):(rx(h,r),rx(b,i),ex(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rn(h,b)>0;)tE(h,b),a=h.bb(),rx(h,a),eM(c,s),ex(s,a),e+=a;for(;0>=rn(h,b)&&(tE(b,h),0!=b.r());)a=b.bb(),rx(b,a),eM(s,c),ex(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new nr(ot);return rn(c,t)>=0&&tE(c,t),c=is(t,c),f=ru(t),e>o&&(c=eH(c,(rK(),uS),t,f),e-=o),c=eH(c,e6(o-e),t,f)}(et(n._(),t),t)).f)throw new nr(ot);return n.f<0?is(t,e):e}function rO(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rD(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eL(e):n.b+t.b<54?new tr(n.g*t.g,eJ(e)):new tS(en((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),eJ(e))}function rk(n,t){var e;if(t<0)throw new nr("Negative exponent");if(0==t)return uS;if(1==t||n.eQ(uS)||n.eQ(uB))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return en(e6(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(ib(),rK(),r=uS,e=n;t>1;t>>=1)(1&t)!=0&&(r=en(r,e)),e=1==e.e?en(e,e):new e5(io(e.b,e.e,tL(fd,{6:1},-1,e.e<<1,1)));return en(r,e)}(n,t)}function rL(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),tm(4194303&r,4194303&i,1048575&o)}function rP(n){switch(iB(),n){case 2:return uZ;case 1:return uX;case 3:return uY;case 5:return u1;case 6:return u0;case 4:return u2;case 7:return u4;case 0:return u3;default:throw new no("Invalid rounding mode")}}function rQ(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new nr(ob);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=eg(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rT(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ia((n.d||(n.d=eU(n.g)),n.d),iv(t)).r()&&++t),n.e=ei(t)),n.e}function rj(){rj=l,uP=new eK(34,(iB(),u0)),uQ=new eK(7,u0),uT=new eK(16,u0),uj=new eK(0,u2),uF=tJ(fJ,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),uH=tJ(fJ,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rF(n,t){var e,r,i,o;if(0==t.f)throw new nr(on);return((o=n.e)!=(e=t.e)?o>e?1:-1:eN(n.b,t.b,o))==-1?n:(r=tL(fd,{6:1},-1,e,1),1==e?r[0]=e2(n.b,o,t.b[0]):r=ik(null,o-e+1,n.b,o,t.b,e),tW(i=new ti(n.f,e,r)),i)}function rH(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16),e+=t=~~(r=(n=~~n>>t)-256)>>16&8,n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function r$(n,t){if(0==n.f)ix(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ih(n.b,n.b,n.e,t.b,t.e):rb(n.b,t.b,n.e,t.e)>0?ry(n.b,n.b,n.e,t.b,t.e):(r5(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=np(n.e,t.e)+1,tW(n),n.c=-2}function rV(n,t){var e;e=rn(n,t),0==n.f?(ix(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ih(n.b,n.b,n.e,t.b,t.e),n.f=e):rb(n.b,t.b,n.e,t.e)>0?ry(n.b,n.b,n.e,t.b,t.e):(r5(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=np(n.e,t.e)+1,tW(n),n.c=-2}function rq(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new nr(oe);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uB:0==r.f&&0==t.f?uS:(t.f<0&&(r=rR(n,e),t=t.cb()),i=e.gb(0)?rc(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rc(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rK(),u=uS,i=eh(t),r=eh(n),n.gb(0)&&eB(i,e-1),eB(r,e),o=i.ab()-1;o>=0;--o)eB(f=eh(u),e),u=en(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eB(u=en(u,r),e);return eB(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e5(tL(fd,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eB(b=en(is(h,a),s),f),b.f<0&&(b=iC(b,e6(f))),iC(a,en(c,b))),r.f<0&&t.gb(0)&&(i=et(en(is(e,uS),i),e)),i)}function rG(n,t){var e,r,i,o,u,f,c;if(i=eg(n),(r=eg(t))>=n.e)return rK(),uB;for(u=tL(fd,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=nd(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new tr(n.g,eJ(t)):new tS((n.d||(n.d=eU(n.g)),n.d),eJ(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),tm(4194303&i,4194303&o,1048575&u)}function rK(){var n;for(n=0,rK=l,uS=new t$(1,1),ux=new t$(1,10),uB=new t$(0,0),uC=new t$(-1,1),uM=tJ(f5,{6:1},17,[uB,uS,new t$(1,2),new t$(1,3),new t$(1,4),new t$(1,5),new t$(1,6),new t$(1,7),new t$(1,8),new t$(1,9),ux]),uA=tL(f5,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tL(fd,{6:1},-1,u=nd(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rK(),uC):(rK(),uB);if(rO(i=tL(fd,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rS(n,t,e):rS(t,n,-e):np(n.b,t.b)+1<54?new tr(n.g+t.g,n.f):new tM(iC((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),n.f)}function r0(n,t){var e,r,i,o,u;return(r=ts(e3(t),o3),rA(n,oz))?(o=iN(n,r,!1),u=n3(n,r)):(o=iN(e=rU(n,1),i=e3(~~t>>>1),!1),u=eX(rL(u=n3(e,i),1),ts(n,oJ)),(1&t)!=0&&(rB(o,u)?rB(eY(o,u),r)?(u=eX(u,eY(rL(r,1),o)),o=eY(o,oK)):(u=eX(u,eY(r,o)),o=eY(o,oJ)):u=eY(u,o))),ta(rL(u,32),ts(o,o3))}function r2(n){var t,e,r,i;return isNaN(n)?(eS(),uf):n<-0x8000000000000000?(eS(),uo):n>=0x7fffffffffffffff?(eS(),ui):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=ei(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=ei(n/4194304),n-=4194304*t),i=tm(ei(n),t,e),r&&eQ(i),i)}function r4(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iK;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iz+r4(eP(n));for(e=n,r=i$;!(0==e.l&&0==e.m&&0==e.h);){if(e=iN(e,e3(1e9),!0),t=i$+nx(o7),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iK+t;r=t+r}return r}function r3(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new nr(on);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iN(g=ts(e3(S[0]),o3),w=ts(e3(l),o3),!1),v=n3(g,w),x!=i&&(d=eP(d)),x<0&&(v=eP(v)),tJ(f5,{6:1},17,[eW(d),eW(v)])):(_=tL(fd,{6:1},-1,M,1),m=tJ(fd,{6:1},-1,[ir(_,S,M,l)]),y=new ti(x==i?1:-1,M,_),C=new ti(x,1,m),tW(y),tW(C),tJ(f5,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eN(a,e,h))<0)?tJ(f5,{6:1},17,[uB,n]):(b=n.f,f=ik(o=tL(fd,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new ti(b==i?1:-1,u,o),s=new ti(b,r,f),tW(c),tW(s),tJ(f5,{6:1},17,[c,s]))}function r6(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eU(n.g)),n.d;if(n.f<0)return en((n.d||(n.d=eU(n.g)),n.d),iv(-n.f));if(n.f>(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eU(n.g)),n.d).bb()||0!=(t=r3((n.d||(n.d=eU(n.g)),n.d),iv(n.f)))[1].r())throw new nr(ol);return t[0]}function r5(n,t,e,r,i){var o,u;if(o=oz,e36)throw new nw("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nw(oc+n+iq);return i}function r7(n){var t,e;if(0==n.f)return rK(),uC;if(e$(n,(rK(),uC)))return uB;if(e=tL(fd,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function it(n,t){var e,r,i,o,u,f,c,s;if(c=0==n.f?1:n.f,u=tL(fd,{6:1},-1,f=np((o=~~t>>5)+1,n.e)+1,1),e=1<<(31&t),ix(n.b,0,u,0,n.e),n.f<0){if(o>=n.e)u[o]=e;else if(o>(r=eg(n)))u[o]^=e;else if(o=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rq(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rA(a=ta(rL(s,32),ts(e3(t[f]),o3)),oz)?(c=iN(a,o,!1),s=n3(a,o)):(c=iN(i=rU(a,1),u=e3(~~r>>>1),!1),s=eX(rL(s=n3(i,u),1),ts(a,oJ)),(1&r)!=0&&(rB(c,s)?rB(eY(c,s),o)?(s=eX(s,eY(rL(o,1),c)),c=eY(c,oK)):(s=eX(s,eY(o,c)),c=eY(c,oJ)):s=eY(s,c))),n[f]=nx(ts(c,o3));return nx(s)}function ii(n,t){var e,r,i,o,u,f,c;if(u=tL(fd,{6:1},-1,f=np(n.e,t.e),1),i=eg(n),e=r=eg(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=nd(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nU((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=en(u,iv(r))),rn(o,u))}function ic(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r2(ub[r]),b=eY(r2(c.f),e3(r)),h=iN(g=r2(c.g),l,!1),tv(a=n3(g,l),oz)&&(s=t_(eY(rL(n_(a,oz)?eP(a):a,1),l),oz)?0:n_(eY(rL(n_(a,oz)?eP(a):a,1),l),oz)?-1:1,h=eX(h,e3(r8(1&nx(h),(t_(a,oz)?0:n_(a,oz)?-1:1)*(5+s),t.c))),n8(rr(n_(h,oz)?eP(h):h))>=t.b&&(h=nP(h,oZ),b=eY(b,oJ))),c.f=eJ(rr(b)),c.e=t.b,c.g=rr(h),c.b=eZ(h),c.d=null;return}f=iv(r),i=r3((n.d||(n.d=eU(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rn(eF(i[1]._()),f),0!=(e=r8(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&e8(i,0,iC(i[0],eW(e3(e)))),new nk(i[0]).q()>o&&(e8(i,0,ia(i[0],(rK(),ux))),--u)),n.f=eJ(u),n.e=o,tR(n,i[0])}}function is(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ts(e3(n.b[0]),o3),r=ts(e3(t.b[0]),o3),u<0&&(e=eP(e)),c<0&&(r=eP(r)),eW(eY(e,r));if(-1==(i=o!=f?o>f?1:-1:eN(n.b,t.b,o)))h=-c,a=u==c?tz(t.b,f,n.b,o):t3(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rK(),uB;a=tz(n.b,o,t.b,f)}else a=t3(n.b,o,t.b,f);return tW(s=new ti(h,a.length,a)),s}function ia(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new nr(on);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nP(ts(e3(n.b[0]),o3),ts(e3(t.b[0]),o3)),s!=i&&(a=eP(a)),eW(a)):0==(e=c!=r?c>r?1:-1:eN(n.b,t.b,c))?s==i?uS:uC:-1==e?uB:(o=tL(fd,{6:1},-1,u=c-r+1,1),1==r?ir(o,n.b,c,t.b[0]):ik(o,u,n.b,c,t.b,r),tW(f=new ti(s==i?1:-1,u,o)),f)}function ih(n,t,e,r,i){var o,u;if(o=eX(ts(e3(t[0]),o3),ts(e3(r[0]),o3)),n[0]=nx(o),o=rJ(o,32),e>=i){for(u=1;u0){if(i0?u=tP(u,ei(i)):i<0&&(o=tP(o,ei(-i))),iw(o,u,e,r)}function ig(n,t){var e,r,i,o,u,f,c;if(r=eg(t),(i=eg(n))>=t.e)return t;if(u=tL(fd,{6:1},-1,f=t.e,1),rt.ab()?(c=eA(s),o=eA(t),i=t_(eY(rL(n_(c,oz)?eP(c):c,1),n_(o,oz)?eP(o):o),oz)?0:n_(eY(rL(n_(c,oz)?eP(c):c,1),n_(o,oz)?eP(o):o),oz)?-1:1,i=r8(f.gb(0)?1:0,a*(5+i),r)):(i=rn(eF(s._()),t._()),i=r8(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return ek(eX(eA(f),e3(i)),e);f=iC(f,eW(e3(i)))}return new tS(f,e)}function id(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v;if(iM(),(u=n_(n,oz))&&(n=eP(n)),t_(n,oz))switch(t){case 0:return iK;case 1:return iZ;case 2:return iX;case 3:return iY;case 4:return i1;case 5:return i0;case 6:return i2;default:return s=new K,t<0?s.b.b+=i3:s.b.b+=i4,b=s.b,b.b+=-2147483648==t?"2147483648":i$+-t,s.b.b}c=tL(fJ,{6:1},-1,19,1),e=18,h=n;do f=h,h=nP(h,oZ),c[--e]=65535&nx(eX(o1,eY(f,iE(h,oZ))));while(tv(h,oz))if(r=eY(eY(eY(oY,e3(e)),e3(t)),oJ),0==t)return u&&(c[--e]=45),tU(c,e,18-e);if(t>0&&rA(r,oq)){if(rA(r,oz)){for(o=17,i=e+nx(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tU(c,e,18-e+1)}for(o=2;n_(e3(o),eX(eP(r),oJ));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tU(c,e,18-e)}return(a=e+1,s=new W,u&&(s.b.b+=iz),18-a>=1)?(tI(s,c[e]),s.b.b+=iJ,l=s.b,g=tU(c,e+1,18-e-1),l.b+=g):(w=s.b,d=tU(c,e,18-e),w.b+=d),s.b.b+=of,rB(r,oz)&&(s.b.b+=iG),_=s.b,v=i$+r4(r),_.b+=v,s.b.b}(r2(n.g),ei(n.f)),n.i):(i=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eU(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new K).b,u.b+=i,n.f>0&&r>=-6?r>=0?n9(o,e-ei(n.f),iJ):(tt(o.b,t-1,t-1,iW),n9(o,t+1,tU(us,0,-ei(r)-1))):(e-t>=1&&(tt(o.b,t,t,iJ),++e),tt(o.b,e,e,of),r>0&&n9(o,++e,iG),n9(o,++e,i$+r4(r2(r)))),n.i=o.b.b,n.i)}function ip(n,t){var e,r,i,o,u,f;if(i=eg(n),o=eg(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==i$;)--s;s1e6)throw new nr("power of ten too big");if(n<=2147483647)return u$[1].db(t).eb(t);for(i=r=u$[1].db(2147483647),e=r2(n-2147483647),t=ei(n%2147483647);rB(e,o4);)i=en(i,r),e=eY(e,o4);for(i=(i=en(i,u$[1].db(t))).eb(2147483647),e=r2(n-2147483647);rB(e,o4);)i=i.eb(2147483647),e=eY(e,o4);return i.eb(t)}function im(){var n,t;f&&rM("com.iriscouch.gwtapp.client.BigDecimalApp"),nW(new J),nX(new T),nZ(new j),tD(new F),f&&rM("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oQ)?oQ:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=oH)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oj:-1!=t.indexOf(oO)&&u.documentMode>=9?"ie9":-1!=t.indexOf(oO)&&u.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tj(oj,n)||o.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),f&&rM("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=u.compatMode,n=tJ(fN,{6:1},1,[oi]);e>5,this.b=tL(fd,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tW(this)}}function iC(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ts(e3(n.b[0]),o3),r=ts(e3(t.b[0]),o3),u==c)?(l=nx(s=eX(e,r)),0==(b=nx(rU(s,32)))?new t$(u,l):new ti(u,2,tJ(fd,{6:1},-1,[l,b]))):eW(u<0?eY(r,e):eY(e,r));if(u==c)h=u,a=o>=f?t3(n.b,o,t.b,f):t3(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eN(n.b,t.b,o)))return rK(),uB;1==i?(h=u,a=tz(n.b,o,t.b,f)):(h=c,a=tz(t.b,f,n.b,o))}return tW(s=new ti(h,a.length,a)),s}function iS(n){var t,e,r,i;if(rj(),null==n)throw new nf("null string");if((t=t6(n)).length<27||t.length>45)throw new no(oM);for(r=0;rft.length)throw new V;if(o=null,i=null,67==r[0]?(i=uZ,o=u6):68==r[0]?(i=uX,o=u5):70==r[0]?(i=uY,o=u9):72==r[0]?e>6&&(68==r[5]?(i=u1,o=u7):69==r[5]?(i=u0,o=u8):85==r[5]&&(i=u2,o=fn)):85==r[0]&&(80==r[1]?(i=u3,o=fe):78==r[1]&&(i=u4,o=ft)),i&&e==o.length){for(t=1;tl||r+i>s)throw new q;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tQ(n,11),o=tQ(e,11),nT(n)===nT(e)&&tr;)e8(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eJ(e+(o>u?o:u)),s=(i=o-u)>0?(ib(),i>19!=0&&(t=eP(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?ec(b):0==h&&0!=l&&0==b?ec(l)+22:0!=h&&0==l&&0==b?ec(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rJ(n,u),c&&eQ(f),e&&(o7=tm(0,0,0)),f;n=nQ((eS(),ui)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eP(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rJ(g,u),w&&eQ(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eQ(f),o&&(r?(o7=eP(n),i&&(o7=eY(o7,(eS(),uu)))):o7=tm(n.l,n.m,n.h)),f}(r?n:tm(n.l,n.m,n.h),t,c,o,i,e):(e&&(o7=o?eP(n):tm(n.l,n.m,n.h)),tm(0,0,0))}function iI(n){var t=[];for(var e in n){var r=typeof n[e];r!=oP?t[t.length]=r:n[e]instanceof Array?t[t.length]=oS:o&&o.bigdecimal&&o.bigdecimal.BigInteger&&n[e]instanceof o.bigdecimal.BigInteger?t[t.length]=i8:o&&o.bigdecimal&&o.bigdecimal.BigDecimal&&n[e]instanceof o.bigdecimal.BigDecimal?t[t.length]=i5:o&&o.bigdecimal&&o.bigdecimal.RoundingMode&&n[e]instanceof o.bigdecimal.RoundingMode?t[t.length]=og:o&&o.bigdecimal&&o.bigdecimal.MathContext&&n[e]instanceof o.bigdecimal.MathContext?t[t.length]=oh:t[t.length]=oP}return t.join(iV)}function iE(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,tm(b,l&=4194303,g&=1048575)}function iR(n,t,e){var r,i,o,u,f,c,s,a;if(a=rr(eX(e3(e.b),oK))+(t.e>0?t.e:nU((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=uv.length-1,s=tJ(f5,{6:1},17,[(n.d||(n.d=eU(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iA(n,t);if(a>0&&(e8(s,0,en((n.d||(n.d=eU(n.g)),n.d),iv(a))),c+=a),u=(s=r3(s[0],(t.d||(t.d=eU(t.g)),t.d)))[0],0!=s[1].r())r=rn(eF(s[1]),(t.d||(t.d=eU(t.g)),t.d)),u=iC(en(u,(rK(),ux)),eW(e3(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r3(u,uv[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?np(n.b,t.b)+1<54?new tr(n.g-t.g,n.f):new tM(is((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),n.f):e>0?e0?t.e:nU((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rK(),r=uB;else if(0==o)r=ia((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d));else if(o>0)u=iv(o),r=ia((n.d||(n.d=eU(n.g)),n.d),en((t.d||(t.d=eU(t.g)),t.d),u)),r=en(r,u);else{for(u=iv(-o),r=ia(en((n.d||(n.d=eU(n.g)),n.d),u),(t.d||(t.d=eU(t.g)),t.d));!r.gb(0);)if(0==(f=r3(r,uv[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nx(m=r0(eX(rL(ts(e3(w[h]),o3),32),ts(e3(w[h-1]),o3)),c)),v=nx(rJ(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iE(ts(e3(s),o3),ts(e3(d[o-2]),o3)),y=eX(rL(e3(v),32),ts(e3(w[h-2]),o3)),32>rH(nx(rU(g=eX(ts(e3(v),o3),ts(e3(c),o3)),32)))?_=!0:v=nx(g)}while(rB(th(l,o$),th(y,o$)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oz,u=oz;f0)e8(b,0,ia((n.d||(n.d=eU(n.g)),n.d),en((t.d||(t.d=eU(t.g)),t.d),iv(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,e8(b,0,en(b[0],iv(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r3(en((n.d||(n.d=eU(n.g)),n.d),iv(u)),(t.d||(t.d=eU(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nk(b[1]).q()+u-t.q())&&(e8(b,1,ia(en(b[1],iv(u)),(t.d||(t.d=eU(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new nr(ou);if(0==b[0].r())return eL(o);for(w=b[0],g=(c=new nk(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r3(w,uv[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new nr(ou);return c.f=eJ(h),tR(c,w),c}function iT(){var n;for(n=0,iT=l,uz=tJ(fd,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uJ=tL(f5,{6:1},17,(uK=tJ(fd,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rA(n,oz)?(e=nP(n,o2),r=n3(n,o2)):(e=nP(t=rU(n,1),o0),r=eX(rL(r=n3(t,o0),1),ts(n,oJ))),ta(rL(r,32),ts(e,o3))}(eX(rL(y,32),ts(e3(M[c]),o3))),M[c]=nx(w),y=e3(nx(rJ(w,32)));d=nx(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tU(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tU(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tU(v,e,_-e)}return(S=e+1,m=new W,h&&(m.b.b+=iz),_-S>=1)?(tI(m,v[e]),m.b.b+=iJ,N=m.b,I=tU(v,e+1,_-e-1),N.b+=I):(E=m.b,R=tU(v,e,_-e),E.b+=R),m.b.b+=of,o>0&&(m.b.b+=iG),O=m.b,O.b+=i$+o,m.b.b}f&&f({moduleName:"gwtapp",sessionId:c,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iF,iH,i$="",iV=" ",iq='"',iG="+",iz="-",iJ=".",iK="0",iW="0.",iZ="0.0",iX="0.00",iY="0.000",i1="0.0000",i0="0.00000",i2="0.000000",i4="0E",i3="0E+",i6=":",i5="BigDecimal",i9="BigDecimal MathContext",i7="BigDecimal;",i8="BigInteger",on="BigInteger divide by zero",ot="BigInteger not invertible.",oe="BigInteger: modulus not positive",or="BigInteger;",oi="CSS1Compat",oo="Division by zero",ou="Division impossible",of="E",oc='For input string: "',os="Infinite or NaN",oa="Invalid Operation",oh="MathContext",ob="Negative bit address",ol="Rounding necessary",og="RoundingMode",ow="RoundingMode;",od="String",op="[Lcom.iriscouch.gwtapp.client.",o_="[Ljava.lang.",ov="[Ljava.math.",om="\\.",oy="__gwtex_wrap",oC="anonymous",oS="array",oM="bad string format",ox="bigdecimal",oB="com.google.gwt.core.client.",oA="com.google.gwt.core.client.impl.",oN="com.iriscouch.gwtapp.client.",oI="java.lang.",oE="java.math.",oR="java.util.",oO="msie",oD="null",ok="number",oL="number MathContext",oU="number number",oP="object",oQ="opera",oT="org.timepedia.exporter.client.",oj="safari",oF="string",oH="undefined",o$={l:0,m:0,h:524288},oV={l:0,m:4193280,h:1048575},oq={l:4194298,m:4194303,h:1048575},oG={l:4194303,m:4194303,h:1048575},oz={l:0,m:0,h:0},oJ={l:1,m:0,h:0},oK={l:2,m:0,h:0},oW={l:5,m:0,h:0},oZ={l:10,m:0,h:0},oX={l:11,m:0,h:0},oY={l:18,m:0,h:0},o1={l:48,m:0,h:0},o0={l:877824,m:119,h:0},o2={l:1755648,m:238,h:0},o4={l:4194303,m:511,h:0},o3={l:4194303,m:1023,h:0},o6={l:0,m:1024,h:0};(iH=s.prototype={}).eQ=function(n){return this===n},iH.gC=function(){return fc},iH.hC=function(){return nj(this)},iH.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tL(fJ,{6:1},-1,8,1),r_(),e=7,n>=0)for(;n>15;)t[e--]=uR[15&n],n>>=4;else for(;e>0;)t[e--]=uR[15&n],n>>=4;return t[e]=uR[15&n],t4(t,e,8)}(this.hC())},iH.toString=function(){return this.tS()},iH.tM=l,iH.cM={},(iH=a.prototype=new s).gC=function(){return fa},iH.j=function(){return this.f},iH.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},iH.cM={6:1,15:1},iH.f=null,(iH=h.prototype=new a).gC=function(){return fh},iH.cM={6:1,15:1},(iH=ne.prototype=b.prototype=new h).gC=function(){return fb},iH.cM={6:1,12:1,15:1},(iH=n1.prototype=(function(){}).prototype=new b).gC=function(){return fl},iH.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?oD:tn(e)?null==(r=t9(e))?null:r.name:nG(e,1)?od:(nF(e)?e.gC():fg).d,this.b=tn(n=this.c)?null==(i=t9(n))?null:i.message:n+i$,this.d="("+this.e+"): "+this.b+(tn(t=this.c)?function(n){var t=i$;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t9(t)):i$)),this.d},iH.cM={6:1,12:1,15:1},iH.b=null,iH.c=null,iH.d=null,iH.e=null,(iH=g.prototype=new s).gC=function(){return fw};var o5=0,o9=0;(iH=w.prototype=(function(){}).prototype=new g).gC=function(){return fv},iH.b=null,iH.c=null,(iH=d.prototype=_.prototype=new s).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i6+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oC},iH.gC=function(){return fm},iH.o=function(n){return[]},(iH=v.prototype=new _).k=function(){return tl(this.o(tw()),this.p())},iH.gC=function(){return fS},iH.o=function(n){return eR(this,n)},iH.p=function(){return 2},(iH=m.prototype=(function(){}).prototype=new v).k=function(){return es(this)},iH.n=function(n){var t,e;return 0==n.length||(0==(e=e9(n)).indexOf("at ")&&(e=n7(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oC:(-1!=(t=(e=e9(e.substr(0,t-0))).indexOf("."))&&(e=n7(e,t+1)),e.length>0?e:oC)},iH.gC=function(){return fM},iH.o=function(n){return t2(this,n)},iH.p=function(){return 3},(iH=y.prototype=new s).gC=function(){return fx},(iH=C.prototype=(function(){}).prototype=new y).gC=function(){return fB},iH.b=i$,(iH=S.prototype=(function(){}).prototype=new s).gC=function(){return this.aC},iH.aC=null,iH.qI=0;var o7=null,o8=null;(iH=M.prototype=(function(){}).prototype=new s).gC=function(){return fI},iH.cM={2:1},(iH=x.prototype=new s).gC=function(){return fR},iH.cM={6:1,10:1};var un=null;(iH=eo.prototype=tr.prototype=tM.prototype=tA.prototype=Z.prototype=ep.prototype=eu.prototype=tB.prototype=tx.prototype=ez.prototype=n2.prototype=n4.prototype=te.prototype=tS.prototype=nk.prototype=B.prototype=new x).eQ=function(n){return e0(this,n)},iH.gC=function(){return fO},iH.hC=function(){return rv(this)},iH.q=function(){return rT(this)},iH.r=function(){return ew(this)},iH.tS=function(){return id(this)},iH.cM={6:1,8:1,10:1,16:1},iH.b=0,iH.c=0,iH.d=null,iH.e=0,iH.f=0,iH.g=0,iH.i=null;var ut,ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_=null,uv=null,um=null;(iH=nL.prototype=ng.prototype=(function(){}).prototype=new B).s=function(n){var t,e,r;if((e=iI(n))==i$)t=0>ew(this)?ed(this):this;else if(e==oh)t=0>(r=t7(this,new iS(n[0].toString()))).r()?ed(r):r;else throw new ne("Unknown call signature for interim = super.abs: "+e);return new nL(t)},iH.t=function(n){var t,e;if((e=iI(n))==i5)t=r1(this,new Z(n[0].toString()));else if(e==i9)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t7(r1(n,t),e);if((n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)0?t.e:nU((t.b-1)*.3010299956639812)+1)<-r-1))return t7(r1(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nU((i.b-1)*.3010299956639812)+1)?t7(r1(n,t),e):(f=(o=i.r())==u.r()?iC(rW((i.d||(i.d=eU(i.g)),i.d),10),eW(e3(o))):iC(rW(f=is((i.d||(i.d=eU(i.g)),i.d),eW(e3(o))),10),eW(e3(9*o))),t7(i=new tM(f,i.f+1),e))}(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.add: "+e);return new nL(t)},iH.u=function(){return~~(nx(t8(this,8))<<24)>>24},iH.v=function(n){return iu(this,n)},iH.w=function(n){var t,e,r,i;if((i=iI(n))==i5)e=eb(this,new Z(n[0].toString()));else if(i==i9)e=el(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tL(fk,{6:1},3,e.length,0);t129?n*=1/0:n=t5(id(this)),n},iH.gC=function(){return fD},iH.hC=function(){return rv(this)},iH.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nU((this.b-1)*.3010299956639812)+1)?0:(n=new n0(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eU(this.g)),this.d):this.f<0?en((this.d||(this.d=eU(this.g)),this.d),iv(-this.f)):ia((this.d||(this.d=eU(this.g)),this.d),iv(this.f)))).f*n.b[0]},iH.C=function(){return nx(t8(this,32))},iH.D=function(){return nx(t8(this,32))},iH.E=function(){return t5(id(this))},iH.F=function(n){return new nL(iu(this,n)>=0?this:n)},iH.G=function(n){return new nL(0>=iu(this,n)?this:n)},iH.H=function(n){return new nL(rz(this,this.f+n))},iH.I=function(n){return new nL(rz(this,this.f-n))},iH.J=function(n){var t,e;if((e=iI(n))==i5)t=rD(this,new Z(n[0].toString()));else if(e==i9)t=tb(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.multiply: "+e);return new nL(t)},iH.K=function(n){var t,e;if((e=iI(n))==i$)t=ed(this);else if(e==oh)t=ed(t7(this,new iS(n[0].toString())));else throw new ne("Unknown call signature for interim = super.negate: "+e);return new nL(t)},iH.L=function(n){var t,e;if((e=iI(n))==i$)t=this;else if(e==oh)t=t7(this,new iS(n[0].toString()));else throw new ne("Unknown call signature for interim = super.plus: "+e);return new nL(t)},iH.M=function(n){var t,e;if((e=iI(n))==ok)t=rw(this,n[0]);else if(e==oL)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=ei(n8(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rw(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new nr(oa);for(u>0&&(f=new eK(u+i+1,e.c)),r=t7(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tb(r,r,f),(o&c)==c&&(r=tb(r,n,f)),c>>=1;return t<0&&(r=iR(ug,r,f)),ic(r,e),r}(this,n[0],new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.pow: "+e);return new nL(t)},iH.q=function(){return rT(this)},iH.N=function(n){var t,e;if((e=iI(n))==i5)t=eb(this,new Z(n[0].toString()))[1];else if(e==i9)t=el(this,new Z(n[0].toString()),new iS(n[1].toString()))[1];else throw new ne("Unknown call signature for interim = super.remainder: "+e);return new nL(t)},iH.O=function(n){return new nL(t7(this,new iS(ea(n.b))))},iH.P=function(){return ei(this.f)},iH.Q=function(n){var t,e;return new nL((t=this,(e=t.f-n,t.b<54)?0==t.g?eL(e):new tr(t.g,eJ(e)):new tS((t.d||(t.d=eU(t.g)),t.d),eJ(e))))},iH.R=function(n){var t,e;if((e=iI(n))==ok)t=rY(this,n[0],(iB(),u4));else if(e==oU)t=rY(this,n[0],rP(n[1]));else if("number RoundingMode"==e)t=rY(this,n[0],tc(n[1].toString()));else throw new ne("Unknown call signature for interim = super.setScale: "+e);return new nL(t)},iH.S=function(){return~~(nx(t8(this,16))<<16)>>16},iH.r=function(){return ew(this)},iH.T=function(){return new nL(function(n){var t,e,r,i,o;if(t=1,e=uv.length-1,r=n.f,0==n.b&&-1!=n.g)return new Z(iK);for(n.d||(n.d=eU(n.g)),o=n.d;!o.gb(0);)if(0==(i=r3(o,uv[t]))[1].r())r-=t,t0?i.e:nU((i.b-1)*.3010299956639812)+1)0?r.e:nU((r.b-1)*.3010299956639812)+1)?(f=(c=ew(r))!=i.r()?iC(rW((r.d||(r.d=eU(r.g)),r.d),10),eW(e3(c))):iC(rW(f=is((r.d||(r.d=eU(r.g)),r.d),eW(e3(c))),10),eW(e3(9*c))),t7(new tM(f,r.f+1),o)):t7(iO(r,i),o);else throw new ne("Unknown call signature for interim = super.subtract: "+e);return new nL(t)},iH.V=function(){return new n0(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eU(this.g)),this.d):this.f<0?en((this.d||(this.d=eU(this.g)),this.d),iv(-this.f)):ia((this.d||(this.d=eU(this.g)),this.d),iv(this.f)))},iH.W=function(){return new n0(r6(this))},iH.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eU(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nV(u),n.f>0&&i>=-6)i>=0?n9(c,r-ei(n.f),iJ):(tt(c.b,t-1,t-1,iW),n9(c,t+1,tU(us,0,-ei(i)-1)));else{if(e=r-t,0!=(f=ei(i%3))&&(0==(n.d||(n.d=eU(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n9(c,r++,iK);r-t>=1&&(tt(c.b,t,t,iJ),++r),0!=i&&(tt(c.b,r,r,of),i>0&&n9(c,++r,iG),n9(c,++r,i$+r4(r2(i))))}return c.b.b}(this)},iH.Y=function(){return function(n){var t,e,r,i,o,u;if(r=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ew(n)?1:0,e=n.f,i=new W(r.length+1+((o=ei(n.f))<0?-o:o)),1==t&&(i.b.b+=iz),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iW;e>us.length;e-=us.length)tq(i,us);n5(i,us,ei(e)),nI(i,n7(r,t))}else nI(i,(u=ei(e=t-e),r.substr(t,u-t))),i.b.b+=iJ,nI(i,n7(r,ei(e)))}else{for(nI(i,n7(r,t));e<-us.length;e+=us.length)tq(i,us);n5(i,us,ei(-e))}return i.b.b}(this)},iH.tS=function(){return id(this)},iH.Z=function(){return new nL(new tr(1,this.f))},iH.$=function(){return new n0((this.d||(this.d=eU(this.g)),this.d))},iH.cM={3:1,6:1,8:1,10:1,16:1,24:1},(iH=F.prototype=(function(){}).prototype=new s).gC=function(){return fL};var uy=!1;(iH=ro.prototype=ri.prototype=ti.prototype=e5.prototype=t$.prototype=ra.prototype=nq.prototype=iy.prototype=A.prototype=new x)._=function(){return this.f<0?new ti(1,this.e,this.b):this},iH.ab=function(){return eV(this)},iH.eQ=function(n){return e$(this,n)},iH.gC=function(){return fU},iH.bb=function(){return t1(this)},iH.hC=function(){return eD(this)},iH.cb=function(){return 0==this.f?this:new ti(-this.f,this.e,this.b)},iH.db=function(n){return rk(this,n)},iH.eb=function(n){return tX(this,n)},iH.fb=function(n){return tY(this,n)},iH.r=function(){return this.f},iH.gb=function(n){return rQ(this,n)},iH.tS=function(){return ij(this,0)},iH.cM={6:1,8:1,10:1,17:1},iH.b=null,iH.c=-2,iH.d=0,iH.e=0,iH.f=0;var uC,uS,uM,ux,uB,uA=null;(iH=n0.prototype=nO.prototype=nD.prototype=(function(){}).prototype=new A)._=function(){return new n0(this.f<0?new ti(1,this.e,this.b):this)},iH.hb=function(n){return new n0(iC(this,n))},iH.ib=function(n){return new n0(0==n.f||0==this.f?(rK(),uB):e$(n,(rK(),uC))?this:e$(this,uC)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=nd(n.e,t.e),(e=np(eg(n),eg(t)))>=i)return rK(),uB;for(r=tL(fd,{6:1},-1,i,1);e0?rG(n,this):this.e>n.e?ip(this,n):ip(n,this))},iH.jb=function(n){return new n0(0==n.f?this:0==this.f?(rK(),uB):e$(this,(rK(),uC))?new n0(r7(n)):e$(n,uC)?uB:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tL(fd,{6:1},-1,n.e,1),r=nd(n.e,t.e),e=eg(n);e=n.e)return n;for(o=tL(fd,{6:1},-1,u=nd(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=eg(n),o=eg(t),i>=t.e)return n;if(c=np(n.e,t.e),r=i,o>i){for(f=tL(fd,{6:1},-1,c,1),u=nd(n.e,o);r=t.e)return rK(),uB;if(u=tL(fd,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},iH.qb=function(n){return new n0(rE(this,n))},iH.gC=function(){return fP},iH.bb=function(){return t1(this)},iH.hC=function(){return eD(this)},iH.B=function(){return this.f*this.b[0]},iH.rb=function(n){return function(n,t){var e,r;if(iT(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rQ(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uK,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n0(this.f<0?new ti(1,this.e,this.b):this),n)},iH.sb=function(){return t5(ij(this,0))},iH.tb=function(n){return new n0(1==rn(this,n)?this:n)},iH.ub=function(n){return new n0(-1==rn(this,n)?this:n)},iH.vb=function(n){return new n0(et(this,n))},iH.wb=function(n){return new n0(rR(this,n))},iH.xb=function(n,t){return new n0(rq(this,n,t))},iH.yb=function(n){return new n0(en(this,n))},iH.cb=function(){return new n0(0==this.f?this:new ti(-this.f,this.e,this.b))},iH.zb=function(){return new n0(function(n){if(n.f<0)throw new nr("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(iT(),o=tL(fd,{6:1},-1,uK.length,1),r=tL(f_,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uK[e];++e);return uJ[e]}for(f=new ti(1,n.e,tL(fd,{6:1},-1,n.e+1,1)),ix(n.b,0,f.b,0,n.e),rQ(n,0)?tK(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rl(this,n):rl(n,this):ig(this,n):n.f>0?ig(n,this):eg(n)>eg(this)?rZ(n,this):rZ(this,n))},iH.db=function(n){return new n0(rk(this,n))},iH.Cb=function(n){return new n0(rF(this,n))},iH.Db=function(n){return new n0(rQ(this,n)?this:it(this,n))},iH.eb=function(n){return new n0(tX(this,n))},iH.fb=function(n){return new n0(tY(this,n))},iH.r=function(){return this.f},iH.Eb=function(n){return new n0(is(this,n))},iH.gb=function(n){return rQ(this,n)},iH.Fb=function(n){var t,e;if((e=iI(n))==i$)t=ij(this,0);else if(e==ok)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(iM(),g=n.f,s=n.e,u=n.b,0==g)return iK;if(1==s)return _=ts(e3(u[0]),o3),g<0&&(_=eP(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return i$+r4(n);if(e=tL(fJ,{6:1},-1,65,1),r_(),r=64,i=e3(t),rA(n,oz)){for(;rA(n,i);)e[r--]=uR[nx(n3(n,i))],n=iN(n,i,!1);e[r]=uR[nx(n)]}else{for(;!rB(n,eP(i));)e[r--]=uR[nx(eP(n3(n,i)))],n=iN(n,i,!1);e[r--]=uR[nx(eP(n))],e[r]=45}return t4(e,r,65)}(_,t);if(10==t||t<2||t>36)return ij(n,0);if(l=tL(fJ,{6:1},-1,b=ei(eV(new n0(n.f<0?new ti(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(ix(u,0,w=tL(fd,{6:1},-1,s,1),0,s),d=s,r=uU[t],e=uL[t-2];;){h=ir(w,w,d,e),a=i;do l[--i]=ev(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=ev(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tU(l,i,b-i)}(this,n[0]);else throw new ne("Unknown call signature for result = super.toString: "+e);return t},iH.Gb=function(n){return new n0(0==n.f?this:0==this.f?n:e$(n,(rK(),uC))?new n0(r7(this)):e$(this,uC)?new n0(r7(n)):this.f>0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iL(this,n):n.f>0?iL(n,this):eg(n)>eg(this)?ii(n,this):ii(this,n))},iH.cM={4:1,6:1,8:1,10:1,17:1,24:1},(iH=j.prototype=(function(){}).prototype=new s).gC=function(){return fT};var uN=!1;(iH=nv.prototype=nm.prototype=(function(){}).prototype=new s).gC=function(){return fj},iH.Hb=function(){return this.b.b},iH.Ib=function(){return new Y(this.b.c)},iH.hC=function(){return nM(this.b)},iH.tS=function(){return ea(this.b)},iH.cM={24:1},iH.b=null,(iH=T.prototype=(function(){}).prototype=new s).gC=function(){return fF};var uI=!1;(iH=Y.prototype=ny.prototype=(function(){}).prototype=new s).gC=function(){return fH},iH.Jb=function(){return this.b.b},iH.tS=function(){return this.b.b},iH.cM={5:1,24:1},iH.b=null,(iH=J.prototype=(function(){}).prototype=new s).gC=function(){return fV};var uE=!1;(iH=nr.prototype=(function(){}).prototype=new b).gC=function(){return fq},iH.cM={6:1,12:1,15:1},(iH=ni.prototype=$.prototype=(function(){}).prototype=new b).gC=function(){return fz},iH.cM={6:1,12:1,15:1},(iH=N.prototype=(function(){}).prototype=new s).gC=function(){return fK},iH.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?i$:"class ")+this.d},iH.b=null,iH.c=0,iH.d=null,(iH=H.prototype=(function(){}).prototype=new b).gC=function(){return fW},iH.cM={6:1,12:1,15:1},(iH=I.prototype=new s).eQ=function(n){return this===n},iH.gC=function(){return fs},iH.hC=function(){return nj(this)},iH.tS=function(){return this.b},iH.cM={6:1,8:1,9:1},iH.b=null,iH.c=0,(iH=no.prototype=V.prototype=E.prototype=new b).gC=function(){return fZ},iH.cM={6:1,12:1,15:1},(iH=nu.prototype=q.prototype=R.prototype=new b).gC=function(){return fG},iH.cM={6:1,12:1,15:1},(iH=nf.prototype=G.prototype=(function(){}).prototype=new b).gC=function(){return fX},iH.cM={6:1,12:1,15:1},(iH=nw.prototype=(function(){}).prototype=new E).gC=function(){return fY},iH.cM={6:1,12:1,15:1},(iH=to.prototype=(function(){}).prototype=new s).gC=function(){return fy},iH.tS=function(){return this.b+iJ+this.d+"(Unknown Source"+(this.c>=0?i6+this.c:i$)+")"},iH.cM={6:1,13:1},iH.b=null,iH.c=0,iH.d=null,(iH=String.prototype).eQ=function(n){return tj(this,n)},iH.gC=function(){return fA},iH.hC=function(){var n,t;return nJ(),null!=(t=uD[n=i6+this])?t:(null==(t=uO[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;et?n:t}function nv(n,t){return!rN(n,t)}function nm(n){this.b=new iM(n)}function ny(){this.b=(rF(),uF)}function nC(){this.b=(iA(),u4)}function nS(n,t){var e;nb(),e=o.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tw(n){return nz(n,15)?n:new n0(n)}function td(){try{null.a()}catch(n){return n}}function tp(n){var t;return(t=new I).d=iV+n,t.c=1,t}function t_(n,t){return nH(n)?n.eQ(t):n===t}function tv(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tm(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function ty(n,t,e){return(i$=new x).l=n,i$.m=t,i$.h=e,i$}function tC(n,t){return nj(n)===nj(t)||null!=n&&t_(n,t)}function tS(n,t){throw new nf("Index: "+n+", Size: "+t)}function tM(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tx(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tB(n,t,e,r){eJ.call(this,n,t,e),is(this,r)}function tA(n,t){eJ.call(this,n,0,n.length),is(this,t)}function tN(n,t){eJ.call(this,t5(n),0,n.length),is(this,t)}function tI(n){nr.call(this,"String index out of range: "+n)}function tE(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tR(n,t){rC(n.b,n.b,n.e,t.b,t.e),tZ(n),n.c=-2}function tO(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=ri(eN(t)))}function tD(){tD=g,ur=[],ui=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new M,ur,ui)}function tk(){uC||(uC=!0,new j,new F,function(){if(ng(oB,iV),u.bigdecimal.BigDecimal)var n=u.bigdecimal.BigDecimal;u.bigdecimal.BigDecimal=fc(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fk?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new nw,nl(this.__gwt_instance,this))});var t=u.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)u.bigdecimal.BigDecimal[p]=n[p];u.bigdecimal.BigDecimal.ROUND_CEILING=2,u.bigdecimal.BigDecimal.ROUND_DOWN=1,u.bigdecimal.BigDecimal.ROUND_FLOOR=3,u.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,u.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,u.bigdecimal.BigDecimal.ROUND_HALF_UP=4,u.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,u.bigdecimal.BigDecimal.ROUND_UP=0,u.bigdecimal.BigDecimal.__init__=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==on)t=new nL(new nG(n[0].toString()));else if("BigInteger number"==e)t=new tM(new nG(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new tr(new nG(n[0].toString()),n[1],new iM(n[2].toString()));else if("BigInteger MathContext"==e)t=new n3(new nG(n[0].toString()),new iM(n[1].toString()));else if(e==oM)t=new n4(t5(n[0].toString()));else if("array number number"==e)t=new eJ(t5(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tB(t5(n[0].toString()),n[1],n[2],new iM(n[3].toString()));else if("array MathContext"==e)t=new tA(t5(n[0].toString()),new iM(n[1].toString()));else if(e==oL)t=new ef(n[0]);else if(e==oU)t=new e_(n[0],new iM(n[1].toString()));else if(e==oH)t=new X(n[0].toString());else if("string MathContext"==e)t=new tN(n[0].toString(),new iM(n[1].toString()));else throw new nr("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nU(t)}(n);return nR(t)}),t.abs_va=fc(function(n){return nR(this.__gwt_instance.s(n))}),t.add_va=fc(function(n){return nR(this.__gwt_instance.t(n))}),t.byteValueExact=fc(function(){return this.__gwt_instance.u()}),t.compareTo=fc(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=fc(function(n){return nR(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=fc(function(n){return nR(this.__gwt_instance.x(n))}),t.doubleValue=fc(function(){return this.__gwt_instance.z()}),t.equals=fc(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=fc(function(){return this.__gwt_instance.A()}),t.hashCode=fc(function(){return this.__gwt_instance.hC()}),t.intValue=fc(function(){return this.__gwt_instance.B()}),t.intValueExact=fc(function(){return this.__gwt_instance.C()}),t.max=fc(function(n){return nR(this.__gwt_instance.F(n.__gwt_instance))}),t.min=fc(function(n){return nR(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=fc(function(n){return nR(this.__gwt_instance.H(n))}),t.movePointRight=fc(function(n){return nR(this.__gwt_instance.I(n))}),t.multiply_va=fc(function(n){return nR(this.__gwt_instance.J(n))}),t.negate_va=fc(function(n){return nR(this.__gwt_instance.K(n))}),t.plus_va=fc(function(n){return nR(this.__gwt_instance.L(n))}),t.pow_va=fc(function(n){return nR(this.__gwt_instance.M(n))}),t.precision=fc(function(){return this.__gwt_instance.q()}),t.remainder_va=fc(function(n){return nR(this.__gwt_instance.N(n))}),t.round=fc(function(n){return nR(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=fc(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=fc(function(n){return nR(this.__gwt_instance.Q(n))}),t.setScale_va=fc(function(n){return nR(this.__gwt_instance.R(n))}),t.shortValueExact=fc(function(){return this.__gwt_instance.S()}),t.signum=fc(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=fc(function(){return nR(this.__gwt_instance.T())}),t.subtract_va=fc(function(n){return nR(this.__gwt_instance.U(n))}),t.toBigInteger=fc(function(){return nR(this.__gwt_instance.V())}),t.toBigIntegerExact=fc(function(){return nR(this.__gwt_instance.W())}),t.toEngineeringString=fc(function(){return this.__gwt_instance.X()}),t.toPlainString=fc(function(){return this.__gwt_instance.Y()}),t.toString=fc(function(){return this.__gwt_instance.tS()}),t.ulp=fc(function(){return nR(this.__gwt_instance.Z())}),t.unscaledValue=fc(function(){return nR(this.__gwt_instance.$())}),t.divideAndRemainder_va=fc(function(n){return nO(this.__gwt_instance.w(n))}),t.longValue=fc(function(){return this.__gwt_instance.E()}),t.longValueExact=fc(function(){return this.__gwt_instance.D()}),u.bigdecimal.BigDecimal.valueOf_va=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==oL)t=function(n){if(!isFinite(n)||isNaN(n))throw new nd(oa);return new X(iV+n)}(n[0]);else if(e==oL)t=tX(e6(n[0]));else if(e==oP)t=eL(e6(n[0]),n[1]);else throw new nr("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nU(t)}(n);return nR(t)}),u.bigdecimal.BigDecimal.log=fc(function(n){iP(),typeof console!==o$&&console.log&&console.log(n)}),u.bigdecimal.BigDecimal.logObj=fc(function(n){iP(),typeof console!==o$&&console.log&&typeof JSON!==o$&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),u.bigdecimal.BigDecimal.ONE=fc(function(){var n=(iP(),new nU(uw));return nR(n)}),u.bigdecimal.BigDecimal.TEN=fc(function(){var n=(iP(),new nU(ud));return nR(n)}),u.bigdecimal.BigDecimal.ZERO=fc(function(){var n=(iP(),new nU(up));return nR(n)}),nS(fk,u.bigdecimal.BigDecimal)}())}function tL(n,t,e){var r;return(r=new I).d=n+t,r.c=4,r.b=e,r}function tU(n,t,e,r,i){var o;return tK(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tI(e)}(n.length,t,r),t3(n,t,r)}function tQ(n,t){return il(),t=n.c.c)throw new J;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tS(r,i),t.b[e]}function tF(n,t){return!!nz(t,1)&&String(n)==t}function tH(){nr.call(this,"Add not supported on this collection")}function t$(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function tV(n,t){rW(),this.f=n,this.e=1,this.b=tK(fp,{6:1},-1,[t])}function tq(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tG(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tz(n,t,e,r){var i,o;return null==t&&(t=ok),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tJ(n,t,e,r){var i;return rC(i=tU(fp,{6:1},-1,t,1),n,t,e,r),i}function tK(n,t,e,r){return tD(),function(n,t,e){tD();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tX(n){return rN(n,oJ)&&nv(n,oY)?us[nB(n)]:new eu(n,0)}function tY(n,t){return 0==t||0==n.f?n:t>0?e3(n,t):rY(n,-t)}function t1(n,t){return 0==t||0==n.f?n:t>0?rY(n,t):e3(n,-t)}function t0(n){var t;return 0==n.f?-1:((t=ew(n))<<5)+es(n.b[t])}function t2(n){var t;return 0!=(t=nB(n))?es(t):es(nB(rK(n,32)))+32}function t4(n,t){var e;return 0==(e=eO(n,t)).length?(new _).o(t):tg(e,1)}function t3(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t6(n,t,e,r){var i;return ib(i=tU(fp,{6:1},-1,t+1,1),n,t,e,r),i}function t5(n){var t,e;return t=tU(fK,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nB(y=iR(ta(e6(b.b[0]),o6),ta(e6(l.b[0]),o6))),0==(C=nB(rP(y,32)))?new tV(v,S):new to(v,2,tK(fp,{6:1},-1,[S,C]))):(eG(b.b,g,l.b,w,d=tU(fp,{6:1},-1,_,1)),tZ(m=new to(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=ia(t,a.eb(f)),o=ia(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iS(iS(u=n(ia(a,i),ia(o,h)),s),r)).eb(f),iS(iS(s=s.eb(f<<1),u),r))}(n,t))}function ee(n,t){var e;if(t.f<=0)throw new ni(or);return(e=rH(n,t)).f<0?iS(e,t):e}function er(n){var t;t=new nJ,n.d&&n5(t,new ne(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nA(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eP(n.g)),n.d).r()}function ep(n){return n.b<54?new ti(-n.g,n.f):new tx((n.d||(n.d=eP(n.g)),n.d).cb(),n.f)}function e_(n,t){if(!isFinite(n)||isNaN(n))throw new nd(oa);iQ(this,n.toPrecision(20)),is(this,t)}function ev(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function em(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function ey(n,t){var e,r;return t?((e=t[oC])||(e=new(r=t.gC(),t7(ei(n.b,r)))(t),t[oC]=e),e):null}function eC(n){var t,e;return 32==(e=r$(n.h))?32==(t=r$(n.m))?r$(n.l)+32:t+20-10:e-12}function eS(n){return ty(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eM(){eM=g,uo=ty(4194303,4194303,524287),uu=ty(0,0,524288),uf=e6(1),e6(2),uc=e6(0)}function ex(n,t){ib(n.b,n.b,n.e,t.b,t.e),n.e=np(n_(n.e,t.e)+1,n.b.length),tZ(n),n.c=-2}function eB(n,t){var e;e=~~t>>5,n.e+=e+(r$(n.b[n.e-1])-(31&t)>=0?0:1),rS(n.b,n.b,e,31&t),tZ(n),n.c=-2}function eA(n,t){var e,r;e=~~t>>5,n.e>>r:0,tZ(n))}function eN(n){var t;return t=n.e>1?th(rU(e6(n.b[1]),32),ta(e6(n.b[0]),o6)):ta(e6(n.b[0]),o6),iR(e6(n.f),t)}function eI(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:nv(ta(e6(n[r]),o6),ta(e6(t[r]),o6))?-1:1}function eE(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eR(n,t,e,r){if(iH=t,n)try{fc(iy)()}catch(i){n(t)}else fc(iy)()}function eO(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eu(oJ,2147483647):new eu(oJ,-2147483648)}function eP(n){return(rW(),n<0)?-1!=n?new ru(-1,-n):uS:n<=10?ux[eo(n)]:new ru(1,n)}function eQ(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,ty(t,e,r)}function eT(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function ej(n){var t,e,r;for(r=0,e=tU(fS,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rA(ta(e6(n[r]),o6),ta(e6(i[r]),o6));break}}return u=new to(1,o+1,n),e&&tR(u,t),tZ(u),u}(o,e)}function eV(n,t){var e;return n===t||!!nz(t,17)&&(e=tT(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eq(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&ew(n)==n.e-1&&(e=~~(e-1)),t-=r$(e))}function eG(n,t,e,r,i){il(),0!=t&&0!=r&&(1==t?i[r]=rc(i,e,r,n[0]):1==r?i[t]=rc(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nj(n)===nj(t)&&r==i){iu(n,r,e);return}for(f=0;f2147483647))return eo(n);throw new ni("Underflow")}function eW(n,t){if(rF(),n<0)throw new nu("Digits < 0");if(!t)throw new nc("null RoundingMode");this.b=n,this.c=t}function eZ(n){return(rW(),nv(n,oJ))?tm(n,oz)?new ro(-1,eQ(n)):uS:rA(n,oX)?new ro(1,n):ux[nB(n)]}function eX(n){var t;return nv(n,oJ)&&(n=ty(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nB(rK(n,32)))?r$(t):r$(nB(n))+32)}function eY(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e0(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-n_(e,n.bb())}function e2(n,t){var e;return n===t||!!nz(t,16)&&(e=tT(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e4(n,t,e){var r,i,o;for(o=oJ,r=t-1;r>=0;--r)i=r2(eY(rU(o,32),ta(e6(n[r]),o6)),e),o=e6(nB(rK(i,32)));return nB(o)}function e3(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rS(r=tU(fp,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tZ(o=new to(n.f,i,r)),o}function e6(n){var t,e;return n>-129&&n<128?(t=n+128,null==un&&(un=tU(fR,{6:1},2,256,0)),(e=un[t])||(e=un[t]=eS(n)),e):eS(n)}function e5(n){var t,e,r;return(rW(),n>5,t=31&n,(r=tU(fp,{6:1},-1,e+1,1))[e]=1<iq&&n[n.length-1]>iq?n:n.replace(/^(\s*)/,iV).replace(/\s*$/,iV)}function e8(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function rn(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==g||n$(e,1)))throw new V}return n[t]=e}function rt(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=e$(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=e$(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tU(f9,{6:1},17,8,0),a=n,rn(s,0,t),h=e$(t,t,r,i),u=1;u<=7;++u)rn(s,u,e$(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=e$(a,a,r,i);return a}(f,r,t,e,o),e$(u,(rW(),uM),e,o)}function ra(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nd("Radix out of range");if(0==n.length)throw new nd("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(ix(),uP)[e])),0!=(d=l%u)&&++o,c=tU(fp,{6:1},-1,o,1),r=uU[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:nv(ta(e6(n[i]),o6),ta(e6(t[i]),o6))?-1:1}function rg(n,t){var e,r,i;for(r=tU(fp,{6:1},-1,i=n.e,1),np(ew(n),ew(t)),e=0;e999999999)throw new ni(oh);return e=n.f*t,0==n.b&&-1!=n.g?eU(e):new tM((n.d||(n.d=eP(n.g)),n.d).db(t),eK(e))}function rp(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fu[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fo[n]=t,t*=.5}function rv(){rv=g,uO=tK(fK,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rm(n){var t;return 0!=n.c?n.c:n.b<54?(t=r4(n.g),n.c=nB(ta(t,oz)),n.c=33*n.c+nB(ta(rK(t,32),oz)),n.c=17*n.c+eo(n.f),n.c):(n.c=17*n.d.hC()+eo(n.f),n.c)}function ry(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=ev(n*t,0),0!=u&&(i=ev((u<=0?0-u:u)*2,t<=0?0-t:t),o+=it(1&eo(o),f*(5+i),r)),new ti(o,e)}function rC(n,t,e,r,i){var o,u;for(u=0,o=oJ;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rD(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=eo(nP(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eX(r4(n))}function rR(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eZ(rI(eN(e),eN(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rB(n,e),rB(t,r),1==rt(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eZ(rI(eN(n),eN(t)));break}if(t.e>1.2*n.e)0!=(t=rH(t,n)).r()&&rB(t,t.bb());else do tR(t,n),rB(t,t.bb());while(rt(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?eB(f,i):(rB(c,r-e0&&eB(f,i-r+e)),e+=i),0!=(i=e0(h,u))&&(eB(h,i),r>=e?eB(c,i):(rB(f,e-r0&&eB(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rq(s,h),rq(f,c)):(rq(h,s),rq(c,f)):e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)),0==h.r()||0==s.r())throw new ni(oe);return eD(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():ia(t,f)),0>f.r()&&(f=iS(f,t)),f}(n,t);for(o=32*t.e,h=eb(t),u=n_((b=eb(n)).e,h.e),c=new to(1,1,tU(fp,{6:1},-1,u+1,1)),(s=new to(1,1,tU(fp,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rB(h,r),rB(b,i),eB(c,i),e+=r-i):(rB(h,r),rB(b,i),eB(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rt(h,b)>0;)tR(h,b),a=h.bb(),rB(h,a),ex(c,s),eB(s,a),e+=a;for(;0>=rt(h,b)&&(tR(b,h),0!=b.r());)a=b.bb(),rB(b,a),ex(s,c),eB(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new ni(oe);return rt(c,t)>=0&&tR(c,t),c=ia(t,c),f=rf(t),e>o&&(c=e$(c,(rW(),uM),t,f),e-=o),c=e$(c,e5(o-e),t,f)}(ee(n._(),t),t)).f)throw new ni(oe);return n.f<0?ia(t,e):e}function rD(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rk(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eU(e):n.b+t.b<54?new ti(n.g*t.g,eK(e)):new tM(et((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),eK(e))}function rL(n,t){var e;if(t<0)throw new ni("Negative exponent");if(0==t)return uM;if(1==t||n.eQ(uM)||n.eQ(uA))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return et(e5(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(il(),rW(),r=uM,e=n;t>1;t>>=1)(1&t)!=0&&(r=et(r,e)),e=1==e.e?et(e,e):new e9(iu(e.b,e.e,tU(fp,{6:1},-1,e.e<<1,1)));return et(r,e)}(n,t)}function rU(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),ty(4194303&r,4194303&i,1048575&o)}function rQ(n){switch(iA(),n){case 2:return uX;case 1:return uY;case 3:return u1;case 5:return u0;case 6:return u2;case 4:return u4;case 7:return u3;case 0:return u6;default:throw new nu("Invalid rounding mode")}}function rT(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new ni(ol);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=ew(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rj(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ih((n.d||(n.d=eP(n.g)),n.d),im(t)).r()&&++t),n.e=eo(t)),n.e}function rF(){rF=g,uQ=new eW(34,(iA(),u2)),uT=new eW(7,u2),uj=new eW(16,u2),uF=new eW(0,u4),uH=tK(fK,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),u$=tK(fK,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rH(n,t){var e,r,i,o;if(0==t.f)throw new ni(ot);return((o=n.e)!=(e=t.e)?o>e?1:-1:eI(n.b,t.b,o))==-1?n:(r=tU(fp,{6:1},-1,e,1),1==e?r[0]=e4(n.b,o,t.b[0]):r=iL(null,o-e+1,n.b,o,t.b,e),tZ(i=new to(n.f,e,r)),i)}function r$(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16),e+=t=~~(r=(n=~~n>>t)-256)>>16&8,n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function rV(n,t){if(0==n.f)iB(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ib(n.b,n.b,n.e,t.b,t.e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rq(n,t){var e;e=rt(n,t),0==n.f?(iB(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ib(n.b,n.b,n.e,t.b,t.e),n.f=e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rG(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new ni(or);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uA:0==r.f&&0==t.f?uM:(t.f<0&&(r=rO(n,e),t=t.cb()),i=e.gb(0)?rs(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rs(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rW(),u=uM,i=eb(t),r=eb(n),n.gb(0)&&eA(i,e-1),eA(r,e),o=i.ab()-1;o>=0;--o)eA(f=eb(u),e),u=et(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eA(u=et(u,r),e);return eA(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e9(tU(fp,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eA(b=et(ia(h,a),s),f),b.f<0&&(b=iS(b,e5(f))),iS(a,et(c,b))),r.f<0&&t.gb(0)&&(i=ee(et(ia(e,uM),i),e)),i)}function rz(n,t){var e,r,i,o,u,f,c;if(i=ew(n),(r=ew(t))>=n.e)return rW(),uA;for(u=tU(fp,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=np(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new ti(n.g,eK(t)):new tM((n.d||(n.d=eP(n.g)),n.d),eK(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),ty(4194303&i,4194303&o,1048575&u)}function rW(){var n;for(n=0,rW=g,uM=new tV(1,1),uB=new tV(1,10),uA=new tV(0,0),uS=new tV(-1,1),ux=tK(f9,{6:1},17,[uA,uM,new tV(1,2),new tV(1,3),new tV(1,4),new tV(1,5),new tV(1,6),new tV(1,7),new tV(1,8),new tV(1,9),uB]),uN=tU(f9,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rW(),uS):(rW(),uA);if(rD(i=tU(fp,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rM(n,t,e):rM(t,n,-e):n_(n.b,t.b)+1<54?new ti(n.g+t.g,n.f):new tx(iS((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f)}function r2(n,t){var e,r,i,o,u;return(r=ta(e6(t),o6),rN(n,oJ))?(o=iI(n,r,!1),u=n6(n,r)):(o=iI(e=rP(n,1),i=e6(~~t>>>1),!1),u=eY(rU(u=n6(e,i),1),ta(n,oK)),(1&t)!=0&&(rA(o,u)?rA(e1(o,u),r)?(u=eY(u,e1(rU(r,1),o)),o=e1(o,oW)):(u=eY(u,e1(r,o)),o=e1(o,oK)):u=e1(u,o))),th(rU(u,32),ta(o,o6))}function r4(n){var t,e,r,i;return isNaN(n)?(eM(),uc):n<-0x8000000000000000?(eM(),uu):n>=0x7fffffffffffffff?(eM(),uo):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=eo(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=eo(n/4194304),n-=4194304*t),i=ty(eo(n),t,e),r&&eT(i),i)}function r3(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iW;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iJ+r3(eQ(n));for(e=n,r=iV;!(0==e.l&&0==e.m&&0==e.h);){if(e=iI(e,e6(1e9),!0),t=iV+nB(o8),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iW+t;r=t+r}return r}function r6(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new ni(ot);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iI(g=ta(e6(S[0]),o6),w=ta(e6(l),o6),!1),v=n6(g,w),x!=i&&(d=eQ(d)),x<0&&(v=eQ(v)),tK(f9,{6:1},17,[eZ(d),eZ(v)])):(_=tU(fp,{6:1},-1,M,1),m=tK(fp,{6:1},-1,[ii(_,S,M,l)]),y=new to(x==i?1:-1,M,_),C=new to(x,1,m),tZ(y),tZ(C),tK(f9,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eI(a,e,h))<0)?tK(f9,{6:1},17,[uA,n]):(b=n.f,f=iL(o=tU(fp,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new to(b==i?1:-1,u,o),s=new to(b,r,f),tZ(c),tZ(s),tK(f9,{6:1},17,[c,s]))}function r5(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eP(n.g)),n.d;if(n.f<0)return et((n.d||(n.d=eP(n.g)),n.d),im(-n.f));if(n.f>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eP(n.g)),n.d).bb()||0!=(t=r6((n.d||(n.d=eP(n.g)),n.d),im(n.f)))[1].r())throw new ni(og);return t[0]}function r9(n,t,e,r,i){var o,u;if(o=oJ,e36)throw new nd("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nd(os+n+iG);return i}function r8(n){var t,e;if(0==n.f)return rW(),uS;if(eV(n,(rW(),uS)))return uA;if(e=tU(fp,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function ie(n,t){var e,r,i,o,u,f,c,s,a;if(s=0==n.f?1:n.f,u=~~t>>5,e=31&t,f=tU(fp,{6:1},-1,c=n_(u+1,n.e)+1,1),r=1<=n.e)f[u]=r;else if(u>(i=ew(n)))f[u]^=r;else if(u=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rG(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rN(a=th(rU(s,32),ta(e6(t[f]),o6)),oJ)?(c=iI(a,o,!1),s=n6(a,o)):(c=iI(i=rP(a,1),u=e6(~~r>>>1),!1),s=eY(rU(s=n6(i,u),1),ta(a,oK)),(1&r)!=0&&(rA(c,s)?rA(e1(c,s),o)?(s=eY(s,e1(rU(o,1),c)),c=e1(c,oW)):(s=eY(s,e1(o,c)),c=e1(c,oK)):s=e1(s,c))),n[f]=nB(ta(c,o6));return nB(s)}function io(n,t){var e,r,i,o,u,f,c;if(u=tU(fp,{6:1},-1,f=n_(n.e,t.e),1),i=ew(n),e=r=ew(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=np(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=et(u,im(r))),rt(o,u))}function is(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r4(ul[r]),b=e1(r4(c.f),e6(r)),h=iI(g=r4(c.g),l,!1),tm(a=n6(g,l),oJ)&&(s=tv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?0:nv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?-1:1,h=eY(h,e6(it(1&nB(h),(tv(a,oJ)?0:nv(a,oJ)?-1:1)*(5+s),t.c))),tn(ri(nv(h,oJ)?eQ(h):h))>=t.b&&(h=nQ(h,oX),b=e1(b,oK))),c.f=eK(ri(b)),c.e=t.b,c.g=ri(h),c.b=eX(h),c.d=null;return}f=im(r),i=r6((n.d||(n.d=eP(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rt(eH(i[1]._()),f),0!=(e=it(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&rn(i,0,iS(i[0],eZ(e6(e)))),new nL(i[0]).q()>o&&(rn(i,0,ih(i[0],(rW(),uB))),--u)),n.f=eK(u),n.e=o,tO(n,i[0])}}function ia(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u<0&&(e=eQ(e)),c<0&&(r=eQ(r)),eZ(e1(e,r));if(-1==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))h=-c,a=u==c?tJ(t.b,f,n.b,o):t6(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rW(),uA;a=tJ(n.b,o,t.b,f)}else a=t6(n.b,o,t.b,f);return tZ(s=new to(h,a.length,a)),s}function ih(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new ni(ot);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nQ(ta(e6(n.b[0]),o6),ta(e6(t.b[0]),o6)),s!=i&&(a=eQ(a)),eZ(a)):0==(e=c!=r?c>r?1:-1:eI(n.b,t.b,c))?s==i?uM:uS:-1==e?uA:(o=tU(fp,{6:1},-1,u=c-r+1,1),1==r?ii(o,n.b,c,t.b[0]):iL(o,u,n.b,c,t.b,r),tZ(f=new to(s==i?1:-1,u,o)),f)}function ib(n,t,e,r,i){var o,u;if(o=eY(ta(e6(t[0]),o6),ta(e6(r[0]),o6)),n[0]=nB(o),o=rK(o,32),e>=i){for(u=1;u0){if(i0?u=tQ(u,eo(i)):i<0&&(o=tQ(o,eo(-i))),id(o,u,e,r)}function iw(n,t){var e,r,i,o,u,f,c;if(r=ew(t),(i=ew(n))>=t.e)return t;if(u=tU(fp,{6:1},-1,f=t.e,1),rt.ab()?(c=eN(s),o=eN(t),i=tv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?0:nv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?-1:1,i=it(f.gb(0)?1:0,a*(5+i),r)):(i=rt(eH(s._()),t._()),i=it(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return eL(eY(eN(f),e6(i)),e);f=iS(f,eZ(e6(i)))}return new tM(f,e)}function ip(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;if(ix(),(u=nv(n,oJ))&&(n=eQ(n)),tv(n,oJ))switch(t){case 0:return iW;case 1:return iX;case 2:return iY;case 3:return i1;case 4:return i0;case 5:return i2;case 6:return i4;default:return s=new W,t<0?s.b.b+=i6:s.b.b+=i3,b=s.b,l=-2147483648==t?"2147483648":iV+-t,b.b+=l,s.b.b}c=tU(fK,{6:1},-1,19,1),e=18,h=n;do f=h,h=nQ(h,oX),c[--e]=65535&nB(eY(o0,e1(f,iR(h,oX))));while(tm(h,oJ))if(r=e1(e1(e1(o1,e6(e)),e6(t)),oK),0==t)return u&&(c[--e]=45),tP(c,e,18-e);if(t>0&&rN(r,oG)){if(rN(r,oJ)){for(o=17,i=e+nB(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tP(c,e,18-e+1)}for(o=2;nv(e6(o),eY(eQ(r),oK));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tP(c,e,18-e)}return(a=e+1,s=new Z,u&&(s.b.b+=iJ),18-a>=1)?(tE(s,c[e]),s.b.b+=iK,g=s.b,w=tP(c,e+1,18-e-1),g.b+=w):(d=s.b,_=tP(c,e,18-e),d.b+=_),s.b.b+=oc,rA(r,oJ)&&(s.b.b+=iz),v=s.b,m=iV+r3(r),v.b+=m,s.b.b}(r4(n.g),eo(n.f)),n.i):(i=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new W).b,u.b+=i,n.f>0&&r>=-6?r>=0?n7(o,e-eo(n.f),iK):(te(o.b,t-1,t-1,iZ),n7(o,t+1,tP(ua,0,-eo(r)-1))):(e-t>=1&&(te(o.b,t,t,iK),++e),te(o.b,e,e,oc),r>0&&n7(o,++e,iz),n7(o,++e,iV+r3(r4(r)))),n.i=o.b.b,n.i)}function i_(n,t){var e,r,i,o,u,f;if(i=ew(n),o=ew(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==iV;)--s;s1e6)throw new ni("power of ten too big");if(n<=2147483647)return uV[1].db(t).eb(t);for(i=r=uV[1].db(2147483647),e=r4(n-2147483647),t=eo(n%2147483647);rA(e,o3);)i=et(i,r),e=e1(e,o3);for(i=(i=et(i,uV[1].db(t))).eb(2147483647),e=r4(n-2147483647);rA(e,o3);)i=i.eb(2147483647),e=e1(e,o3);return i.eb(t)}function iy(){var n,t;c&&rx("com.iriscouch.gwtapp.client.BigDecimalApp"),nZ(new K),nY(new j),nX(new F),tk(new H),c&&rx("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oT)?oT:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=o$)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oF:-1!=t.indexOf(oD)&&f.documentMode>=9?"ie9":-1!=t.indexOf(oD)&&f.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tF(oF,n)||u.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),c&&rx("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=f.compatMode,n=tK(fI,{6:1},1,[oo]);e>5,this.b=tU(fp,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tZ(this)}}function iS(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u==c)?(l=nB(s=eY(e,r)),0==(b=nB(rP(s,32)))?new tV(u,l):new to(u,2,tK(fp,{6:1},-1,[l,b]))):eZ(u<0?e1(r,e):e1(e,r));if(u==c)h=u,a=o>=f?t6(n.b,o,t.b,f):t6(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))return rW(),uA;1==i?(h=u,a=tJ(n.b,o,t.b,f)):(h=c,a=tJ(t.b,f,n.b,o))}return tZ(s=new to(h,a.length,a)),s}function iM(n){var t,e,r,i;if(rF(),null==n)throw new nc("null string");if((t=t5(n)).length<27||t.length>45)throw new nu(ox);for(r=0;rfe.length)throw new q;if(o=null,i=null,67==r[0]?(i=uX,o=u5):68==r[0]?(i=uY,o=u9):70==r[0]?(i=u1,o=u7):72==r[0]?e>6&&(68==r[5]?(i=u0,o=u8):69==r[5]?(i=u2,o=fn):85==r[5]&&(i=u4,o=ft)):85==r[0]&&(80==r[1]?(i=u6,o=fr):78==r[1]&&(i=u3,o=fe)),i&&e==o.length){for(t=1;tl||r+i>s)throw new G;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tT(n,11),o=tT(e,11),nj(n)===nj(e)&&tr;)rn(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eK(e+(o>u?o:u)),s=(i=o-u)>0?(il(),i>19!=0&&(t=eQ(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?es(b):0==h&&0!=l&&0==b?es(l)+22:0!=h&&0==l&&0==b?es(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rK(n,u),c&&eT(f),e&&(o8=ty(0,0,0)),f;n=nT((eM(),uo)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eQ(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rK(g,u),w&&eT(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eT(f),o&&(r?(o8=eQ(n),i&&(o8=e1(o8,(eM(),uf)))):o8=ty(n.l,n.m,n.h)),f}(r?n:ty(n.l,n.m,n.h),t,c,o,i,e):(e&&(o8=o?eQ(n):ty(n.l,n.m,n.h)),ty(0,0,0))}function iE(n){var t=[];for(var e in n){var r=typeof n[e];r!=oQ?t[t.length]=r:n[e]instanceof Array?t[t.length]=oM:u&&u.bigdecimal&&u.bigdecimal.BigInteger&&n[e]instanceof u.bigdecimal.BigInteger?t[t.length]=on:u&&u.bigdecimal&&u.bigdecimal.BigDecimal&&n[e]instanceof u.bigdecimal.BigDecimal?t[t.length]=i9:u&&u.bigdecimal&&u.bigdecimal.RoundingMode&&n[e]instanceof u.bigdecimal.RoundingMode?t[t.length]=ow:u&&u.bigdecimal&&u.bigdecimal.MathContext&&n[e]instanceof u.bigdecimal.MathContext?t[t.length]=ob:t[t.length]=oQ}return t.join(iq)}function iR(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,ty(b,l&=4194303,g&=1048575)}function iO(n,t,e){var r,i,o,u,f,c,s,a;if(a=ri(eY(e6(e.b),oW))+(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=um.length-1,s=tK(f9,{6:1},17,[(n.d||(n.d=eP(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iN(n,t);if(a>0&&(rn(s,0,et((n.d||(n.d=eP(n.g)),n.d),im(a))),c+=a),u=(s=r6(s[0],(t.d||(t.d=eP(t.g)),t.d)))[0],0!=s[1].r())r=rt(eH(s[1]),(t.d||(t.d=eP(t.g)),t.d)),u=iS(et(u,(rW(),uB)),eZ(e6(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r6(u,um[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?n_(n.b,t.b)+1<54?new ti(n.g-t.g,n.f):new tx(ia((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f):e>0?e0?t.e:nP((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rW(),r=uA;else if(0==o)r=ih((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d));else if(o>0)u=im(o),r=ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),u)),r=et(r,u);else{for(u=im(-o),r=ih(et((n.d||(n.d=eP(n.g)),n.d),u),(t.d||(t.d=eP(t.g)),t.d));!r.gb(0);)if(0==(f=r6(r,um[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nB(m=r2(eY(rU(ta(e6(w[h]),o6),32),ta(e6(w[h-1]),o6)),c)),v=nB(rK(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iR(ta(e6(s),o6),ta(e6(d[o-2]),o6)),y=eY(rU(e6(v),32),ta(e6(w[h-2]),o6)),32>r$(nB(rP(g=eY(ta(e6(v),o6),ta(e6(c),o6)),32)))?_=!0:v=nB(g)}while(rA(tb(l,oV),tb(y,oV)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oJ,u=oJ;f0)rn(b,0,ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),im(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,rn(b,0,et(b[0],im(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r6(et((n.d||(n.d=eP(n.g)),n.d),im(u)),(t.d||(t.d=eP(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nL(b[1]).q()+u-t.q())&&(rn(b,1,ih(et(b[1],im(u)),(t.d||(t.d=eP(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new ni(of);if(0==b[0].r())return eU(o);for(w=b[0],g=(c=new nL(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r6(w,um[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new ni(of);return c.f=eK(h),tO(c,w),c}function ij(){var n;for(n=0,ij=g,uJ=tK(fp,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uK=tU(f9,{6:1},17,(uW=tK(fp,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rN(n,oJ)?(e=nQ(n,o4),r=n6(n,o4)):(e=nQ(t=rP(n,1),o2),r=eY(rU(r=n6(t,o2),1),ta(n,oK))),th(rU(r,32),ta(e,o6))}(eY(rU(y,32),ta(e6(M[c]),o6))),M[c]=nB(w),y=e6(nB(rK(w,32)));d=nB(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tP(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tP(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tP(v,e,_-e)}return(S=e+1,m=new Z,h&&(m.b.b+=iJ),_-S>=1)?(tE(m,v[e]),m.b.b+=iK,I=m.b,E=tP(v,e+1,_-e-1),I.b+=E):(R=m.b,O=tP(v,e,_-e),R.b+=O),m.b.b+=oc,o>0&&(m.b.b+=iz),D=m.b,k=iV+o,D.b+=k,m.b.b}c&&c({moduleName:"gwtapp",sessionId:s,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iH,i$,iV="",iq=" ",iG='"',iz="+",iJ="-",iK=".",iW="0",iZ="0.",iX="0.0",iY="0.00",i1="0.000",i0="0.0000",i2="0.00000",i4="0.000000",i3="0E",i6="0E+",i5=":",i9="BigDecimal",i7="BigDecimal MathContext",i8="BigDecimal;",on="BigInteger",ot="BigInteger divide by zero",oe="BigInteger not invertible.",or="BigInteger: modulus not positive",oi="BigInteger;",oo="CSS1Compat",ou="Division by zero",of="Division impossible",oc="E",os='For input string: "',oa="Infinite or NaN",oh="Invalid Operation",ob="MathContext",ol="Negative bit address",og="Rounding necessary",ow="RoundingMode",od="RoundingMode;",op="String",o_="[Lcom.iriscouch.gwtapp.client.",ov="[Ljava.lang.",om="[Ljava.math.",oy="\\.",oC="__gwtex_wrap",oS="anonymous",oM="array",ox="bad string format",oB="bigdecimal",oA="com.google.gwt.core.client.",oN="com.google.gwt.core.client.impl.",oI="com.iriscouch.gwtapp.client.",oE="java.lang.",oR="java.math.",oO="java.util.",oD="msie",ok="null",oL="number",oU="number MathContext",oP="number number",oQ="object",oT="opera",oj="org.timepedia.exporter.client.",oF="safari",oH="string",o$="undefined",oV={l:0,m:0,h:524288},oq={l:0,m:4193280,h:1048575},oG={l:4194298,m:4194303,h:1048575},oz={l:4194303,m:4194303,h:1048575},oJ={l:0,m:0,h:0},oK={l:1,m:0,h:0},oW={l:2,m:0,h:0},oZ={l:5,m:0,h:0},oX={l:10,m:0,h:0},oY={l:11,m:0,h:0},o1={l:18,m:0,h:0},o0={l:48,m:0,h:0},o2={l:877824,m:119,h:0},o4={l:1755648,m:238,h:0},o3={l:4194303,m:511,h:0},o6={l:4194303,m:1023,h:0},o5={l:0,m:1024,h:0};(i$=a.prototype={}).eQ=function(n){return this===n},i$.gC=function(){return fs},i$.hC=function(){return nF(this)},i$.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tU(fK,{6:1},-1,8,1),rv(),e=7,n>=0)for(;n>15;)t[e--]=uO[15&n],n>>=4;else for(;e>0;)t[e--]=uO[15&n],n>>=4;return t[e]=uO[15&n],t3(t,e,8)}(this.hC())},i$.toString=function(){return this.tS()},i$.tM=g,i$.cM={},(i$=h.prototype=new a).gC=function(){return fh},i$.j=function(){return this.f},i$.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},i$.cM={6:1,15:1},i$.f=null,(i$=b.prototype=new h).gC=function(){return fb},i$.cM={6:1,15:1},(i$=nr.prototype=l.prototype=new b).gC=function(){return fl},i$.cM={6:1,12:1,15:1},(i$=n0.prototype=(function(){}).prototype=new l).gC=function(){return fg},i$.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?ok:tt(e)?null==(r=t7(e))?null:r.name:nz(e,1)?op:(nH(e)?e.gC():fw).d,this.b=tt(n=this.c)?null==(i=t7(n))?null:i.message:n+iV,this.d="("+this.e+"): "+this.b+(tt(t=this.c)?function(n){var t=iV;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t7(t)):iV)),this.d},i$.cM={6:1,12:1,15:1},i$.b=null,i$.c=null,i$.d=null,i$.e=null,(i$=w.prototype=new a).gC=function(){return fd};var o9=0,o7=0;(i$=d.prototype=(function(){}).prototype=new w).gC=function(){return fm},i$.b=null,i$.c=null,(i$=_.prototype=v.prototype=new a).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i5+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oS},i$.gC=function(){return fy},i$.o=function(n){return[]},(i$=m.prototype=new v).k=function(){return tg(this.o(td()),this.p())},i$.gC=function(){return fM},i$.o=function(n){return eO(this,n)},i$.p=function(){return 2},(i$=y.prototype=(function(){}).prototype=new m).k=function(){return ea(this)},i$.n=function(n){var t,e;return 0==n.length||(0==(e=e7(n)).indexOf("at ")&&(e=n8(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oS:(-1!=(t=(e=e7(e.substr(0,t-0))).indexOf("."))&&(e=n8(e,t+1)),e.length>0?e:oS)},i$.gC=function(){return fx},i$.o=function(n){return t4(this,n)},i$.p=function(){return 3},(i$=C.prototype=new a).gC=function(){return fB},(i$=S.prototype=(function(){}).prototype=new C).gC=function(){return fA},i$.b=iV,(i$=M.prototype=(function(){}).prototype=new a).gC=function(){return this.aC},i$.aC=null,i$.qI=0;var o8=null,un=null;(i$=x.prototype=(function(){}).prototype=new a).gC=function(){return fE},i$.cM={2:1},(i$=B.prototype=new a).gC=function(){return fO},i$.cM={6:1,10:1};var ut=null;(i$=eu.prototype=ti.prototype=tx.prototype=tN.prototype=X.prototype=e_.prototype=ef.prototype=tA.prototype=tB.prototype=eJ.prototype=n4.prototype=n3.prototype=tr.prototype=tM.prototype=nL.prototype=A.prototype=new B).eQ=function(n){return e2(this,n)},i$.gC=function(){return fD},i$.hC=function(){return rm(this)},i$.q=function(){return rj(this)},i$.r=function(){return ed(this)},i$.tS=function(){return ip(this)},i$.cM={6:1,8:1,10:1,16:1},i$.b=0,i$.c=0,i$.d=null,i$.e=0,i$.f=0,i$.g=0,i$.i=null;var ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_,uv=null,um=null,uy=null;(i$=nU.prototype=nw.prototype=(function(){}).prototype=new A).s=function(n){var t,e,r;if((e=iE(n))==iV)t=0>ed(this)?ep(this):this;else if(e==ob)t=0>(r=t8(this,new iM(n[0].toString()))).r()?ep(r):r;else throw new nr("Unknown call signature for interim = super.abs: "+e);return new nU(t)},i$.t=function(n){var t,e;if((e=iE(n))==i9)t=r0(this,new X(n[0].toString()));else if(e==i7)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t8(r0(n,t),e);if((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)0?t.e:nP((t.b-1)*.3010299956639812)+1)<-r-1))return t8(r0(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nP((i.b-1)*.3010299956639812)+1)?t8(r0(n,t),e):(f=(o=i.r())==u.r()?iS(rZ((i.d||(i.d=eP(i.g)),i.d),10),eZ(e6(o))):iS(rZ(f=ia((i.d||(i.d=eP(i.g)),i.d),eZ(e6(o))),10),eZ(e6(9*o))),t8(i=new tx(f,i.f+1),e))}(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.add: "+e);return new nU(t)},i$.u=function(){return~~(nB(en(this,8))<<24)>>24},i$.v=function(n){return ic(this,n)},i$.w=function(n){var t,e,r,i;if((i=iE(n))==i9)e=el(this,new X(n[0].toString()));else if(i==i7)e=eg(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tU(fL,{6:1},3,e.length,0);t129?n*=1/0:n=t9(ip(this)),n},i$.gC=function(){return fk},i$.hC=function(){return rm(this)},i$.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nP((this.b-1)*.3010299956639812)+1)?0:(n=new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))).f*n.b[0]},i$.C=function(){return nB(en(this,32))},i$.D=function(){return nB(en(this,32))},i$.E=function(){return t9(ip(this))},i$.F=function(n){return new nU(ic(this,n)>=0?this:n)},i$.G=function(n){return new nU(0>=ic(this,n)?this:n)},i$.H=function(n){return new nU(rJ(this,this.f+n))},i$.I=function(n){return new nU(rJ(this,this.f-n))},i$.J=function(n){var t,e;if((e=iE(n))==i9)t=rk(this,new X(n[0].toString()));else if(e==i7)t=tl(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.multiply: "+e);return new nU(t)},i$.K=function(n){var t,e;if((e=iE(n))==iV)t=ep(this);else if(e==ob)t=ep(t8(this,new iM(n[0].toString())));else throw new nr("Unknown call signature for interim = super.negate: "+e);return new nU(t)},i$.L=function(n){var t,e;if((e=iE(n))==iV)t=this;else if(e==ob)t=t8(this,new iM(n[0].toString()));else throw new nr("Unknown call signature for interim = super.plus: "+e);return new nU(t)},i$.M=function(n){var t,e;if((e=iE(n))==oL)t=rd(this,n[0]);else if(e==oU)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=eo(tn(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rd(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new ni(oh);for(u>0&&(f=new eW(u+i+1,e.c)),r=t8(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tl(r,r,f),(o&c)==c&&(r=tl(r,n,f)),c>>=1;return t<0&&(r=iO(uw,r,f)),is(r,e),r}(this,n[0],new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.pow: "+e);return new nU(t)},i$.q=function(){return rj(this)},i$.N=function(n){var t,e;if((e=iE(n))==i9)t=el(this,new X(n[0].toString()))[1];else if(e==i7)t=eg(this,new X(n[0].toString()),new iM(n[1].toString()))[1];else throw new nr("Unknown call signature for interim = super.remainder: "+e);return new nU(t)},i$.O=function(n){return new nU(t8(this,new iM(eh(n.b))))},i$.P=function(){return eo(this.f)},i$.Q=function(n){var t,e;return new nU((t=this,(e=t.f-n,t.b<54)?0==t.g?eU(e):new ti(t.g,eK(e)):new tM((t.d||(t.d=eP(t.g)),t.d),eK(e))))},i$.R=function(n){var t,e;if((e=iE(n))==oL)t=r1(this,n[0],(iA(),u3));else if(e==oP)t=r1(this,n[0],rQ(n[1]));else if("number RoundingMode"==e)t=r1(this,n[0],ts(n[1].toString()));else throw new nr("Unknown call signature for interim = super.setScale: "+e);return new nU(t)},i$.S=function(){return~~(nB(en(this,16))<<16)>>16},i$.r=function(){return ed(this)},i$.T=function(){return new nU(function(n){var t,e,r,i,o;if(t=1,e=um.length-1,r=n.f,0==n.b&&-1!=n.g)return new X(iW);for(n.d||(n.d=eP(n.g)),o=n.d;!o.gb(0);)if(0==(i=r6(o,um[t]))[1].r())r-=t,t0?i.e:nP((i.b-1)*.3010299956639812)+1)0?r.e:nP((r.b-1)*.3010299956639812)+1)?(f=(c=ed(r))!=i.r()?iS(rZ((r.d||(r.d=eP(r.g)),r.d),10),eZ(e6(c))):iS(rZ(f=ia((r.d||(r.d=eP(r.g)),r.d),eZ(e6(c))),10),eZ(e6(9*c))),t8(new tx(f,r.f+1),o)):t8(iD(r,i),o);else throw new nr("Unknown call signature for interim = super.subtract: "+e);return new nU(t)},i$.V=function(){return new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))},i$.W=function(){return new n2(r5(this))},i$.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nq(u),n.f>0&&i>=-6)i>=0?n7(c,r-eo(n.f),iK):(te(c.b,t-1,t-1,iZ),n7(c,t+1,tP(ua,0,-eo(i)-1)));else{if(e=r-t,0!=(f=eo(i%3))&&(0==(n.d||(n.d=eP(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n7(c,r++,iW);r-t>=1&&(te(c.b,t,t,iK),++r),0!=i&&(te(c.b,r,r,oc),i>0&&n7(c,++r,iz),n7(c,++r,iV+r3(r4(i))))}return c.b.b}(this)},i$.Y=function(){return function(n){var t,e,r,i,o,u;if(r=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ed(n)?1:0,e=n.f,i=new Z(r.length+1+((o=eo(n.f))<0?-o:o)),1==t&&(i.b.b+=iJ),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iZ;e>ua.length;e-=ua.length)tG(i,ua);n9(i,ua,eo(e)),nE(i,n8(r,t))}else nE(i,(u=eo(e=t-e),r.substr(t,u-t))),i.b.b+=iK,nE(i,n8(r,eo(e)))}else{for(nE(i,n8(r,t));e<-ua.length;e+=ua.length)tG(i,ua);n9(i,ua,eo(-e))}return i.b.b}(this)},i$.tS=function(){return ip(this)},i$.Z=function(){return new nU(new ti(1,this.f))},i$.$=function(){return new n2((this.d||(this.d=eP(this.g)),this.d))},i$.cM={3:1,6:1,8:1,10:1,16:1,24:1},(i$=H.prototype=(function(){}).prototype=new a).gC=function(){return fU};var uC=!1;(i$=ru.prototype=ro.prototype=to.prototype=e9.prototype=tV.prototype=rh.prototype=nG.prototype=iC.prototype=N.prototype=new B)._=function(){return this.f<0?new to(1,this.e,this.b):this},i$.ab=function(){return eq(this)},i$.eQ=function(n){return eV(this,n)},i$.gC=function(){return fP},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.cb=function(){return 0==this.f?this:new to(-this.f,this.e,this.b)},i$.db=function(n){return rL(this,n)},i$.eb=function(n){return tY(this,n)},i$.fb=function(n){return t1(this,n)},i$.r=function(){return this.f},i$.gb=function(n){return rT(this,n)},i$.tS=function(){return iF(this,0)},i$.cM={6:1,8:1,10:1,17:1},i$.b=null,i$.c=-2,i$.d=0,i$.e=0,i$.f=0;var uS,uM,ux,uB,uA,uN=null;(i$=n2.prototype=nD.prototype=nk.prototype=(function(){}).prototype=new N)._=function(){return new n2(this.f<0?new to(1,this.e,this.b):this)},i$.hb=function(n){return new n2(iS(this,n))},i$.ib=function(n){return new n2(0==n.f||0==this.f?(rW(),uA):eV(n,(rW(),uS))?this:eV(this,uS)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=np(n.e,t.e),(e=n_(ew(n),ew(t)))>=i)return rW(),uA;for(r=tU(fp,{6:1},-1,i,1);e0?rz(n,this):this.e>n.e?i_(this,n):i_(n,this))},i$.jb=function(n){return new n2(0==n.f?this:0==this.f?(rW(),uA):eV(this,(rW(),uS))?new n2(r8(n)):eV(n,uS)?uA:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tU(fp,{6:1},-1,n.e,1),r=np(n.e,t.e),e=ew(n);e=n.e)return n;for(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=ew(n),o=ew(t),i>=t.e)return n;if(c=n_(n.e,t.e),r=i,o>i){for(f=tU(fp,{6:1},-1,c,1),u=np(n.e,o);r=t.e)return rW(),uA;if(u=tU(fp,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},i$.qb=function(n){return new n2(rR(this,n))},i$.gC=function(){return fQ},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.B=function(){return this.f*this.b[0]},i$.rb=function(n){return function(n,t){var e,r;if(ij(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rT(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uW,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n2(this.f<0?new to(1,this.e,this.b):this),n)},i$.sb=function(){return t9(iF(this,0))},i$.tb=function(n){return new n2(1==rt(this,n)?this:n)},i$.ub=function(n){return new n2(-1==rt(this,n)?this:n)},i$.vb=function(n){return new n2(ee(this,n))},i$.wb=function(n){return new n2(rO(this,n))},i$.xb=function(n,t){return new n2(rG(this,n,t))},i$.yb=function(n){return new n2(et(this,n))},i$.cb=function(){return new n2(0==this.f?this:new to(-this.f,this.e,this.b))},i$.zb=function(){return new n2(function(n){if(n.f<0)throw new ni("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(ij(),o=tU(fp,{6:1},-1,uW.length,1),r=tU(fv,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uW[e];++e);return uK[e]}for(f=new to(1,n.e,tU(fp,{6:1},-1,n.e+1,1)),iB(n.b,0,f.b,0,n.e),rT(n,0)?tW(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iw(this,n):n.f>0?iw(n,this):ew(n)>ew(this)?rX(n,this):rX(this,n))},i$.db=function(n){return new n2(rL(this,n))},i$.Cb=function(n){return new n2(rH(this,n))},i$.Db=function(n){return new n2(rT(this,n)?this:ie(this,n))},i$.eb=function(n){return new n2(tY(this,n))},i$.fb=function(n){return new n2(t1(this,n))},i$.r=function(){return this.f},i$.Eb=function(n){return new n2(ia(this,n))},i$.gb=function(n){return rT(this,n)},i$.Fb=function(n){var t,e;if((e=iE(n))==iV)t=iF(this,0);else if(e==oL)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(ix(),g=n.f,s=n.e,u=n.b,0==g)return iW;if(1==s)return _=ta(e6(u[0]),o6),g<0&&(_=eQ(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return iV+r3(n);if(e=tU(fK,{6:1},-1,65,1),rv(),r=64,i=e6(t),rN(n,oJ)){for(;rN(n,i);)e[r--]=uO[nB(n6(n,i))],n=iI(n,i,!1);e[r]=uO[nB(n)]}else{for(;!rA(n,eQ(i));)e[r--]=uO[nB(eQ(n6(n,i)))],n=iI(n,i,!1);e[r--]=uO[nB(eQ(n))],e[r]=45}return t3(e,r,65)}(_,t);if(10==t||t<2||t>36)return iF(n,0);if(l=tU(fK,{6:1},-1,b=eo(eq(new n2(n.f<0?new to(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(iB(u,0,w=tU(fp,{6:1},-1,s,1),0,s),d=s,r=uP[t],e=uU[t-2];;){h=ii(w,w,d,e),a=i;do l[--i]=em(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=em(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tP(l,i,b-i)}(this,n[0]);else throw new nr("Unknown call signature for result = super.toString: "+e);return t},i$.Gb=function(n){return new n2(0==n.f?this:0==this.f?n:eV(n,(rW(),uS))?new n2(r8(this)):eV(this,uS)?new n2(r8(n)):this.f>0?n.f>0?this.e>n.e?rw(this,n):rw(n,this):iU(this,n):n.f>0?iU(n,this):ew(n)>ew(this)?io(n,this):io(this,n))},i$.cM={4:1,6:1,8:1,10:1,17:1,24:1},(i$=F.prototype=(function(){}).prototype=new a).gC=function(){return fj};var uI=!1;(i$=nm.prototype=ny.prototype=(function(){}).prototype=new a).gC=function(){return fF},i$.Hb=function(){return this.b.b},i$.Ib=function(){return new nn(this.b.c)},i$.hC=function(){return nx(this.b)},i$.tS=function(){return eh(this.b)},i$.cM={24:1},i$.b=null,(i$=j.prototype=(function(){}).prototype=new a).gC=function(){return fH};var uE=!1;(i$=nn.prototype=nC.prototype=(function(){}).prototype=new a).gC=function(){return f$},i$.Jb=function(){return this.b.b},i$.tS=function(){return this.b.b},i$.cM={5:1,24:1},i$.b=null,(i$=K.prototype=(function(){}).prototype=new a).gC=function(){return fq};var uR=!1;(i$=ni.prototype=(function(){}).prototype=new l).gC=function(){return fG},i$.cM={6:1,12:1,15:1},(i$=no.prototype=V.prototype=(function(){}).prototype=new l).gC=function(){return fJ},i$.cM={6:1,12:1,15:1},(i$=I.prototype=(function(){}).prototype=new a).gC=function(){return fW},i$.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?iV:"class ")+this.d},i$.b=null,i$.c=0,i$.d=null,(i$=$.prototype=(function(){}).prototype=new l).gC=function(){return fZ},i$.cM={6:1,12:1,15:1},(i$=E.prototype=new a).eQ=function(n){return this===n},i$.gC=function(){return fa},i$.hC=function(){return nF(this)},i$.tS=function(){return this.b},i$.cM={6:1,8:1,9:1},i$.b=null,i$.c=0,(i$=nu.prototype=q.prototype=R.prototype=new l).gC=function(){return fX},i$.cM={6:1,12:1,15:1},(i$=nf.prototype=G.prototype=O.prototype=new l).gC=function(){return fz},i$.cM={6:1,12:1,15:1},(i$=nc.prototype=z.prototype=(function(){}).prototype=new l).gC=function(){return fY},i$.cM={6:1,12:1,15:1},(i$=nd.prototype=(function(){}).prototype=new R).gC=function(){return f1},i$.cM={6:1,12:1,15:1},(i$=tu.prototype=(function(){}).prototype=new a).gC=function(){return fC},i$.tS=function(){return this.b+iK+this.d+"(Unknown Source"+(this.c>=0?i5+this.c:iV)+")"},i$.cM={6:1,13:1},i$.b=null,i$.c=0,i$.d=null,(i$=String.prototype).eQ=function(n){return tF(this,n)},i$.gC=function(){return fN},i$.hC=function(){var n,t;return nK(),null!=(t=uk[n=i5+this])?t:(null==(t=uD[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;et?n:t}function nv(n,t){return!rN(n,t)}function nm(n){this.b=new iM(n)}function ny(){this.b=(rF(),uF)}function nC(){this.b=(iA(),u4)}function nS(n,t){var e;nb(),e=o.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tw(n){return nz(n,15)?n:new n0(n)}function td(){try{null.a()}catch(n){return n}}function tp(n){var t;return(t=new I).d=iV+n,t.c=1,t}function t_(n,t){return nH(n)?n.eQ(t):n===t}function tv(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tm(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function ty(n,t,e){return(i$=new x).l=n,i$.m=t,i$.h=e,i$}function tC(n,t){return nj(n)===nj(t)||null!=n&&t_(n,t)}function tS(n,t){throw new nf("Index: "+n+", Size: "+t)}function tM(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tx(n,t){if(!n)throw new z;this.f=t,tO(this,n)}function tB(n,t,e,r){eJ.call(this,n,t,e),is(this,r)}function tA(n,t){eJ.call(this,n,0,n.length),is(this,t)}function tN(n,t){eJ.call(this,t5(n),0,n.length),is(this,t)}function tI(n){nr.call(this,"String index out of range: "+n)}function tE(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tR(n,t){rC(n.b,n.b,n.e,t.b,t.e),tZ(n),n.c=-2}function tO(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=ri(eN(t)))}function tD(){tD=g,ur=[],ui=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new M,ur,ui)}function tk(){uC||(uC=!0,new j,new F,function(){if(ng(oB,iV),u.bigdecimal.BigDecimal)var n=u.bigdecimal.BigDecimal;u.bigdecimal.BigDecimal=fc(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fk?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new nw,nl(this.__gwt_instance,this))});var t=u.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)u.bigdecimal.BigDecimal[p]=n[p];u.bigdecimal.BigDecimal.ROUND_CEILING=2,u.bigdecimal.BigDecimal.ROUND_DOWN=1,u.bigdecimal.BigDecimal.ROUND_FLOOR=3,u.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,u.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,u.bigdecimal.BigDecimal.ROUND_HALF_UP=4,u.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,u.bigdecimal.BigDecimal.ROUND_UP=0,u.bigdecimal.BigDecimal.__init__=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==on)t=new nL(new nG(n[0].toString()));else if("BigInteger number"==e)t=new tM(new nG(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new tr(new nG(n[0].toString()),n[1],new iM(n[2].toString()));else if("BigInteger MathContext"==e)t=new n3(new nG(n[0].toString()),new iM(n[1].toString()));else if(e==oM)t=new n4(t5(n[0].toString()));else if("array number number"==e)t=new eJ(t5(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tB(t5(n[0].toString()),n[1],n[2],new iM(n[3].toString()));else if("array MathContext"==e)t=new tA(t5(n[0].toString()),new iM(n[1].toString()));else if(e==oL)t=new ef(n[0]);else if(e==oU)t=new e_(n[0],new iM(n[1].toString()));else if(e==oH)t=new X(n[0].toString());else if("string MathContext"==e)t=new tN(n[0].toString(),new iM(n[1].toString()));else throw new nr("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nU(t)}(n);return nR(t)}),t.abs_va=fc(function(n){return nR(this.__gwt_instance.s(n))}),t.add_va=fc(function(n){return nR(this.__gwt_instance.t(n))}),t.byteValueExact=fc(function(){return this.__gwt_instance.u()}),t.compareTo=fc(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=fc(function(n){return nR(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=fc(function(n){return nR(this.__gwt_instance.x(n))}),t.doubleValue=fc(function(){return this.__gwt_instance.z()}),t.equals=fc(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=fc(function(){return this.__gwt_instance.A()}),t.hashCode=fc(function(){return this.__gwt_instance.hC()}),t.intValue=fc(function(){return this.__gwt_instance.B()}),t.intValueExact=fc(function(){return this.__gwt_instance.C()}),t.max=fc(function(n){return nR(this.__gwt_instance.F(n.__gwt_instance))}),t.min=fc(function(n){return nR(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=fc(function(n){return nR(this.__gwt_instance.H(n))}),t.movePointRight=fc(function(n){return nR(this.__gwt_instance.I(n))}),t.multiply_va=fc(function(n){return nR(this.__gwt_instance.J(n))}),t.negate_va=fc(function(n){return nR(this.__gwt_instance.K(n))}),t.plus_va=fc(function(n){return nR(this.__gwt_instance.L(n))}),t.pow_va=fc(function(n){return nR(this.__gwt_instance.M(n))}),t.precision=fc(function(){return this.__gwt_instance.q()}),t.remainder_va=fc(function(n){return nR(this.__gwt_instance.N(n))}),t.round=fc(function(n){return nR(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=fc(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=fc(function(n){return nR(this.__gwt_instance.Q(n))}),t.setScale_va=fc(function(n){return nR(this.__gwt_instance.R(n))}),t.shortValueExact=fc(function(){return this.__gwt_instance.S()}),t.signum=fc(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=fc(function(){return nR(this.__gwt_instance.T())}),t.subtract_va=fc(function(n){return nR(this.__gwt_instance.U(n))}),t.toBigInteger=fc(function(){return nR(this.__gwt_instance.V())}),t.toBigIntegerExact=fc(function(){return nR(this.__gwt_instance.W())}),t.toEngineeringString=fc(function(){return this.__gwt_instance.X()}),t.toPlainString=fc(function(){return this.__gwt_instance.Y()}),t.toString=fc(function(){return this.__gwt_instance.tS()}),t.ulp=fc(function(){return nR(this.__gwt_instance.Z())}),t.unscaledValue=fc(function(){return nR(this.__gwt_instance.$())}),t.divideAndRemainder_va=fc(function(n){return nO(this.__gwt_instance.w(n))}),t.longValue=fc(function(){return this.__gwt_instance.E()}),t.longValueExact=fc(function(){return this.__gwt_instance.D()}),u.bigdecimal.BigDecimal.valueOf_va=fc(function(n){var t=function(n){var t,e;if(iP(),(e=iE(n))==oL)t=function(n){if(!isFinite(n)||isNaN(n))throw new nd(oa);return new X(iV+n)}(n[0]);else if(e==oL)t=tX(e6(n[0]));else if(e==oP)t=eL(e6(n[0]),n[1]);else throw new nr("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nU(t)}(n);return nR(t)}),u.bigdecimal.BigDecimal.log=fc(function(n){iP(),typeof console!==o$&&console.log&&console.log(n)}),u.bigdecimal.BigDecimal.logObj=fc(function(n){iP(),typeof console!==o$&&console.log&&typeof JSON!==o$&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),u.bigdecimal.BigDecimal.ONE=fc(function(){var n=(iP(),new nU(uw));return nR(n)}),u.bigdecimal.BigDecimal.TEN=fc(function(){var n=(iP(),new nU(ud));return nR(n)}),u.bigdecimal.BigDecimal.ZERO=fc(function(){var n=(iP(),new nU(up));return nR(n)}),nS(fk,u.bigdecimal.BigDecimal)}())}function tL(n,t,e){var r;return(r=new I).d=n+t,r.c=4,r.b=e,r}function tU(n,t,e,r,i){var o;return tK(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tI(e)}(n.length,t,r),t3(n,t,r)}function tQ(n,t){return il(),t=n.c.c)throw new J;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tS(r,i),t.b[e]}function tF(n,t){return!!nz(t,1)&&String(n)==t}function tH(){nr.call(this,"Add not supported on this collection")}function t$(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function tV(n,t){rW(),this.f=n,this.e=1,this.b=tK(fp,{6:1},-1,[t])}function tq(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tG(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tz(n,t,e,r){var i,o;return null==t&&(t=ok),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tJ(n,t,e,r){var i;return rC(i=tU(fp,{6:1},-1,t,1),n,t,e,r),i}function tK(n,t,e,r){return tD(),function(n,t,e){tD();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tX(n){return rN(n,oJ)&&nv(n,oY)?us[nB(n)]:new eu(n,0)}function tY(n,t){return 0==t||0==n.f?n:t>0?e3(n,t):rY(n,-t)}function t1(n,t){return 0==t||0==n.f?n:t>0?rY(n,t):e3(n,-t)}function t0(n){var t;return 0==n.f?-1:((t=ew(n))<<5)+es(n.b[t])}function t2(n){var t;return 0!=(t=nB(n))?es(t):es(nB(rK(n,32)))+32}function t4(n,t){var e;return 0==(e=eO(n,t)).length?(new _).o(t):tg(e,1)}function t3(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t6(n,t,e,r){var i;return ib(i=tU(fp,{6:1},-1,t+1,1),n,t,e,r),i}function t5(n){var t,e;return t=tU(fK,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nB(y=iR(ta(e6(b.b[0]),o6),ta(e6(l.b[0]),o6))),0==(C=nB(rP(y,32)))?new tV(v,S):new to(v,2,tK(fp,{6:1},-1,[S,C]))):(eG(b.b,g,l.b,w,d=tU(fp,{6:1},-1,_,1)),tZ(m=new to(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=ia(t,a.eb(f)),o=ia(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iS(iS(u=n(ia(a,i),ia(o,h)),s),r)).eb(f),iS(iS(s=s.eb(f<<1),u),r))}(n,t))}function ee(n,t){var e;if(t.f<=0)throw new ni(or);return(e=rH(n,t)).f<0?iS(e,t):e}function er(n){var t;t=new nJ,n.d&&n5(t,new ne(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nA(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eP(n.g)),n.d).r()}function ep(n){return n.b<54?new ti(-n.g,n.f):new tx((n.d||(n.d=eP(n.g)),n.d).cb(),n.f)}function e_(n,t){if(!isFinite(n)||isNaN(n))throw new nd(oa);iQ(this,n.toPrecision(20)),is(this,t)}function ev(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function em(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function ey(n,t){var e,r;return t?((e=t[oC])||(e=new(r=t.gC(),t7(ei(n.b,r)))(t),t[oC]=e),e):null}function eC(n){var t,e;return 32==(e=r$(n.h))?32==(t=r$(n.m))?r$(n.l)+32:t+20-10:e-12}function eS(n){return ty(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eM(){eM=g,uo=ty(4194303,4194303,524287),uu=ty(0,0,524288),uf=e6(1),e6(2),uc=e6(0)}function ex(n,t){ib(n.b,n.b,n.e,t.b,t.e),n.e=np(n_(n.e,t.e)+1,n.b.length),tZ(n),n.c=-2}function eB(n,t){var e;e=~~t>>5,n.e+=e+(r$(n.b[n.e-1])-(31&t)>=0?0:1),rS(n.b,n.b,e,31&t),tZ(n),n.c=-2}function eA(n,t){var e,r;e=~~t>>5,n.e>>r:0,tZ(n))}function eN(n){var t;return t=n.e>1?th(rU(e6(n.b[1]),32),ta(e6(n.b[0]),o6)):ta(e6(n.b[0]),o6),iR(e6(n.f),t)}function eI(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:nv(ta(e6(n[r]),o6),ta(e6(t[r]),o6))?-1:1}function eE(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eR(n,t,e,r){if(iH=t,n)try{fc(iy)()}catch(i){n(t)}else fc(iy)()}function eO(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eu(oJ,2147483647):new eu(oJ,-2147483648)}function eP(n){return(rW(),n<0)?-1!=n?new ru(-1,-n):uS:n<=10?ux[eo(n)]:new ru(1,n)}function eQ(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,ty(t,e,r)}function eT(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function ej(n){var t,e,r;for(r=0,e=tU(fS,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rA(ta(e6(n[r]),o6),ta(e6(i[r]),o6));break}}return u=new to(1,o+1,n),e&&tR(u,t),tZ(u),u}(o,e)}function eV(n,t){var e;return n===t||!!nz(t,17)&&(e=tT(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eq(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&ew(n)==n.e-1&&(e=~~(e-1)),t-=r$(e))}function eG(n,t,e,r,i){il(),0!=t&&0!=r&&(1==t?i[r]=rc(i,e,r,n[0]):1==r?i[t]=rc(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nj(n)===nj(t)&&r==i){iu(n,r,e);return}for(f=0;f2147483647))return eo(n);throw new ni("Underflow")}function eW(n,t){if(rF(),n<0)throw new nu("Digits < 0");if(!t)throw new nc("null RoundingMode");this.b=n,this.c=t}function eZ(n){return(rW(),nv(n,oJ))?tm(n,oz)?new ro(-1,eQ(n)):uS:rA(n,oX)?new ro(1,n):ux[nB(n)]}function eX(n){var t;return nv(n,oJ)&&(n=ty(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nB(rK(n,32)))?r$(t):r$(nB(n))+32)}function eY(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),ty(4194303&e,4194303&r,1048575&i)}function e0(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-n_(e,n.bb())}function e2(n,t){var e;return n===t||!!nz(t,16)&&(e=tT(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e4(n,t,e){var r,i,o;for(o=oJ,r=t-1;r>=0;--r)i=r2(eY(rU(o,32),ta(e6(n[r]),o6)),e),o=e6(nB(rK(i,32)));return nB(o)}function e3(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rS(r=tU(fp,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tZ(o=new to(n.f,i,r)),o}function e6(n){var t,e;return n>-129&&n<128?(t=n+128,null==un&&(un=tU(fR,{6:1},2,256,0)),(e=un[t])||(e=un[t]=eS(n)),e):eS(n)}function e5(n){var t,e,r;return(rW(),n>5,t=31&n,(r=tU(fp,{6:1},-1,e+1,1))[e]=1<iq&&n[n.length-1]>iq?n:n.replace(/^(\s*)/,iV).replace(/\s*$/,iV)}function e8(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function rn(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==g||n$(e,1)))throw new V}return n[t]=e}function rt(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=e$(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=e$(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tU(f9,{6:1},17,8,0),a=n,rn(s,0,t),h=e$(t,t,r,i),u=1;u<=7;++u)rn(s,u,e$(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=e$(a,a,r,i);return a}(f,r,t,e,o),e$(u,(rW(),uM),e,o)}function ra(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nd("Radix out of range");if(0==n.length)throw new nd("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(ix(),uP)[e])),0!=(d=l%u)&&++o,c=tU(fp,{6:1},-1,o,1),r=uU[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:nv(ta(e6(n[i]),o6),ta(e6(t[i]),o6))?-1:1}function rg(n,t){var e,r,i;for(r=tU(fp,{6:1},-1,i=n.e,1),np(ew(n),ew(t)),e=0;e999999999)throw new ni(oh);return e=n.f*t,0==n.b&&-1!=n.g?eU(e):new tM((n.d||(n.d=eP(n.g)),n.d).db(t),eK(e))}function rp(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fu[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fo[n]=t,t*=.5}function rv(){rv=g,uO=tK(fK,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rm(n){var t;return 0!=n.c?n.c:n.b<54?(t=r4(n.g),n.c=nB(ta(t,oz)),n.c=33*n.c+nB(ta(rK(t,32),oz)),n.c=17*n.c+eo(n.f),n.c):(n.c=17*n.d.hC()+eo(n.f),n.c)}function ry(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=ev(n*t,0),0!=u&&(i=ev((u<=0?0-u:u)*2,t<=0?0-t:t),o+=it(1&eo(o),f*(5+i),r)),new ti(o,e)}function rC(n,t,e,r,i){var o,u;for(u=0,o=oJ;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rD(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=eo(nP(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eX(r4(n))}function rR(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eZ(rI(eN(e),eN(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rB(n,e),rB(t,r),1==rt(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eZ(rI(eN(n),eN(t)));break}if(t.e>1.2*n.e)0!=(t=rH(t,n)).r()&&rB(t,t.bb());else do tR(t,n),rB(t,t.bb());while(rt(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?eB(f,i):(rB(c,r-e0&&eB(f,i-r+e)),e+=i),0!=(i=e0(h,u))&&(eB(h,i),r>=e?eB(c,i):(rB(f,e-r0&&eB(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rq(s,h),rq(f,c)):(rq(h,s),rq(c,f)):e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)),0==h.r()||0==s.r())throw new ni(oe);return eD(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():ia(t,f)),0>f.r()&&(f=iS(f,t)),f}(n,t);for(o=32*t.e,h=eb(t),u=n_((b=eb(n)).e,h.e),c=new to(1,1,tU(fp,{6:1},-1,u+1,1)),(s=new to(1,1,tU(fp,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rB(h,r),rB(b,i),eB(c,i),e+=r-i):(rB(h,r),rB(b,i),eB(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rt(h,b)>0;)tR(h,b),a=h.bb(),rB(h,a),ex(c,s),eB(s,a),e+=a;for(;0>=rt(h,b)&&(tR(b,h),0!=b.r());)a=b.bb(),rB(b,a),ex(s,c),eB(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new ni(oe);return rt(c,t)>=0&&tR(c,t),c=ia(t,c),f=rf(t),e>o&&(c=e$(c,(rW(),uM),t,f),e-=o),c=e$(c,e5(o-e),t,f)}(ee(n._(),t),t)).f)throw new ni(oe);return n.f<0?ia(t,e):e}function rD(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rk(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eU(e):n.b+t.b<54?new ti(n.g*t.g,eK(e)):new tM(et((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),eK(e))}function rL(n,t){var e;if(t<0)throw new ni("Negative exponent");if(0==t)return uM;if(1==t||n.eQ(uM)||n.eQ(uA))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return et(e5(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(il(),rW(),r=uM,e=n;t>1;t>>=1)(1&t)!=0&&(r=et(r,e)),e=1==e.e?et(e,e):new e9(iu(e.b,e.e,tU(fp,{6:1},-1,e.e<<1,1)));return et(r,e)}(n,t)}function rU(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),ty(4194303&r,4194303&i,1048575&o)}function rQ(n){switch(iA(),n){case 2:return uX;case 1:return uY;case 3:return u1;case 5:return u0;case 6:return u2;case 4:return u4;case 7:return u3;case 0:return u6;default:throw new nu("Invalid rounding mode")}}function rT(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new ni(ol);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=ew(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rj(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ih((n.d||(n.d=eP(n.g)),n.d),im(t)).r()&&++t),n.e=eo(t)),n.e}function rF(){rF=g,uQ=new eW(34,(iA(),u2)),uT=new eW(7,u2),uj=new eW(16,u2),uF=new eW(0,u4),uH=tK(fK,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),u$=tK(fK,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rH(n,t){var e,r,i,o;if(0==t.f)throw new ni(ot);return((o=n.e)!=(e=t.e)?o>e?1:-1:eI(n.b,t.b,o))==-1?n:(r=tU(fp,{6:1},-1,e,1),1==e?r[0]=e4(n.b,o,t.b[0]):r=iL(null,o-e+1,n.b,o,t.b,e),tZ(i=new to(n.f,e,r)),i)}function r$(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16)+(t=~~(r=(n=~~n>>t)-256)>>16&8),n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function rV(n,t){if(0==n.f)iB(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ib(n.b,n.b,n.e,t.b,t.e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rq(n,t){var e;e=rt(n,t),0==n.f?(iB(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ib(n.b,n.b,n.e,t.b,t.e),n.f=e):rl(n.b,t.b,n.e,t.e)>0?rC(n.b,n.b,n.e,t.b,t.e):(r9(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=n_(n.e,t.e)+1,tZ(n),n.c=-2}function rG(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new ni(or);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uA:0==r.f&&0==t.f?uM:(t.f<0&&(r=rO(n,e),t=t.cb()),i=e.gb(0)?rs(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rs(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rW(),u=uM,i=eb(t),r=eb(n),n.gb(0)&&eA(i,e-1),eA(r,e),o=i.ab()-1;o>=0;--o)eA(f=eb(u),e),u=et(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eA(u=et(u,r),e);return eA(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e9(tU(fp,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eA(b=et(ia(h,a),s),f),b.f<0&&(b=iS(b,e5(f))),iS(a,et(c,b))),r.f<0&&t.gb(0)&&(i=ee(et(ia(e,uM),i),e)),i)}function rz(n,t){var e,r,i,o,u,f,c;if(i=ew(n),(r=ew(t))>=n.e)return rW(),uA;for(u=tU(fp,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=np(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new ti(n.g,eK(t)):new tM((n.d||(n.d=eP(n.g)),n.d),eK(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),ty(4194303&i,4194303&o,1048575&u)}function rW(){var n;for(n=0,rW=g,uM=new tV(1,1),uB=new tV(1,10),uA=new tV(0,0),uS=new tV(-1,1),ux=tK(f9,{6:1},17,[uA,uM,new tV(1,2),new tV(1,3),new tV(1,4),new tV(1,5),new tV(1,6),new tV(1,7),new tV(1,8),new tV(1,9),uB]),uN=tU(f9,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rW(),uS):(rW(),uA);if(rD(i=tU(fp,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rM(n,t,e):rM(t,n,-e):n_(n.b,t.b)+1<54?new ti(n.g+t.g,n.f):new tx(iS((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f)}function r2(n,t){var e,r,i,o,u;return(r=ta(e6(t),o6),rN(n,oJ))?(o=iI(n,r,!1),u=n6(n,r)):(o=iI(e=rP(n,1),i=e6(~~t>>>1),!1),u=eY(rU(u=n6(e,i),1),ta(n,oK)),(1&t)!=0&&(rA(o,u)?rA(e1(o,u),r)?(u=eY(u,e1(rU(r,1),o)),o=e1(o,oW)):(u=eY(u,e1(r,o)),o=e1(o,oK)):u=e1(u,o))),th(rU(u,32),ta(o,o6))}function r4(n){var t,e,r,i;return isNaN(n)?(eM(),uc):n<-0x8000000000000000?(eM(),uu):n>=0x7fffffffffffffff?(eM(),uo):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=eo(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=eo(n/4194304),n-=4194304*t),i=ty(eo(n),t,e),r&&eT(i),i)}function r3(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iW;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iJ+r3(eQ(n));for(e=n,r=iV;!(0==e.l&&0==e.m&&0==e.h);){if(e=iI(e,e6(1e9),!0),t=iV+nB(o8),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iW+t;r=t+r}return r}function r6(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new ni(ot);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iI(g=ta(e6(S[0]),o6),w=ta(e6(l),o6),!1),v=n6(g,w),x!=i&&(d=eQ(d)),x<0&&(v=eQ(v)),tK(f9,{6:1},17,[eZ(d),eZ(v)])):(_=tU(fp,{6:1},-1,M,1),m=tK(fp,{6:1},-1,[ii(_,S,M,l)]),y=new to(x==i?1:-1,M,_),C=new to(x,1,m),tZ(y),tZ(C),tK(f9,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eI(a,e,h))<0)?tK(f9,{6:1},17,[uA,n]):(b=n.f,f=iL(o=tU(fp,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new to(b==i?1:-1,u,o),s=new to(b,r,f),tZ(c),tZ(s),tK(f9,{6:1},17,[c,s]))}function r5(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eP(n.g)),n.d;if(n.f<0)return et((n.d||(n.d=eP(n.g)),n.d),im(-n.f));if(n.f>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eP(n.g)),n.d).bb()||0!=(t=r6((n.d||(n.d=eP(n.g)),n.d),im(n.f)))[1].r())throw new ni(og);return t[0]}function r9(n,t,e,r,i){var o,u;if(o=oJ,e36)throw new nd("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nd(os+n+iG);return i}function r8(n){var t,e;if(0==n.f)return rW(),uS;if(eV(n,(rW(),uS)))return uA;if(e=tU(fp,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function ie(n,t){var e,r,i,o,u,f,c,s,a;if(s=0==n.f?1:n.f,u=~~t>>5,e=31&t,f=tU(fp,{6:1},-1,c=n_(u+1,n.e)+1,1),r=1<=n.e)f[u]=r;else if(u>(i=ew(n)))f[u]^=r;else if(u=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rG(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rN(a=th(rU(s,32),ta(e6(t[f]),o6)),oJ)?(c=iI(a,o,!1),s=n6(a,o)):(c=iI(i=rP(a,1),u=e6(~~r>>>1),!1),s=eY(rU(s=n6(i,u),1),ta(a,oK)),(1&r)!=0&&(rA(c,s)?rA(e1(c,s),o)?(s=eY(s,e1(rU(o,1),c)),c=e1(c,oW)):(s=eY(s,e1(o,c)),c=e1(c,oK)):s=e1(s,c))),n[f]=nB(ta(c,o6));return nB(s)}function io(n,t){var e,r,i,o,u,f,c;if(u=tU(fp,{6:1},-1,f=n_(n.e,t.e),1),i=ew(n),e=r=ew(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=np(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=et(u,im(r))),rt(o,u))}function is(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r4(ul[r]),b=e1(r4(c.f),e6(r)),h=iI(g=r4(c.g),l,!1),tm(a=n6(g,l),oJ)&&(s=tv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?0:nv(e1(rU(nv(a,oJ)?eQ(a):a,1),l),oJ)?-1:1,h=eY(h,e6(it(1&nB(h),(tv(a,oJ)?0:nv(a,oJ)?-1:1)*(5+s),t.c))),tn(ri(nv(h,oJ)?eQ(h):h))>=t.b&&(h=nQ(h,oX),b=e1(b,oK))),c.f=eK(ri(b)),c.e=t.b,c.g=ri(h),c.b=eX(h),c.d=null;return}f=im(r),i=r6((n.d||(n.d=eP(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rt(eH(i[1]._()),f),0!=(e=it(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&rn(i,0,iS(i[0],eZ(e6(e)))),new nL(i[0]).q()>o&&(rn(i,0,ih(i[0],(rW(),uB))),--u)),n.f=eK(u),n.e=o,tO(n,i[0])}}function ia(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u<0&&(e=eQ(e)),c<0&&(r=eQ(r)),eZ(e1(e,r));if(-1==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))h=-c,a=u==c?tJ(t.b,f,n.b,o):t6(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rW(),uA;a=tJ(n.b,o,t.b,f)}else a=t6(n.b,o,t.b,f);return tZ(s=new to(h,a.length,a)),s}function ih(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new ni(ot);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nQ(ta(e6(n.b[0]),o6),ta(e6(t.b[0]),o6)),s!=i&&(a=eQ(a)),eZ(a)):0==(e=c!=r?c>r?1:-1:eI(n.b,t.b,c))?s==i?uM:uS:-1==e?uA:(o=tU(fp,{6:1},-1,u=c-r+1,1),1==r?ii(o,n.b,c,t.b[0]):iL(o,u,n.b,c,t.b,r),tZ(f=new to(s==i?1:-1,u,o)),f)}function ib(n,t,e,r,i){var o,u;if(o=eY(ta(e6(t[0]),o6),ta(e6(r[0]),o6)),n[0]=nB(o),o=rK(o,32),e>=i){for(u=1;u0){if(i0?u=tQ(u,eo(i)):i<0&&(o=tQ(o,eo(-i))),id(o,u,e,r)}function iw(n,t){var e,r,i,o,u,f,c;if(r=ew(t),(i=ew(n))>=t.e)return t;if(u=tU(fp,{6:1},-1,f=t.e,1),rt.ab()?(c=eN(s),o=eN(t),i=tv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?0:nv(e1(rU(nv(c,oJ)?eQ(c):c,1),nv(o,oJ)?eQ(o):o),oJ)?-1:1,i=it(f.gb(0)?1:0,a*(5+i),r)):(i=rt(eH(s._()),t._()),i=it(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return eL(eY(eN(f),e6(i)),e);f=iS(f,eZ(e6(i)))}return new tM(f,e)}function ip(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;if(ix(),(u=nv(n,oJ))&&(n=eQ(n)),tv(n,oJ))switch(t){case 0:return iW;case 1:return iX;case 2:return iY;case 3:return i1;case 4:return i0;case 5:return i2;case 6:return i4;default:return s=new W,t<0?s.b.b+=i6:s.b.b+=i3,b=s.b,l=-2147483648==t?"2147483648":iV+-t,b.b+=l,s.b.b}c=tU(fK,{6:1},-1,19,1),e=18,h=n;do f=h,h=nQ(h,oX),c[--e]=65535&nB(eY(o0,e1(f,iR(h,oX))));while(tm(h,oJ))if(r=e1(e1(e1(o1,e6(e)),e6(t)),oK),0==t)return u&&(c[--e]=45),tP(c,e,18-e);if(t>0&&rN(r,oG)){if(rN(r,oJ)){for(o=17,i=e+nB(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tP(c,e,18-e+1)}for(o=2;nv(e6(o),eY(eQ(r),oK));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tP(c,e,18-e)}return(a=e+1,s=new Z,u&&(s.b.b+=iJ),18-a>=1)?(tE(s,c[e]),s.b.b+=iK,g=s.b,w=tP(c,e+1,18-e-1),g.b+=w):(d=s.b,_=tP(c,e,18-e),d.b+=_),s.b.b+=oc,rA(r,oJ)&&(s.b.b+=iz),v=s.b,m=iV+r3(r),v.b+=m,s.b.b}(r4(n.g),eo(n.f)),n.i):(i=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new W).b,u.b+=i,n.f>0&&r>=-6?r>=0?n7(o,e-eo(n.f),iK):(te(o.b,t-1,t-1,iZ),n7(o,t+1,tP(ua,0,-eo(r)-1))):(e-t>=1&&(te(o.b,t,t,iK),++e),te(o.b,e,e,oc),r>0&&n7(o,++e,iz),n7(o,++e,iV+r3(r4(r)))),n.i=o.b.b,n.i)}function i_(n,t){var e,r,i,o,u,f;if(i=ew(n),o=ew(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==iV;)--s;s1e6)throw new ni("power of ten too big");if(n<=2147483647)return uV[1].db(t).eb(t);for(i=r=uV[1].db(2147483647),e=r4(n-2147483647),t=eo(n%2147483647);rA(e,o3);)i=et(i,r),e=e1(e,o3);for(i=(i=et(i,uV[1].db(t))).eb(2147483647),e=r4(n-2147483647);rA(e,o3);)i=i.eb(2147483647),e=e1(e,o3);return i.eb(t)}function iy(){var n,t;c&&rx("com.iriscouch.gwtapp.client.BigDecimalApp"),nZ(new K),nY(new j),nX(new F),tk(new H),c&&rx("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oT)?oT:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=o$)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oF:-1!=t.indexOf(oD)&&f.documentMode>=9?"ie9":-1!=t.indexOf(oD)&&f.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tF(oF,n)||u.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),c&&rx("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=f.compatMode,n=tK(fI,{6:1},1,[oo]);e>5,this.b=tU(fp,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tZ(this)}}function iS(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ta(e6(n.b[0]),o6),r=ta(e6(t.b[0]),o6),u==c)?(l=nB(s=eY(e,r)),0==(b=nB(rP(s,32)))?new tV(u,l):new to(u,2,tK(fp,{6:1},-1,[l,b]))):eZ(u<0?e1(r,e):e1(e,r));if(u==c)h=u,a=o>=f?t6(n.b,o,t.b,f):t6(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eI(n.b,t.b,o)))return rW(),uA;1==i?(h=u,a=tJ(n.b,o,t.b,f)):(h=c,a=tJ(t.b,f,n.b,o))}return tZ(s=new to(h,a.length,a)),s}function iM(n){var t,e,r,i;if(rF(),null==n)throw new nc("null string");if((t=t5(n)).length<27||t.length>45)throw new nu(ox);for(r=0;rfe.length)throw new q;if(o=null,i=null,67==r[0]?(i=uX,o=u5):68==r[0]?(i=uY,o=u9):70==r[0]?(i=u1,o=u7):72==r[0]?e>6&&(68==r[5]?(i=u0,o=u8):69==r[5]?(i=u2,o=fn):85==r[5]&&(i=u4,o=ft)):85==r[0]&&(80==r[1]?(i=u6,o=fr):78==r[1]&&(i=u3,o=fe)),i&&e==o.length){for(t=1;tl||r+i>s)throw new G;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tT(n,11),o=tT(e,11),nj(n)===nj(e)&&tr;)rn(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eK(e+(o>u?o:u)),s=(i=o-u)>0?(il(),i>19!=0&&(t=eQ(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?es(b):0==h&&0!=l&&0==b?es(l)+22:0!=h&&0==l&&0==b?es(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rK(n,u),c&&eT(f),e&&(o8=ty(0,0,0)),f;n=nT((eM(),uo)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eQ(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rK(g,u),w&&eT(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eT(f),o&&(r?(o8=eQ(n),i&&(o8=e1(o8,(eM(),uf)))):o8=ty(n.l,n.m,n.h)),f}(r?n:ty(n.l,n.m,n.h),t,c,o,i,e):(e&&(o8=o?eQ(n):ty(n.l,n.m,n.h)),ty(0,0,0))}function iE(n){var t=[];for(var e in n){var r=typeof n[e];r!=oQ?t[t.length]=r:n[e]instanceof Array?t[t.length]=oM:u&&u.bigdecimal&&u.bigdecimal.BigInteger&&n[e]instanceof u.bigdecimal.BigInteger?t[t.length]=on:u&&u.bigdecimal&&u.bigdecimal.BigDecimal&&n[e]instanceof u.bigdecimal.BigDecimal?t[t.length]=i9:u&&u.bigdecimal&&u.bigdecimal.RoundingMode&&n[e]instanceof u.bigdecimal.RoundingMode?t[t.length]=ow:u&&u.bigdecimal&&u.bigdecimal.MathContext&&n[e]instanceof u.bigdecimal.MathContext?t[t.length]=ob:t[t.length]=oQ}return t.join(iq)}function iR(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,ty(b,l&=4194303,g&=1048575)}function iO(n,t,e){var r,i,o,u,f,c,s,a;if(a=ri(eY(e6(e.b),oW))+(t.e>0?t.e:nP((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=um.length-1,s=tK(f9,{6:1},17,[(n.d||(n.d=eP(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iN(n,t);if(a>0&&(rn(s,0,et((n.d||(n.d=eP(n.g)),n.d),im(a))),c+=a),u=(s=r6(s[0],(t.d||(t.d=eP(t.g)),t.d)))[0],0!=s[1].r())r=rt(eH(s[1]),(t.d||(t.d=eP(t.g)),t.d)),u=iS(et(u,(rW(),uB)),eZ(e6(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r6(u,um[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?n_(n.b,t.b)+1<54?new ti(n.g-t.g,n.f):new tx(ia((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d)),n.f):e>0?e0?t.e:nP((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rW(),r=uA;else if(0==o)r=ih((n.d||(n.d=eP(n.g)),n.d),(t.d||(t.d=eP(t.g)),t.d));else if(o>0)u=im(o),r=ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),u)),r=et(r,u);else{for(u=im(-o),r=ih(et((n.d||(n.d=eP(n.g)),n.d),u),(t.d||(t.d=eP(t.g)),t.d));!r.gb(0);)if(0==(f=r6(r,um[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nB(m=r2(eY(rU(ta(e6(w[h]),o6),32),ta(e6(w[h-1]),o6)),c)),v=nB(rK(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iR(ta(e6(s),o6),ta(e6(d[o-2]),o6)),y=eY(rU(e6(v),32),ta(e6(w[h-2]),o6)),32>r$(nB(rP(g=eY(ta(e6(v),o6),ta(e6(c),o6)),32)))?_=!0:v=nB(g)}while(rA(tb(l,oV),tb(y,oV)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oJ,u=oJ;f0)rn(b,0,ih((n.d||(n.d=eP(n.g)),n.d),et((t.d||(t.d=eP(t.g)),t.d),im(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,rn(b,0,et(b[0],im(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r6(et((n.d||(n.d=eP(n.g)),n.d),im(u)),(t.d||(t.d=eP(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nL(b[1]).q()+u-t.q())&&(rn(b,1,ih(et(b[1],im(u)),(t.d||(t.d=eP(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new ni(of);if(0==b[0].r())return eU(o);for(w=b[0],g=(c=new nL(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r6(w,um[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new ni(of);return c.f=eK(h),tO(c,w),c}function ij(){var n;for(n=0,ij=g,uJ=tK(fp,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uK=tU(f9,{6:1},17,(uW=tK(fp,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rN(n,oJ)?(e=nQ(n,o4),r=n6(n,o4)):(e=nQ(t=rP(n,1),o2),r=eY(rU(r=n6(t,o2),1),ta(n,oK))),th(rU(r,32),ta(e,o6))}(eY(rU(y,32),ta(e6(M[c]),o6))),M[c]=nB(w),y=e6(nB(rK(w,32)));d=nB(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tP(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tP(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tP(v,e,_-e)}return(S=e+1,m=new Z,h&&(m.b.b+=iJ),_-S>=1)?(tE(m,v[e]),m.b.b+=iK,I=m.b,E=tP(v,e+1,_-e-1),I.b+=E):(R=m.b,O=tP(v,e,_-e),R.b+=O),m.b.b+=oc,o>0&&(m.b.b+=iz),D=m.b,k=iV+o,D.b+=k,m.b.b}c&&c({moduleName:"gwtapp",sessionId:s,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iH,i$,iV="",iq=" ",iG='"',iz="+",iJ="-",iK=".",iW="0",iZ="0.",iX="0.0",iY="0.00",i1="0.000",i0="0.0000",i2="0.00000",i4="0.000000",i3="0E",i6="0E+",i5=":",i9="BigDecimal",i7="BigDecimal MathContext",i8="BigDecimal;",on="BigInteger",ot="BigInteger divide by zero",oe="BigInteger not invertible.",or="BigInteger: modulus not positive",oi="BigInteger;",oo="CSS1Compat",ou="Division by zero",of="Division impossible",oc="E",os='For input string: "',oa="Infinite or NaN",oh="Invalid Operation",ob="MathContext",ol="Negative bit address",og="Rounding necessary",ow="RoundingMode",od="RoundingMode;",op="String",o_="[Lcom.iriscouch.gwtapp.client.",ov="[Ljava.lang.",om="[Ljava.math.",oy="\\.",oC="__gwtex_wrap",oS="anonymous",oM="array",ox="bad string format",oB="bigdecimal",oA="com.google.gwt.core.client.",oN="com.google.gwt.core.client.impl.",oI="com.iriscouch.gwtapp.client.",oE="java.lang.",oR="java.math.",oO="java.util.",oD="msie",ok="null",oL="number",oU="number MathContext",oP="number number",oQ="object",oT="opera",oj="org.timepedia.exporter.client.",oF="safari",oH="string",o$="undefined",oV={l:0,m:0,h:524288},oq={l:0,m:4193280,h:1048575},oG={l:4194298,m:4194303,h:1048575},oz={l:4194303,m:4194303,h:1048575},oJ={l:0,m:0,h:0},oK={l:1,m:0,h:0},oW={l:2,m:0,h:0},oZ={l:5,m:0,h:0},oX={l:10,m:0,h:0},oY={l:11,m:0,h:0},o1={l:18,m:0,h:0},o0={l:48,m:0,h:0},o2={l:877824,m:119,h:0},o4={l:1755648,m:238,h:0},o3={l:4194303,m:511,h:0},o6={l:4194303,m:1023,h:0},o5={l:0,m:1024,h:0};(i$=a.prototype={}).eQ=function(n){return this===n},i$.gC=function(){return fs},i$.hC=function(){return nF(this)},i$.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tU(fK,{6:1},-1,8,1),rv(),e=7,n>=0)for(;n>15;)t[e--]=uO[15&n],n>>=4;else for(;e>0;)t[e--]=uO[15&n],n>>=4;return t[e]=uO[15&n],t3(t,e,8)}(this.hC())},i$.toString=function(){return this.tS()},i$.tM=g,i$.cM={},(i$=h.prototype=new a).gC=function(){return fh},i$.j=function(){return this.f},i$.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},i$.cM={6:1,15:1},i$.f=null,(i$=b.prototype=new h).gC=function(){return fb},i$.cM={6:1,15:1},(i$=nr.prototype=l.prototype=new b).gC=function(){return fl},i$.cM={6:1,12:1,15:1},(i$=n0.prototype=(function(){}).prototype=new l).gC=function(){return fg},i$.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?ok:tt(e)?null==(r=t7(e))?null:r.name:nz(e,1)?op:(nH(e)?e.gC():fw).d,this.b=tt(n=this.c)?null==(i=t7(n))?null:i.message:n+iV,this.d="("+this.e+"): "+this.b+(tt(t=this.c)?function(n){var t=iV;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t7(t)):iV)),this.d},i$.cM={6:1,12:1,15:1},i$.b=null,i$.c=null,i$.d=null,i$.e=null,(i$=w.prototype=new a).gC=function(){return fd};var o9=0,o7=0;(i$=d.prototype=(function(){}).prototype=new w).gC=function(){return fm},i$.b=null,i$.c=null,(i$=_.prototype=v.prototype=new a).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i5+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oS},i$.gC=function(){return fy},i$.o=function(n){return[]},(i$=m.prototype=new v).k=function(){return tg(this.o(td()),this.p())},i$.gC=function(){return fM},i$.o=function(n){return eO(this,n)},i$.p=function(){return 2},(i$=y.prototype=(function(){}).prototype=new m).k=function(){return ea(this)},i$.n=function(n){var t,e;return 0==n.length||(0==(e=e7(n)).indexOf("at ")&&(e=n8(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oS:(-1!=(t=(e=e7(e.substr(0,t-0))).indexOf("."))&&(e=n8(e,t+1)),e.length>0?e:oS)},i$.gC=function(){return fx},i$.o=function(n){return t4(this,n)},i$.p=function(){return 3},(i$=C.prototype=new a).gC=function(){return fB},(i$=S.prototype=(function(){}).prototype=new C).gC=function(){return fA},i$.b=iV,(i$=M.prototype=(function(){}).prototype=new a).gC=function(){return this.aC},i$.aC=null,i$.qI=0;var o8=null,un=null;(i$=x.prototype=(function(){}).prototype=new a).gC=function(){return fE},i$.cM={2:1},(i$=B.prototype=new a).gC=function(){return fO},i$.cM={6:1,10:1};var ut=null;(i$=eu.prototype=ti.prototype=tx.prototype=tN.prototype=X.prototype=e_.prototype=ef.prototype=tA.prototype=tB.prototype=eJ.prototype=n4.prototype=n3.prototype=tr.prototype=tM.prototype=nL.prototype=A.prototype=new B).eQ=function(n){return e2(this,n)},i$.gC=function(){return fD},i$.hC=function(){return rm(this)},i$.q=function(){return rj(this)},i$.r=function(){return ed(this)},i$.tS=function(){return ip(this)},i$.cM={6:1,8:1,10:1,16:1},i$.b=0,i$.c=0,i$.d=null,i$.e=0,i$.f=0,i$.g=0,i$.i=null;var ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_,uv=null,um=null,uy=null;(i$=nU.prototype=nw.prototype=(function(){}).prototype=new A).s=function(n){var t,e,r;if((e=iE(n))==iV)t=0>ed(this)?ep(this):this;else if(e==ob)t=0>(r=t8(this,new iM(n[0].toString()))).r()?ep(r):r;else throw new nr("Unknown call signature for interim = super.abs: "+e);return new nU(t)},i$.t=function(n){var t,e;if((e=iE(n))==i9)t=r0(this,new X(n[0].toString()));else if(e==i7)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t8(r0(n,t),e);if((n.e>0?n.e:nP((n.b-1)*.3010299956639812)+1)0?t.e:nP((t.b-1)*.3010299956639812)+1)<-r-1))return t8(r0(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nP((i.b-1)*.3010299956639812)+1)?t8(r0(n,t),e):(f=(o=i.r())==u.r()?iS(rZ((i.d||(i.d=eP(i.g)),i.d),10),eZ(e6(o))):iS(rZ(f=ia((i.d||(i.d=eP(i.g)),i.d),eZ(e6(o))),10),eZ(e6(9*o))),t8(i=new tx(f,i.f+1),e))}(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.add: "+e);return new nU(t)},i$.u=function(){return~~(nB(en(this,8))<<24)>>24},i$.v=function(n){return ic(this,n)},i$.w=function(n){var t,e,r,i;if((i=iE(n))==i9)e=el(this,new X(n[0].toString()));else if(i==i7)e=eg(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tU(fL,{6:1},3,e.length,0);t129?n*=1/0:n=t9(ip(this)),n},i$.gC=function(){return fk},i$.hC=function(){return rm(this)},i$.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nP((this.b-1)*.3010299956639812)+1)?0:(n=new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))).f*n.b[0]},i$.C=function(){return nB(en(this,32))},i$.D=function(){return nB(en(this,32))},i$.E=function(){return t9(ip(this))},i$.F=function(n){return new nU(ic(this,n)>=0?this:n)},i$.G=function(n){return new nU(0>=ic(this,n)?this:n)},i$.H=function(n){return new nU(rJ(this,this.f+n))},i$.I=function(n){return new nU(rJ(this,this.f-n))},i$.J=function(n){var t,e;if((e=iE(n))==i9)t=rk(this,new X(n[0].toString()));else if(e==i7)t=tl(this,new X(n[0].toString()),new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.multiply: "+e);return new nU(t)},i$.K=function(n){var t,e;if((e=iE(n))==iV)t=ep(this);else if(e==ob)t=ep(t8(this,new iM(n[0].toString())));else throw new nr("Unknown call signature for interim = super.negate: "+e);return new nU(t)},i$.L=function(n){var t,e;if((e=iE(n))==iV)t=this;else if(e==ob)t=t8(this,new iM(n[0].toString()));else throw new nr("Unknown call signature for interim = super.plus: "+e);return new nU(t)},i$.M=function(n){var t,e;if((e=iE(n))==oL)t=rd(this,n[0]);else if(e==oU)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=eo(tn(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rd(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new ni(oh);for(u>0&&(f=new eW(u+i+1,e.c)),r=t8(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tl(r,r,f),(o&c)==c&&(r=tl(r,n,f)),c>>=1;return t<0&&(r=iO(uw,r,f)),is(r,e),r}(this,n[0],new iM(n[1].toString()));else throw new nr("Unknown call signature for interim = super.pow: "+e);return new nU(t)},i$.q=function(){return rj(this)},i$.N=function(n){var t,e;if((e=iE(n))==i9)t=el(this,new X(n[0].toString()))[1];else if(e==i7)t=eg(this,new X(n[0].toString()),new iM(n[1].toString()))[1];else throw new nr("Unknown call signature for interim = super.remainder: "+e);return new nU(t)},i$.O=function(n){return new nU(t8(this,new iM(eh(n.b))))},i$.P=function(){return eo(this.f)},i$.Q=function(n){var t,e;return new nU((t=this,(e=t.f-n,t.b<54)?0==t.g?eU(e):new ti(t.g,eK(e)):new tM((t.d||(t.d=eP(t.g)),t.d),eK(e))))},i$.R=function(n){var t,e;if((e=iE(n))==oL)t=r1(this,n[0],(iA(),u3));else if(e==oP)t=r1(this,n[0],rQ(n[1]));else if("number RoundingMode"==e)t=r1(this,n[0],ts(n[1].toString()));else throw new nr("Unknown call signature for interim = super.setScale: "+e);return new nU(t)},i$.S=function(){return~~(nB(en(this,16))<<16)>>16},i$.r=function(){return ed(this)},i$.T=function(){return new nU(function(n){var t,e,r,i,o;if(t=1,e=um.length-1,r=n.f,0==n.b&&-1!=n.g)return new X(iW);for(n.d||(n.d=eP(n.g)),o=n.d;!o.gb(0);)if(0==(i=r6(o,um[t]))[1].r())r-=t,t0?i.e:nP((i.b-1)*.3010299956639812)+1)0?r.e:nP((r.b-1)*.3010299956639812)+1)?(f=(c=ed(r))!=i.r()?iS(rZ((r.d||(r.d=eP(r.g)),r.d),10),eZ(e6(c))):iS(rZ(f=ia((r.d||(r.d=eP(r.g)),r.d),eZ(e6(c))),10),eZ(e6(9*c))),t8(new tx(f,r.f+1),o)):t8(iD(r,i),o);else throw new nr("Unknown call signature for interim = super.subtract: "+e);return new nU(t)},i$.V=function(){return new n2(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eP(this.g)),this.d):this.f<0?et((this.d||(this.d=eP(this.g)),this.d),im(-this.f)):ih((this.d||(this.d=eP(this.g)),this.d),im(this.f)))},i$.W=function(){return new n2(r5(this))},i$.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eP(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nq(u),n.f>0&&i>=-6)i>=0?n7(c,r-eo(n.f),iK):(te(c.b,t-1,t-1,iZ),n7(c,t+1,tP(ua,0,-eo(i)-1)));else{if(e=r-t,0!=(f=eo(i%3))&&(0==(n.d||(n.d=eP(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n7(c,r++,iW);r-t>=1&&(te(c.b,t,t,iK),++r),0!=i&&(te(c.b,r,r,oc),i>0&&n7(c,++r,iz),n7(c,++r,iV+r3(r4(i))))}return c.b.b}(this)},i$.Y=function(){return function(n){var t,e,r,i,o,u;if(r=iF((n.d||(n.d=eP(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ed(n)?1:0,e=n.f,i=new Z(r.length+1+((o=eo(n.f))<0?-o:o)),1==t&&(i.b.b+=iJ),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iZ;e>ua.length;e-=ua.length)tG(i,ua);n9(i,ua,eo(e)),nE(i,n8(r,t))}else nE(i,(u=eo(e=t-e),r.substr(t,u-t))),i.b.b+=iK,nE(i,n8(r,eo(e)))}else{for(nE(i,n8(r,t));e<-ua.length;e+=ua.length)tG(i,ua);n9(i,ua,eo(-e))}return i.b.b}(this)},i$.tS=function(){return ip(this)},i$.Z=function(){return new nU(new ti(1,this.f))},i$.$=function(){return new n2((this.d||(this.d=eP(this.g)),this.d))},i$.cM={3:1,6:1,8:1,10:1,16:1,24:1},(i$=H.prototype=(function(){}).prototype=new a).gC=function(){return fU};var uC=!1;(i$=ru.prototype=ro.prototype=to.prototype=e9.prototype=tV.prototype=rh.prototype=nG.prototype=iC.prototype=N.prototype=new B)._=function(){return this.f<0?new to(1,this.e,this.b):this},i$.ab=function(){return eq(this)},i$.eQ=function(n){return eV(this,n)},i$.gC=function(){return fP},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.cb=function(){return 0==this.f?this:new to(-this.f,this.e,this.b)},i$.db=function(n){return rL(this,n)},i$.eb=function(n){return tY(this,n)},i$.fb=function(n){return t1(this,n)},i$.r=function(){return this.f},i$.gb=function(n){return rT(this,n)},i$.tS=function(){return iF(this,0)},i$.cM={6:1,8:1,10:1,17:1},i$.b=null,i$.c=-2,i$.d=0,i$.e=0,i$.f=0;var uS,uM,ux,uB,uA,uN=null;(i$=n2.prototype=nD.prototype=nk.prototype=(function(){}).prototype=new N)._=function(){return new n2(this.f<0?new to(1,this.e,this.b):this)},i$.hb=function(n){return new n2(iS(this,n))},i$.ib=function(n){return new n2(0==n.f||0==this.f?(rW(),uA):eV(n,(rW(),uS))?this:eV(this,uS)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=np(n.e,t.e),(e=n_(ew(n),ew(t)))>=i)return rW(),uA;for(r=tU(fp,{6:1},-1,i,1);e0?rz(n,this):this.e>n.e?i_(this,n):i_(n,this))},i$.jb=function(n){return new n2(0==n.f?this:0==this.f?(rW(),uA):eV(this,(rW(),uS))?new n2(r8(n)):eV(n,uS)?uA:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tU(fp,{6:1},-1,n.e,1),r=np(n.e,t.e),e=ew(n);e=n.e)return n;for(o=tU(fp,{6:1},-1,u=np(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=ew(n),o=ew(t),i>=t.e)return n;if(c=n_(n.e,t.e),r=i,o>i){for(f=tU(fp,{6:1},-1,c,1),u=np(n.e,o);r=t.e)return rW(),uA;if(u=tU(fp,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},i$.qb=function(n){return new n2(rR(this,n))},i$.gC=function(){return fQ},i$.bb=function(){return t0(this)},i$.hC=function(){return ek(this)},i$.B=function(){return this.f*this.b[0]},i$.rb=function(n){return function(n,t){var e,r;if(ij(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rT(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uW,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n2(this.f<0?new to(1,this.e,this.b):this),n)},i$.sb=function(){return t9(iF(this,0))},i$.tb=function(n){return new n2(1==rt(this,n)?this:n)},i$.ub=function(n){return new n2(-1==rt(this,n)?this:n)},i$.vb=function(n){return new n2(ee(this,n))},i$.wb=function(n){return new n2(rO(this,n))},i$.xb=function(n,t){return new n2(rG(this,n,t))},i$.yb=function(n){return new n2(et(this,n))},i$.cb=function(){return new n2(0==this.f?this:new to(-this.f,this.e,this.b))},i$.zb=function(){return new n2(function(n){if(n.f<0)throw new ni("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(ij(),o=tU(fp,{6:1},-1,uW.length,1),r=tU(fv,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uW[e];++e);return uK[e]}for(f=new to(1,n.e,tU(fp,{6:1},-1,n.e+1,1)),iB(n.b,0,f.b,0,n.e),rT(n,0)?tW(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iw(this,n):n.f>0?iw(n,this):ew(n)>ew(this)?rX(n,this):rX(this,n))},i$.db=function(n){return new n2(rL(this,n))},i$.Cb=function(n){return new n2(rH(this,n))},i$.Db=function(n){return new n2(rT(this,n)?this:ie(this,n))},i$.eb=function(n){return new n2(tY(this,n))},i$.fb=function(n){return new n2(t1(this,n))},i$.r=function(){return this.f},i$.Eb=function(n){return new n2(ia(this,n))},i$.gb=function(n){return rT(this,n)},i$.Fb=function(n){var t,e;if((e=iE(n))==iV)t=iF(this,0);else if(e==oL)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(ix(),g=n.f,s=n.e,u=n.b,0==g)return iW;if(1==s)return _=ta(e6(u[0]),o6),g<0&&(_=eQ(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return iV+r3(n);if(e=tU(fK,{6:1},-1,65,1),rv(),r=64,i=e6(t),rN(n,oJ)){for(;rN(n,i);)e[r--]=uO[nB(n6(n,i))],n=iI(n,i,!1);e[r]=uO[nB(n)]}else{for(;!rA(n,eQ(i));)e[r--]=uO[nB(eQ(n6(n,i)))],n=iI(n,i,!1);e[r--]=uO[nB(eQ(n))],e[r]=45}return t3(e,r,65)}(_,t);if(10==t||t<2||t>36)return iF(n,0);if(l=tU(fK,{6:1},-1,b=eo(eq(new n2(n.f<0?new to(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(iB(u,0,w=tU(fp,{6:1},-1,s,1),0,s),d=s,r=uP[t],e=uU[t-2];;){h=ii(w,w,d,e),a=i;do l[--i]=em(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=em(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tP(l,i,b-i)}(this,n[0]);else throw new nr("Unknown call signature for result = super.toString: "+e);return t},i$.Gb=function(n){return new n2(0==n.f?this:0==this.f?n:eV(n,(rW(),uS))?new n2(r8(this)):eV(this,uS)?new n2(r8(n)):this.f>0?n.f>0?this.e>n.e?rw(this,n):rw(n,this):iU(this,n):n.f>0?iU(n,this):ew(n)>ew(this)?io(n,this):io(this,n))},i$.cM={4:1,6:1,8:1,10:1,17:1,24:1},(i$=F.prototype=(function(){}).prototype=new a).gC=function(){return fj};var uI=!1;(i$=nm.prototype=ny.prototype=(function(){}).prototype=new a).gC=function(){return fF},i$.Hb=function(){return this.b.b},i$.Ib=function(){return new nn(this.b.c)},i$.hC=function(){return nx(this.b)},i$.tS=function(){return eh(this.b)},i$.cM={24:1},i$.b=null,(i$=j.prototype=(function(){}).prototype=new a).gC=function(){return fH};var uE=!1;(i$=nn.prototype=nC.prototype=(function(){}).prototype=new a).gC=function(){return f$},i$.Jb=function(){return this.b.b},i$.tS=function(){return this.b.b},i$.cM={5:1,24:1},i$.b=null,(i$=K.prototype=(function(){}).prototype=new a).gC=function(){return fq};var uR=!1;(i$=ni.prototype=(function(){}).prototype=new l).gC=function(){return fG},i$.cM={6:1,12:1,15:1},(i$=no.prototype=V.prototype=(function(){}).prototype=new l).gC=function(){return fJ},i$.cM={6:1,12:1,15:1},(i$=I.prototype=(function(){}).prototype=new a).gC=function(){return fW},i$.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?iV:"class ")+this.d},i$.b=null,i$.c=0,i$.d=null,(i$=$.prototype=(function(){}).prototype=new l).gC=function(){return fZ},i$.cM={6:1,12:1,15:1},(i$=E.prototype=new a).eQ=function(n){return this===n},i$.gC=function(){return fa},i$.hC=function(){return nF(this)},i$.tS=function(){return this.b},i$.cM={6:1,8:1,9:1},i$.b=null,i$.c=0,(i$=nu.prototype=q.prototype=R.prototype=new l).gC=function(){return fX},i$.cM={6:1,12:1,15:1},(i$=nf.prototype=G.prototype=O.prototype=new l).gC=function(){return fz},i$.cM={6:1,12:1,15:1},(i$=nc.prototype=z.prototype=(function(){}).prototype=new l).gC=function(){return fY},i$.cM={6:1,12:1,15:1},(i$=nd.prototype=(function(){}).prototype=new R).gC=function(){return f1},i$.cM={6:1,12:1,15:1},(i$=tu.prototype=(function(){}).prototype=new a).gC=function(){return fC},i$.tS=function(){return this.b+iK+this.d+"(Unknown Source"+(this.c>=0?i5+this.c:iV)+")"},i$.cM={6:1,13:1},i$.b=null,i$.c=0,i$.d=null,(i$=String.prototype).eQ=function(n){return tF(this,n)},i$.gC=function(){return fN},i$.hC=function(){var n,t;return nK(),null!=(t=uk[n=i5+this])?t:(null==(t=uD[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;et?n:t}function n_(n,t){return!rA(n,t)}function nv(n){this.b=new iS(n)}function nm(){this.b=(rj(),uj)}function ny(){this.b=(iB(),u2)}function nC(n,e){var r;nh(),r=t.b,n?function(n,t,e,r){var i=n.b[r];if(i)for(var o=0,u=i.length;o=t&&n.splice(0,t),n}function tg(n){return nG(n,15)?n:new n1(n)}function tw(){try{null.a()}catch(n){return n}}function td(n){var t;return(t=new N).d=i$+n,t.c=1,t}function tp(n,t){return nF(n)?n.eQ(t):n===t}function t_(n,t){return n.l==t.l&&n.m==t.m&&n.h==t.h}function tv(n,t){return n.l!=t.l||n.m!=t.m||n.h!=t.h}function tm(n,t,e){return(iH=new M).l=n,iH.m=t,iH.h=e,iH}function ty(n,t){return nT(n)===nT(t)||null!=n&&tp(n,t)}function tC(n,t){throw new nu("Index: "+n+", Size: "+t)}function tS(n,t){if(!n)throw new G;this.f=t,tR(this,n)}function tM(n,t){if(!n)throw new G;this.f=t,tR(this,n)}function tx(n,t,e,r){ez.call(this,n,t,e),ic(this,r)}function tB(n,t){ez.call(this,n,0,n.length),ic(this,t)}function tA(n,t){ez.call(this,t6(n),0,n.length),ic(this,t)}function tN(n){ne.call(this,"String index out of range: "+n)}function tI(n,t){var e,r;return e=n.b,r=String.fromCharCode(t),e.b+=r,n}function tE(n,t){ry(n.b,n.b,n.e,t.b,t.e),tW(n),n.c=-2}function tR(n,t){n.d=t,n.b=t.ab(),n.b<54&&(n.g=rr(eA(t)))}function tO(){tO=l,ue=[],ur=[],function(n,t,e){var r,i=0;for(var o in n)(r=n[o])&&(t[i]=o,e[i]=r,++i)}(new S,ue,ur)}function tD(){uy||(uy=!0,new T,new j,function(){if(nl(ox,i$),o.bigdecimal.BigDecimal)var n=o.bigdecimal.BigDecimal;o.bigdecimal.BigDecimal=ff(function(){1==arguments.length&&null!=arguments[0]&&arguments[0].gC()==fD?this.__gwt_instance=arguments[0]:0==arguments.length&&(this.__gwt_instance=new ng,nb(this.__gwt_instance,this))});var t=o.bigdecimal.BigDecimal.prototype={};if(n)for(p in n)o.bigdecimal.BigDecimal[p]=n[p];o.bigdecimal.BigDecimal.ROUND_CEILING=2,o.bigdecimal.BigDecimal.ROUND_DOWN=1,o.bigdecimal.BigDecimal.ROUND_FLOOR=3,o.bigdecimal.BigDecimal.ROUND_HALF_DOWN=5,o.bigdecimal.BigDecimal.ROUND_HALF_EVEN=6,o.bigdecimal.BigDecimal.ROUND_HALF_UP=4,o.bigdecimal.BigDecimal.ROUND_UNNECESSARY=7,o.bigdecimal.BigDecimal.ROUND_UP=0,o.bigdecimal.BigDecimal.__init__=ff(function(n){var t=function(n){var t,e;if(iU(),(e=iI(n))==i8)t=new nk(new nq(n[0].toString()));else if("BigInteger number"==e)t=new tS(new nq(n[0].toString()),n[1]);else if("BigInteger number MathContext"==e)t=new te(new nq(n[0].toString()),n[1],new iS(n[2].toString()));else if("BigInteger MathContext"==e)t=new n4(new nq(n[0].toString()),new iS(n[1].toString()));else if(e==oS)t=new n2(t6(n[0].toString()));else if("array number number"==e)t=new ez(t6(n[0].toString()),n[1],n[2]);else if("array number number MathContext"==e)t=new tx(t6(n[0].toString()),n[1],n[2],new iS(n[3].toString()));else if("array MathContext"==e)t=new tB(t6(n[0].toString()),new iS(n[1].toString()));else if(e==ok)t=new eu(n[0]);else if(e==oL)t=new ep(n[0],new iS(n[1].toString()));else if(e==oF)t=new Z(n[0].toString());else if("string MathContext"==e)t=new tA(n[0].toString(),new iS(n[1].toString()));else throw new ne("Unknown call signature for obj = new java.math.BigDecimal: "+e);return new nL(t)}(n);return nE(t)}),t.abs_va=ff(function(n){return nE(this.__gwt_instance.s(n))}),t.add_va=ff(function(n){return nE(this.__gwt_instance.t(n))}),t.byteValueExact=ff(function(){return this.__gwt_instance.u()}),t.compareTo=ff(function(n){return this.__gwt_instance.v(n.__gwt_instance)}),t.divide_va=ff(function(n){return nE(this.__gwt_instance.y(n))}),t.divideToIntegralValue_va=ff(function(n){return nE(this.__gwt_instance.x(n))}),t.doubleValue=ff(function(){return this.__gwt_instance.z()}),t.equals=ff(function(n){return this.__gwt_instance.eQ(n)}),t.floatValue=ff(function(){return this.__gwt_instance.A()}),t.hashCode=ff(function(){return this.__gwt_instance.hC()}),t.intValue=ff(function(){return this.__gwt_instance.B()}),t.intValueExact=ff(function(){return this.__gwt_instance.C()}),t.max=ff(function(n){return nE(this.__gwt_instance.F(n.__gwt_instance))}),t.min=ff(function(n){return nE(this.__gwt_instance.G(n.__gwt_instance))}),t.movePointLeft=ff(function(n){return nE(this.__gwt_instance.H(n))}),t.movePointRight=ff(function(n){return nE(this.__gwt_instance.I(n))}),t.multiply_va=ff(function(n){return nE(this.__gwt_instance.J(n))}),t.negate_va=ff(function(n){return nE(this.__gwt_instance.K(n))}),t.plus_va=ff(function(n){return nE(this.__gwt_instance.L(n))}),t.pow_va=ff(function(n){return nE(this.__gwt_instance.M(n))}),t.precision=ff(function(){return this.__gwt_instance.q()}),t.remainder_va=ff(function(n){return nE(this.__gwt_instance.N(n))}),t.round=ff(function(n){return nE(this.__gwt_instance.O(n.__gwt_instance))}),t.scale=ff(function(){return this.__gwt_instance.P()}),t.scaleByPowerOfTen=ff(function(n){return nE(this.__gwt_instance.Q(n))}),t.setScale_va=ff(function(n){return nE(this.__gwt_instance.R(n))}),t.shortValueExact=ff(function(){return this.__gwt_instance.S()}),t.signum=ff(function(){return this.__gwt_instance.r()}),t.stripTrailingZeros=ff(function(){return nE(this.__gwt_instance.T())}),t.subtract_va=ff(function(n){return nE(this.__gwt_instance.U(n))}),t.toBigInteger=ff(function(){return nE(this.__gwt_instance.V())}),t.toBigIntegerExact=ff(function(){return nE(this.__gwt_instance.W())}),t.toEngineeringString=ff(function(){return this.__gwt_instance.X()}),t.toPlainString=ff(function(){return this.__gwt_instance.Y()}),t.toString=ff(function(){return this.__gwt_instance.tS()}),t.ulp=ff(function(){return nE(this.__gwt_instance.Z())}),t.unscaledValue=ff(function(){return nE(this.__gwt_instance.$())}),t.divideAndRemainder_va=ff(function(n){return nR(this.__gwt_instance.w(n))}),t.longValue=ff(function(){return this.__gwt_instance.E()}),t.longValueExact=ff(function(){return this.__gwt_instance.D()}),o.bigdecimal.BigDecimal.valueOf_va=ff(function(n){var t=function(n){var t,e;if(iU(),(e=iI(n))==ok)t=function(n){if(!isFinite(n)||isNaN(n))throw new nw(os);return new Z(i$+n)}(n[0]);else if(e==ok)t=tZ(e3(n[0]));else if(e==oU)t=ek(e3(n[0]),n[1]);else throw new ne("Unknown call signature for bd = java.math.BigDecimal.valueOf: "+e);return new nL(t)}(n);return nE(t)}),o.bigdecimal.BigDecimal.log=ff(function(n){iU(),typeof console!==oH&&console.log&&console.log(n)}),o.bigdecimal.BigDecimal.logObj=ff(function(n){iU(),typeof console!==oH&&console.log&&typeof JSON!==oH&&JSON.stringify&&console.log("object: "+JSON.stringify(n))}),o.bigdecimal.BigDecimal.ONE=ff(function(){var n=(iU(),new nL(ug));return nE(n)}),o.bigdecimal.BigDecimal.TEN=ff(function(){var n=(iU(),new nL(uw));return nE(n)}),o.bigdecimal.BigDecimal.ZERO=ff(function(){var n=(iU(),new nL(ud));return nE(n)}),nC(fD,o.bigdecimal.BigDecimal)}())}function tk(n,t,e){var r;return(r=new N).d=n+t,r.c=4,r.b=e,r}function tL(n,t,e,r,i){var o;return tJ(n,t,e,o=function(n,t){var e=Array(t);if(3==n)for(var r=0;r0)for(var i=[null,0,!1][n],r=0;rn)throw new tN(e)}(n.length,t,r),t4(n,t,r)}function tP(n,t){return ib(),t=n.c.c)throw new z;return t=n.c,r=e=n.b++,i=t.c,(r<0||r>=i)&&tC(r,i),t.b[e]}function tj(n,t){return!!nG(t,1)&&String(n)==t}function tF(){ne.call(this,"Add not supported on this collection")}function tH(){this.b=[],this.f={},this.d=!1,this.c=null,this.e=0}function t$(n,t){rK(),this.f=n,this.e=1,this.b=tJ(fd,{6:1},-1,[t])}function tV(n,t){var e;return e=n.c,n.c=t,!n.d&&(n.d=!0,++n.e),e}function tq(n,t){var e,r;return e=n.b,r=String.fromCharCode.apply(null,t),e.b+=r,n}function tG(n,t,e,r){var i,o;return null==t&&(t=oD),i=n.b,o=t.substr(e,r-e),i.b+=o,n}function tz(n,t,e,r){var i;return ry(i=tL(fd,{6:1},-1,t,1),n,t,e,r),i}function tJ(n,t,e,r){return tO(),function(n,t,e){tO();for(var r=0,i=t.length;r0&&0==n.b[--n.e];);0==n.b[n.e++]&&(n.f=0)}function tZ(n){return rA(n,oz)&&n_(n,oX)?uc[nx(n)]:new eo(n,0)}function tX(n,t){return 0==t||0==n.f?n:t>0?e4(n,t):rX(n,-t)}function tY(n,t){return 0==t||0==n.f?n:t>0?rX(n,t):e4(n,-t)}function t1(n){var t;return 0==n.f?-1:((t=eg(n))<<5)+ec(n.b[t])}function t0(n){var t;return 0!=(t=nx(n))?ec(t):ec(nx(rJ(n,32)))+32}function t2(n,t){var e;return 0==(e=eR(n,t)).length?(new d).o(t):tl(e,1)}function t4(n,t,e){return n=n.slice(t,e),String.fromCharCode.apply(null,n)}function t3(n,t,e,r){var i;return ih(i=tL(fd,{6:1},-1,t+1,1),n,t,e,r),i}function t6(n){var t,e;return t=tL(fJ,{6:1},-1,e=n.length,1),function(n,t,e,r){var i;for(i=0;it.e&&(c=t,t=e,e=c),e.e<63)?(b=t,l=e,(_=(g=b.e)+(w=l.e),v=b.f!=l.f?-1:1,2==_)?(S=nx(y=iE(ts(e3(b.b[0]),o3),ts(e3(l.b[0]),o3))),0==(C=nx(rU(y,32)))?new t$(v,S):new ti(v,2,tJ(fd,{6:1},-1,[S,C]))):(eq(b.b,g,l.b,w,d=tL(fd,{6:1},-1,_,1)),tW(m=new ti(v,_,d)),m)):(f=(-2&t.e)<<4,a=t.fb(f),h=e.fb(f),i=is(t,a.eb(f)),o=is(e,h.eb(f)),s=n(a,h),r=n(i,o),u=(u=iC(iC(u=n(is(a,i),is(o,h)),s),r)).eb(f),iC(iC(s=s.eb(f<<1),u),r))}(n,t))}function et(n,t){var e;if(t.f<=0)throw new nr(oe);return(e=rF(n,t)).f<0?iC(e,t):e}function ee(n){var t;t=new nz,n.d&&n6(t,new nt(n)),function(n,t){var e=n.f;for(var r in e)if(58==r.charCodeAt(0)){var i=new nB(n,r.substring(1));t.Kb(i)}}(n,t),function(n,t){var e=n.b;for(var r in e){var i=parseInt(r,10);if(r==i)for(var o=e[i],u=0,f=o.length;u0?1:0:(n.d||(n.d=eU(n.g)),n.d).r()}function ed(n){return n.b<54?new tr(-n.g,n.f):new tM((n.d||(n.d=eU(n.g)),n.d).cb(),n.f)}function ep(n,t){if(!isFinite(n)||isNaN(n))throw new nw(os);iP(this,n.toPrecision(20)),ic(this,t)}function e_(n,t){return isNaN(n)?isNaN(t)?0:1:isNaN(t)?-1:nt?1:0}function ev(n,t){return t<2||t>36||n<0||n>=t?0:n<10?48+n&65535:97+n-10&65535}function em(n,t){var e,r;return t?((e=t[oy])||(e=new(r=t.gC(),t9(er(n.b,r)))(t),t[oy]=e),e):null}function ey(n){var t,e;return 32==(e=rH(n.h))?32==(t=rH(n.m))?rH(n.l)+32:t+20-10:e-12}function eC(n){return tm(4194303&n,~~n>>22&4194303,n<0?1048575:0)}function eS(){eS=l,ui=tm(4194303,4194303,524287),uo=tm(0,0,524288),uu=e3(1),e3(2),uf=e3(0)}function eM(n,t){ih(n.b,n.b,n.e,t.b,t.e),n.e=nd(np(n.e,t.e)+1,n.b.length),tW(n),n.c=-2}function ex(n,t){var e;e=~~t>>5,n.e+=e+(rH(n.b[n.e-1])-(31&t)>=0?0:1),rC(n.b,n.b,e,31&t),tW(n),n.c=-2}function eB(n,t){var e,r;e=~~t>>5,n.e>>r:0,tW(n))}function eA(n){var t;return t=n.e>1?ta(rL(e3(n.b[1]),32),ts(e3(n.b[0]),o3)):ts(e3(n.b[0]),o3),iE(e3(n.f),t)}function eN(n,t,e){var r;for(r=e-1;r>=0&&n[r]==t[r];--r);return r<0?0:n_(ts(e3(n[r]),o3),ts(e3(t[r]),o3))?-1:1}function eI(n,t,e){var r,i,o;for(i=0,r=0;i>>31;0!=r&&(n[e]=r)}function eE(n,t,e,r){if(iF=t,n)try{ff(im)()}catch(i){n(t)}else ff(im)()}function eR(n,t){var e,r,i;for(e=0,r=(i=t&&t.stack?t.stack.split("\n"):[]).length;e>5==n.e-1&&n.b[n.e-1]==1<<(31&t))for(e=0;r&&e=0&&t=0?new eo(oz,2147483647):new eo(oz,-2147483648)}function eU(n){return(rK(),n<0)?-1!=n?new ro(-1,-n):uC:n<=10?uM[ei(n)]:new ro(1,n)}function eP(n){var t,e,r;return t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,tm(t,e,r)}function eQ(n){var t,e,r;t=~n.l+1&4194303,e=~n.m+(0==t?1:0)&4194303,r=~n.h+(0==t&&0==e?1:0)&1048575,n.l=t,n.m=e,n.h=r}function eT(n){var t,e,r;for(r=0,e=tL(fC,{6:1},13,n.length,0),t=n.length;r=0;--r)if(n[r]!=i[r]){e=0!=n[r]&&rB(ts(e3(n[r]),o3),ts(e3(i[r]),o3));break}}return u=new ti(1,o+1,n),e&&tE(u,t),tW(u),u}(o,e)}function e$(n,t){var e;return n===t||!!nG(t,17)&&(e=tQ(t,17),n.f==e.f&&n.e==e.e&&function(n,t){var e;for(e=n.e-1;e>=0&&n.b[e]==t[e];--e);return e<0}(n,e.b))}function eV(n){var t,e;return 0==n.f?0:(t=n.e<<5,e=n.b[n.e-1],n.f<0&&eg(n)==n.e-1&&(e=~~(e-1)),t-=rH(e))}function eq(n,t,e,r,i){ib(),0!=t&&0!=r&&(1==t?i[r]=rf(i,e,r,n[0]):1==r?i[t]=rf(i,n,t,e[0]):function(n,t,e,r,i){var o,u,f,c;if(nT(n)===nT(t)&&r==i){io(n,r,e);return}for(f=0;f2147483647))return ei(n);throw new nr("Underflow")}function eK(n,t){if(rj(),n<0)throw new no("Digits < 0");if(!t)throw new nf("null RoundingMode");this.b=n,this.c=t}function eW(n){return(rK(),n_(n,oz))?tv(n,oG)?new ri(-1,eP(n)):uC:rB(n,oZ)?new ri(1,n):uM[nx(n)]}function eZ(n){var t;return n_(n,oz)&&(n=tm(4194303&~n.l,4194303&~n.m,1048575&~n.h)),64-(0!=(t=nx(rJ(n,32)))?rH(t):rH(nx(n))+32)}function eX(n,t){var e,r,i;return e=n.l+t.l,r=n.m+t.m+(~~e>>22),i=n.h+t.h+(~~r>>22),tm(4194303&e,4194303&r,1048575&i)}function eY(n,t){var e,r,i;return e=n.l-t.l,r=n.m-t.m+(~~e>>22),i=n.h-t.h+(~~r>>22),tm(4194303&e,4194303&r,1048575&i)}function e1(n,t){var e;if(e=t-1,n.f>0){for(;!n.gb(e);)--e;return t-1-e}for(;n.gb(e);)--e;return t-1-np(e,n.bb())}function e0(n,t){var e;return n===t||!!nG(t,16)&&(e=tQ(t,16)).f==n.f&&(n.b<54?e.g==n.g:n.d.eQ(e.d))}function e2(n,t,e){var r,i,o;for(o=oz,r=t-1;r>=0;--r)i=r0(eX(rL(o,32),ts(e3(n[r]),o3)),e),o=e3(nx(rJ(i,32)));return nx(o)}function e4(n,t){var e,r,i,o;return e=~~t>>5,t&=31,rC(r=tL(fd,{6:1},-1,i=n.e+e+(0==t?0:1),1),n.b,e,t),tW(o=new ti(n.f,i,r)),o}function e3(n){var t,e;return n>-129&&n<128?(t=n+128,null==o8&&(o8=tL(fE,{6:1},2,256,0)),(e=o8[t])||(e=o8[t]=eC(n)),e):eC(n)}function e6(n){var t,e;return(rK(),n>5)+1,1))[t]=1<<(31&n),new ti(1,t+1,e))}function e5(n){rK(),0==n.length?(this.f=0,this.e=1,this.b=tJ(fd,{6:1},-1,[0])):(this.f=1,this.e=n.length,this.b=n,tW(this))}function e9(n){return 0==n.length||n[0]>iV&&n[n.length-1]>iV?n:n.replace(/^(\s*)/,i$).replace(/\s*$/,i$)}function e7(n){return n-=~~n>>1&1431655765,n=(~~(n=(~~n>>2&858993459)+(858993459&n))>>4)+n&252645135,n+=~~n>>8,63&(n+=~~n>>16)}function e8(n,t,e){if(null!=e){var r;if(n.qI>0&&(r=n.qI,!e.cM||!e.cM[r])||n.qI<0&&(e.tM==l||nH(e,1)))throw new $}return n[t]=e}function rn(n,t){return n.f>t.f?1:n.ft.e?n.f:n.e=0;--o)u=eH(u,u,r,i),(e.b[~~o>>5]&1<<(31&o))!=0&&(u=eH(u,t,r,i));return u}(f,r,t,e,o):function(n,t,e,r,i){var o,u,f,c,s,a,h;for(s=tL(f5,{6:1},17,8,0),a=n,e8(s,0,t),h=eH(t,t,r,i),u=1;u<=7;++u)e8(s,u,eH(s[u-1],h,r,i));for(u=e.ab()-1;u>=0;--u)if((e.b[~~u>>5]&1<<(31&u))!=0){for(c=1,o=u,f=u-3>0?u-3:0;f<=u-1;++f)(e.b[~~f>>5]&1<<(31&f))!=0&&(f>1],a,r,i),u=o}else a=eH(a,a,r,i);return a}(f,r,t,e,o),eH(u,(rK(),uS),e,o)}function rs(n,t){var e,r,i,o;for(e=0,r=n.length;e36)throw new nw("Radix out of range");if(0==n.length)throw new nw("Zero length BigInteger");(function(n,t,e){var r,i,o,u,f,c,s,a,h,b,l,g,w,d;for(s=l=t.length,45==t.charCodeAt(0)?(h=-1,b=1,--l):(h=1,b=0),o=~~(l/(u=(iM(),uU)[e])),0!=(d=l%u)&&++o,c=tL(fd,{6:1},-1,o,1),r=uL[e-2],f=0,g=b+(0==d?u:d),w=b;wr)return 1;if(e=0&&n[i]==t[i];--i);return i<0?0:n_(ts(e3(n[i]),o3),ts(e3(t[i]),o3))?-1:1}function rl(n,t){var e,r,i;for(r=tL(fd,{6:1},-1,i=n.e,1),nd(eg(n),eg(t)),e=0;e999999999)throw new nr(oa);return e=n.f*t,0==n.b&&-1!=n.g?eL(e):new tS((n.d||(n.d=eU(n.g)),n.d).db(t),eJ(e))}function rd(n,t){return t<2||t>36?-1:n>=48&&n<48+(t<10?t:10)?n-48:n>=97&&n=65&&n=0;--n)fo[n]=e,e*=.5;for(n=24,t=1;n>=0;--n)fi[n]=t,t*=.5}function r_(){r_=l,uR=tJ(fJ,{6:1},-1,[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122])}function rv(n){var t;return 0!=n.c?n.c:n.b<54?(t=r2(n.g),n.c=nx(ts(t,oG)),n.c=33*n.c+nx(ts(rJ(t,32),oG)),n.c=17*n.c+ei(n.f),n.c):(n.c=17*n.d.hC()+ei(n.f),n.c)}function rm(n,t,e,r){var i,o,u,f,c;return o=(c=n/t)>0?Math.floor(c):Math.ceil(c),u=n%t,f=e_(n*t,0),0!=u&&(i=e_((u<=0?0-u:u)*2,t<=0?0-t:t),o+=r8(1&ei(o),f*(5+i),r)),new tr(o,e)}function ry(n,t,e,r,i){var o,u;for(u=0,o=oz;ue;--i)n[i]|=~~t[i-e-1]>>>o,n[i-1]=t[i-e-1]<>5,n.e-=r,!rO(n.b,n.e,n.b,r,31&t)&&i<0){for(e=0;e>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>t.l:!(0==r||n.h>19,r=~~t.h>>19,0==e?0!=r||n.h>t.h||n.h==t.h&&n.m>t.m||n.h==t.h&&n.m==t.m&&n.l>=t.l:!(0==r||n.h-140737488355328&&n<0x800000000000?0==n?0:((t=n<0)&&(n=-n),e=ei(nU(Math.log(n)/.6931471805599453)),(!t||n!=Math.pow(2,e))&&++e,e):eZ(r2(n))}function rE(n,t){var e,r;return(e=n._(),r=t._(),0==e.r())?r:0==r.r()?e:(1==e.e||2==e.e&&e.b[1]>0)&&(1==r.e||2==r.e&&r.b[1]>0)?eW(rN(eA(e),eA(r))):function(n,t){var e,r,i;e=n.bb(),r=t.bb(),rx(n,e),rx(t,r),1==rn(n,t)&&(i=n,n=t,t=i);do{if(1==t.e||2==t.e&&t.b[1]>0){t=eW(rN(eA(n),eA(t)));break}if(t.e>1.2*n.e)0!=(t=rF(t,n)).r()&&rx(t,t.bb());else do tE(t,n),rx(t,t.bb());while(rn(t,n)>=0)i=t,t=n,n=i}while(0!=i.f)return t.eb(e=r?ex(f,i):(rx(c,r-e0&&ex(f,i-r+e)),e+=i),0!=(i=e1(h,u))&&(ex(h,i),r>=e?ex(c,i):(rx(f,e-r0&&ex(c,i-e+r)),r+=i),s.r()==h.r()?e<=r?(rV(s,h),rV(f,c)):(rV(h,s),rV(c,f)):e<=r?(r$(s,h),r$(f,c)):(r$(h,s),r$(c,f)),0==h.r()||0==s.r())throw new nr(ot);return eO(h,r)&&(f=c,h.r()!=s.r()&&(s=s.cb())),s.gb(u)&&(f=0>f.r()?f.cb():is(t,f)),0>f.r()&&(f=iC(f,t)),f}(n,t);for(o=32*t.e,h=eh(t),u=np((b=eh(n)).e,h.e),c=new ti(1,1,tL(fd,{6:1},-1,u+1,1)),(s=new ti(1,1,tL(fd,{6:1},-1,u+1,1))).b[0]=1,e=0,(r=h.bb())>(i=b.bb())?(rx(h,r),rx(b,i),ex(c,i),e+=r-i):(rx(h,r),rx(b,i),ex(s,r),e+=i-r),c.f=1;b.r()>0;){for(;rn(h,b)>0;)tE(h,b),a=h.bb(),rx(h,a),eM(c,s),ex(s,a),e+=a;for(;0>=rn(h,b)&&(tE(b,h),0!=b.r());)a=b.bb(),rx(b,a),eM(s,c),ex(c,a),e+=a}if(!(1==h.e&&1==h.b[0]))throw new nr(ot);return rn(c,t)>=0&&tE(c,t),c=is(t,c),f=ru(t),e>o&&(c=eH(c,(rK(),uS),t,f),e-=o),c=eH(c,e6(o-e),t,f)}(et(n._(),t),t)).f)throw new nr(ot);return n.f<0?is(t,e):e}function rO(n,t,e,r,i){var o,u,f;for(u=0,o=!0;u>>i|e[u+r+1]<>>i,++u}return o}function rD(n,t){var e;return(e=n.f+t.f,0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)?eL(e):n.b+t.b<54?new tr(n.g*t.g,eJ(e)):new tS(en((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),eJ(e))}function rk(n,t){var e;if(t<0)throw new nr("Negative exponent");if(0==t)return uS;if(1==t||n.eQ(uS)||n.eQ(uB))return n;if(!n.gb(0)){for(e=1;!n.gb(e);)++e;return en(e6(e*t),n.fb(e).db(t))}return function(n,t){var e,r;for(ib(),rK(),r=uS,e=n;t>1;t>>=1)(1&t)!=0&&(r=en(r,e)),e=1==e.e?en(e,e):new e5(io(e.b,e.e,tL(fd,{6:1},-1,e.e<<1,1)));return en(r,e)}(n,t)}function rL(n,t){var e,r,i;return(t&=63)<22?(e=n.l<>22-t,i=n.h<>22-t):t<44?(e=0,r=n.l<>44-t):(e=0,r=0,i=n.l<>>t,i=~~n.m>>t|e<<22-t,r=~~n.l>>t|n.m<<22-t):t<44?(o=0,i=~~e>>>t-22,r=~~n.m>>t-22|n.h<<44-t):(o=0,i=0,r=~~e>>>t-44),tm(4194303&r,4194303&i,1048575&o)}function rP(n){switch(iB(),n){case 2:return uZ;case 1:return uX;case 3:return uY;case 5:return u1;case 6:return u0;case 4:return u2;case 7:return u4;case 0:return u3;default:throw new no("Invalid rounding mode")}}function rQ(n,t){var e,r,i;if(0==t)return(1&n.b[0])!=0;if(t<0)throw new nr(ob);if((i=~~t>>5)>=n.e)return n.f<0;if(e=n.b[i],t=1<<(31&t),n.f<0){if(i<(r=eg(n)))return!1;e=r==i?-e:~e}return(e&t)!=0}function rT(n){var t,e;return n.e>0||(t=1,e=1,n.b<54?(n.b>=1&&(e=n.g),t+=Math.log(e<=0?0-e:e)*Math.LOG10E):(t+=(n.b-1)*.3010299956639812,0!=ia((n.d||(n.d=eU(n.g)),n.d),iv(t)).r()&&++t),n.e=ei(t)),n.e}function rj(){rj=l,uP=new eK(34,(iB(),u0)),uQ=new eK(7,u0),uT=new eK(16,u0),uj=new eK(0,u2),uF=tJ(fJ,{6:1},-1,[112,114,101,99,105,115,105,111,110,61]),uH=tJ(fJ,{6:1},-1,[114,111,117,110,100,105,110,103,77,111,100,101,61])}function rF(n,t){var e,r,i,o;if(0==t.f)throw new nr(on);return((o=n.e)!=(e=t.e)?o>e?1:-1:eN(n.b,t.b,o))==-1?n:(r=tL(fd,{6:1},-1,e,1),1==e?r[0]=e2(n.b,o,t.b[0]):r=ik(null,o-e+1,n.b,o,t.b,e),tW(i=new ti(n.f,e,r)),i)}function rH(n){var t,e,r;return n<0?0:0==n?32:(e=16-(t=~~(r=-(~~n>>16))>>16&16)+(t=~~(r=(n=~~n>>t)-256)>>16&8),n<<=t,e+=t=~~(r=n-4096)>>16&4,n<<=t,e+=t=~~(r=n-16384)>>16&2,n<<=t,e+2-(t=(r=~~n>>14)&~(~~r>>1)))}function r$(n,t){if(0==n.f)ix(t.b,0,n.b,0,t.e);else{if(0==t.f)return;n.f==t.f?ih(n.b,n.b,n.e,t.b,t.e):rb(n.b,t.b,n.e,t.e)>0?ry(n.b,n.b,n.e,t.b,t.e):(r5(n.b,n.b,n.e,t.b,t.e),n.f=-n.f)}n.e=np(n.e,t.e)+1,tW(n),n.c=-2}function rV(n,t){var e;e=rn(n,t),0==n.f?(ix(t.b,0,n.b,0,t.e),n.f=-t.f):n.f!=t.f?(ih(n.b,n.b,n.e,t.b,t.e),n.f=e):rb(n.b,t.b,n.e,t.e)>0?ry(n.b,n.b,n.e,t.b,t.e):(r5(n.b,n.b,n.e,t.b,t.e),n.f=-n.f),n.e=np(n.e,t.e)+1,tW(n),n.c=-2}function rq(n,t,e){var r,i,o,u,f,c,s,a,h,b;if(e.f<=0)throw new nr(oe);return(r=n,(1==e.e&&1==e.b[0])|t.f>0&0==r.f)?uB:0==r.f&&0==t.f?uS:(t.f<0&&(r=rR(n,e),t=t.cb()),i=e.gb(0)?rc(r._(),t,e):(o=r._(),u=t,f=e.bb(),a=rc(o,u,c=e.fb(f)),h=function(n,t,e){var r,i,o,u,f;for(rK(),u=uS,i=eh(t),r=eh(n),n.gb(0)&&eB(i,e-1),eB(r,e),o=i.ab()-1;o>=0;--o)eB(f=eh(u),e),u=en(u,f),(i.b[~~o>>5]&1<<(31&o))!=0&&eB(u=en(u,r),e);return eB(u,e),u}(o,u,f),s=function(n,t){var e,r,i,o;for(e=1,(r=new e5(tL(fd,{6:1},-1,1<>5]&1<<(31&o))!=0&&(r.b[~~e>>5]|=1<<(31&e));return r}(c,f),eB(b=en(is(h,a),s),f),b.f<0&&(b=iC(b,e6(f))),iC(a,en(c,b))),r.f<0&&t.gb(0)&&(i=et(en(is(e,uS),i),e)),i)}function rG(n,t){var e,r,i,o,u,f,c;if(i=eg(n),(r=eg(t))>=n.e)return rK(),uB;for(u=tL(fd,{6:1},-1,f=n.e,1),(e=i>r?i:r)==r&&(u[e]=-t.b[e]&n.b[e],++e),o=nd(t.e,n.e);e=t.e)for(;e0?t:0):t>=0?n.b<54?new tr(n.g,eJ(t)):new tS((n.d||(n.d=eU(n.g)),n.d),eJ(t)):-t>t,o=~~n.m>>t|e<<22-t,i=~~n.l>>t|n.m<<22-t):t<44?(u=r?1048575:0,o=~~e>>t-22,i=~~n.m>>t-22|e<<44-t):(u=r?1048575:0,o=r?4194303:0,i=~~e>>t-44),tm(4194303&i,4194303&o,1048575&u)}function rK(){var n;for(n=0,rK=l,uS=new t$(1,1),ux=new t$(1,10),uB=new t$(0,0),uC=new t$(-1,1),uM=tJ(f5,{6:1},17,[uB,uS,new t$(1,2),new t$(1,3),new t$(1,4),new t$(1,5),new t$(1,6),new t$(1,7),new t$(1,8),new t$(1,9),ux]),uA=tL(f5,{6:1},17,32,0);n=t.e)return t;if(r>=n.e)return n;if(o=tL(fd,{6:1},-1,u=nd(n.e,t.e),1),r==i)o[i]=-(-n.b[i]|-t.b[i]),e=i;else{for(e=r;e>5,t&=31,r>=n.e)return n.f<0?(rK(),uC):(rK(),uB);if(rO(i=tL(fd,{6:1},-1,(o=n.e-r)+1,1),o,n.b,r,t),n.f<0){for(e=0;e0&&n.b[e]<<32-t!=0){for(e=0;e0?r=0)return n;return 0!=e?e>0?rS(n,t,e):rS(t,n,-e):np(n.b,t.b)+1<54?new tr(n.g+t.g,n.f):new tM(iC((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),n.f)}function r0(n,t){var e,r,i,o,u;return(r=ts(e3(t),o3),rA(n,oz))?(o=iN(n,r,!1),u=n3(n,r)):(o=iN(e=rU(n,1),i=e3(~~t>>>1),!1),u=eX(rL(u=n3(e,i),1),ts(n,oJ)),(1&t)!=0&&(rB(o,u)?rB(eY(o,u),r)?(u=eX(u,eY(rL(r,1),o)),o=eY(o,oK)):(u=eX(u,eY(r,o)),o=eY(o,oJ)):u=eY(u,o))),ta(rL(u,32),ts(o,o3))}function r2(n){var t,e,r,i;return isNaN(n)?(eS(),uf):n<-0x8000000000000000?(eS(),uo):n>=0x7fffffffffffffff?(eS(),ui):(r=!1,n<0&&(r=!0,n=-n),e=0,n>=17592186044416&&(e=ei(n/17592186044416),n-=17592186044416*e),t=0,n>=4194304&&(t=ei(n/4194304),n-=4194304*t),i=tm(ei(n),t,e),r&&eQ(i),i)}function r4(n){var t,e,r,i;if(0==n.l&&0==n.m&&0==n.h)return iK;if(524288==n.h&&0==n.m&&0==n.l)return"-9223372036854775808";if(~~n.h>>19!=0)return iz+r4(eP(n));for(e=n,r=i$;!(0==e.l&&0==e.m&&0==e.h);){if(e=iN(e,e3(1e9),!0),t=i$+nx(o7),!(0==e.l&&0==e.m&&0==e.h))for(i=9-t.length;i>0;--i)t=iK+t;r=t+r}return r}function r3(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m,y,C,S,M,x;if(0==(i=t.f))throw new nr(on);return(r=t.e,e=t.b,1==r)?(l=e[0],(S=n.b,M=n.e,x=n.f,1==M)?(d=iN(g=ts(e3(S[0]),o3),w=ts(e3(l),o3),!1),v=n3(g,w),x!=i&&(d=eP(d)),x<0&&(v=eP(v)),tJ(f5,{6:1},17,[eW(d),eW(v)])):(_=tL(fd,{6:1},-1,M,1),m=tJ(fd,{6:1},-1,[ir(_,S,M,l)]),y=new ti(x==i?1:-1,M,_),C=new ti(x,1,m),tW(y),tW(C),tJ(f5,{6:1},17,[y,C]))):(a=n.b,((h=n.e)!=r?h>r?1:-1:eN(a,e,h))<0)?tJ(f5,{6:1},17,[uB,n]):(b=n.f,f=ik(o=tL(fd,{6:1},-1,u=h-r+1,1),u,a,h,e,r),c=new ti(b==i?1:-1,u,o),s=new ti(b,r,f),tW(c),tW(s),tJ(f5,{6:1},17,[c,s]))}function r6(n){var t;if(0==n.f||0==n.b&&-1!=n.g)return n.d||(n.d=eU(n.g)),n.d;if(n.f<0)return en((n.d||(n.d=eU(n.g)),n.d),iv(-n.f));if(n.f>(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)||n.f>(n.d||(n.d=eU(n.g)),n.d).bb()||0!=(t=r3((n.d||(n.d=eU(n.g)),n.d),iv(n.f)))[1].r())throw new nr(ol);return t[0]}function r5(n,t,e,r,i){var o,u;if(o=oz,e36)throw new nw("radix "+t+" out of range");for(e=(r=n.length)>0&&45==n.charCodeAt(0)?1:0;e2147483647)throw new nw(oc+n+iq);return i}function r7(n){var t,e;if(0==n.f)return rK(),uC;if(e$(n,(rK(),uC)))return uB;if(e=tL(fd,{6:1},-1,n.e+1,1),n.f>0){if(-1!=n.b[n.e-1])for(t=0;-1==n.b[t];++t);else{for(t=0;t0?0==t?0:t<0?-1:1:0;break;case 3:r=(0==t?0:t<0?-1:1)<0?0==t?0:t<0?-1:1:0;break;case 4:(t<0?-t:t)>=5&&(r=0==t?0:t<0?-1:1);break;case 5:(t<0?-t:t)>5&&(r=0==t?0:t<0?-1:1);break;case 6:(t<0?-t:t)+n>5&&(r=0==t?0:t<0?-1:1)}return r}function it(n,t){var e,r,i,o,u,f,c,s;if(c=0==n.f?1:n.f,u=tL(fd,{6:1},-1,f=np((o=~~t>>5)+1,n.e)+1,1),e=1<<(31&t),ix(n.b,0,u,0,n.e),n.f<0){if(o>=n.e)u[o]=e;else if(o>(r=eg(n)))u[o]^=e;else if(o=0||0==s.f||1==s.e&&1==s.b[0])if(!(1==(a=rq(s,f,n)).e&&1==a.b[0]||a.eQ(u))){for(i=1;i=0;--f)rA(a=ta(rL(s,32),ts(e3(t[f]),o3)),oz)?(c=iN(a,o,!1),s=n3(a,o)):(c=iN(i=rU(a,1),u=e3(~~r>>>1),!1),s=eX(rL(s=n3(i,u),1),ts(a,oJ)),(1&r)!=0&&(rB(c,s)?rB(eY(c,s),o)?(s=eX(s,eY(rL(o,1),c)),c=eY(c,oK)):(s=eX(s,eY(o,c)),c=eY(c,oJ)):s=eY(s,c))),n[f]=nx(ts(c,o3));return nx(s)}function ii(n,t){var e,r,i,o,u,f,c;if(u=tL(fd,{6:1},-1,f=np(n.e,t.e),1),i=eg(n),e=r=eg(t),i==r)u[r]=-n.b[r]^-t.b[r];else{for(u[r]=-t.b[r],o=nd(t.e,i),++e;et.g?1:0:(r=n.f-t.f,(e=(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)-(t.e>0?t.e:nU((t.b-1)*.3010299956639812)+1))>r+1)?i:e0&&(u=en(u,iv(r))),rn(o,u))}function ic(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g;if(o=t.b,!((n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)-o<0||0==o||(r=n.q()-o)<=0)){if(n.b<54){c=n,l=r2(ub[r]),b=eY(r2(c.f),e3(r)),h=iN(g=r2(c.g),l,!1),tv(a=n3(g,l),oz)&&(s=t_(eY(rL(n_(a,oz)?eP(a):a,1),l),oz)?0:n_(eY(rL(n_(a,oz)?eP(a):a,1),l),oz)?-1:1,h=eX(h,e3(r8(1&nx(h),(t_(a,oz)?0:n_(a,oz)?-1:1)*(5+s),t.c))),n8(rr(n_(h,oz)?eP(h):h))>=t.b&&(h=nP(h,oZ),b=eY(b,oJ))),c.f=eJ(rr(b)),c.e=t.b,c.g=rr(h),c.b=eZ(h),c.d=null;return}f=iv(r),i=r3((n.d||(n.d=eU(n.g)),n.d),f),u=n.f-r,0!=i[1].r()&&(e=rn(eF(i[1]._()),f),0!=(e=r8(i[0].gb(0)?1:0,i[1].r()*(5+e),t.c))&&e8(i,0,iC(i[0],eW(e3(e)))),new nk(i[0]).q()>o&&(e8(i,0,ia(i[0],(rK(),ux))),--u)),n.f=eJ(u),n.e=o,tR(n,i[0])}}function is(n,t){var e,r,i,o,u,f,c,s,a,h;if(u=n.f,0==(c=t.f))return n;if(0==u)return t.cb();if((o=n.e)+(f=t.e)==2)return e=ts(e3(n.b[0]),o3),r=ts(e3(t.b[0]),o3),u<0&&(e=eP(e)),c<0&&(r=eP(r)),eW(eY(e,r));if(-1==(i=o!=f?o>f?1:-1:eN(n.b,t.b,o)))h=-c,a=u==c?tz(t.b,f,n.b,o):t3(t.b,f,n.b,o);else if(h=u,u==c){if(0==i)return rK(),uB;a=tz(n.b,o,t.b,f)}else a=t3(n.b,o,t.b,f);return tW(s=new ti(h,a.length,a)),s}function ia(n,t){var e,r,i,o,u,f,c,s,a;if(0==t.f)throw new nr(on);return(i=t.f,1==t.e&&1==t.b[0])?t.f>0?n:n.cb():(s=n.f,(c=n.e)+(r=t.e)==2)?(a=nP(ts(e3(n.b[0]),o3),ts(e3(t.b[0]),o3)),s!=i&&(a=eP(a)),eW(a)):0==(e=c!=r?c>r?1:-1:eN(n.b,t.b,c))?s==i?uS:uC:-1==e?uB:(o=tL(fd,{6:1},-1,u=c-r+1,1),1==r?ir(o,n.b,c,t.b[0]):ik(o,u,n.b,c,t.b,r),tW(f=new ti(s==i?1:-1,u,o)),f)}function ih(n,t,e,r,i){var o,u;if(o=eX(ts(e3(t[0]),o3),ts(e3(r[0]),o3)),n[0]=nx(o),o=rJ(o,32),e>=i){for(u=1;u0){if(i0?u=tP(u,ei(i)):i<0&&(o=tP(o,ei(-i))),iw(o,u,e,r)}function ig(n,t){var e,r,i,o,u,f,c;if(r=eg(t),(i=eg(n))>=t.e)return t;if(u=tL(fd,{6:1},-1,f=t.e,1),rt.ab()?(c=eA(s),o=eA(t),i=t_(eY(rL(n_(c,oz)?eP(c):c,1),n_(o,oz)?eP(o):o),oz)?0:n_(eY(rL(n_(c,oz)?eP(c):c,1),n_(o,oz)?eP(o):o),oz)?-1:1,i=r8(f.gb(0)?1:0,a*(5+i),r)):(i=rn(eF(s._()),t._()),i=r8(f.gb(0)?1:0,a*(5+i),r)),0!=i){if(54>f.ab())return ek(eX(eA(f),e3(i)),e);f=iC(f,eW(e3(i)))}return new tS(f,e)}function id(n){var t,e,r,i,o,u;return null!=n.i?n.i:n.b<32?(n.i=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v;if(iM(),(u=n_(n,oz))&&(n=eP(n)),t_(n,oz))switch(t){case 0:return iK;case 1:return iZ;case 2:return iX;case 3:return iY;case 4:return i1;case 5:return i0;case 6:return i2;default:return s=new K,t<0?s.b.b+=i3:s.b.b+=i4,b=s.b,b.b+=-2147483648==t?"2147483648":i$+-t,s.b.b}c=tL(fJ,{6:1},-1,19,1),e=18,h=n;do f=h,h=nP(h,oZ),c[--e]=65535&nx(eX(o1,eY(f,iE(h,oZ))));while(tv(h,oz))if(r=eY(eY(eY(oY,e3(e)),e3(t)),oJ),0==t)return u&&(c[--e]=45),tU(c,e,18-e);if(t>0&&rA(r,oq)){if(rA(r,oz)){for(o=17,i=e+nx(r);o>=i;--o)c[o+1]=c[o];return c[++i]=46,u&&(c[--e]=45),tU(c,e,18-e+1)}for(o=2;n_(e3(o),eX(eP(r),oJ));++o)c[--e]=48;return c[--e]=46,c[--e]=48,u&&(c[--e]=45),tU(c,e,18-e)}return(a=e+1,s=new W,u&&(s.b.b+=iz),18-a>=1)?(tI(s,c[e]),s.b.b+=iJ,l=s.b,g=tU(c,e+1,18-e-1),l.b+=g):(w=s.b,d=tU(c,e,18-e),w.b+=d),s.b.b+=of,rB(r,oz)&&(s.b.b+=iG),_=s.b,v=i$+r4(r),_.b+=v,s.b.b}(r2(n.g),ei(n.f)),n.i):(i=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f)?i:(t=0>(n.d||(n.d=eU(n.g)),n.d).r()?2:1,e=i.length,r=-n.f+e-t,u=(o=new K).b,u.b+=i,n.f>0&&r>=-6?r>=0?n9(o,e-ei(n.f),iJ):(tt(o.b,t-1,t-1,iW),n9(o,t+1,tU(us,0,-ei(r)-1))):(e-t>=1&&(tt(o.b,t,t,iJ),++e),tt(o.b,e,e,of),r>0&&n9(o,++e,iG),n9(o,++e,i$+r4(r2(r)))),n.i=o.b.b,n.i)}function ip(n,t){var e,r,i,o,u,f;if(i=eg(n),o=eg(t),i>=t.e)return n;if(r=o>i?o:i,0==(e=o>i?-t.b[r]&~n.b[r]:o0){i[o]=u;break}i[o]=u.substring(0,c.index),u=u.substring(c.index+c[0].length,u.length),r.lastIndex=0,f==u&&(i[o]=u.substring(0,1),u=u.substring(1)),f=u,o++}if(0==e&&n.length>0){for(var s=i.length;s>0&&i[s-1]==i$;)--s;s1e6)throw new nr("power of ten too big");if(n<=2147483647)return u$[1].db(t).eb(t);for(i=r=u$[1].db(2147483647),e=r2(n-2147483647),t=ei(n%2147483647);rB(e,o4);)i=en(i,r),e=eY(e,o4);for(i=(i=en(i,u$[1].db(t))).eb(2147483647),e=r2(n-2147483647);rB(e,o4);)i=i.eb(2147483647),e=eY(e,o4);return i.eb(t)}function im(){var n,t;f&&rM("com.iriscouch.gwtapp.client.BigDecimalApp"),nW(new J),nX(new T),nZ(new j),tD(new F),f&&rM("com.google.gwt.user.client.UserAgentAsserter"),n=-1!=(t=r.userAgent.toLowerCase()).indexOf(oQ)?oQ:-1!=t.indexOf("webkit")||function(){if(-1!=t.indexOf("chromeframe"))return!0;if(typeof e.ActiveXObject!=oH)try{var n=new ActiveXObject("ChromeTab.ChromeFrame");if(n)return n.registerBhoIfNeeded(),!0}catch(r){}return!1}()?oj:-1!=t.indexOf(oO)&&u.documentMode>=9?"ie9":-1!=t.indexOf(oO)&&u.documentMode>=8?"ie8":!function(){var n=/msie ([0-9]+)\.([0-9]+)/.exec(t);if(n&&3==n.length)return 1e3*parseInt(n[1])+parseInt(n[2])>=6e3}()?-1!=t.indexOf("gecko")?"gecko1_8":"unknown":"ie6",tj(oj,n)||o.alert("ERROR: Possible problem with your *.gwt.xml module file.\nThe compile time user.agent value (safari) does not match the runtime user.agent value ("+n+"). Expect more errors.\n"),f&&rM("com.google.gwt.user.client.DocumentModeAsserter"),function(){var n,t,e;for(e=0,t=u.compatMode,n=tJ(fN,{6:1},1,[oi]);e>5,this.b=tL(fd,{6:1},-1,this.e,1);u=2147483648&&(r-=4294967296),r));this.b[this.e-1]>>>=31&-n,tW(this)}}function iC(n,t){var e,r,i,o,u,f,c,s,a,h,b,l;if(u=n.f,c=t.f,0==u)return t;if(0==c)return n;if((o=n.e)+(f=t.e)==2)return(e=ts(e3(n.b[0]),o3),r=ts(e3(t.b[0]),o3),u==c)?(l=nx(s=eX(e,r)),0==(b=nx(rU(s,32)))?new t$(u,l):new ti(u,2,tJ(fd,{6:1},-1,[l,b]))):eW(u<0?eY(r,e):eY(e,r));if(u==c)h=u,a=o>=f?t3(n.b,o,t.b,f):t3(t.b,f,n.b,o);else{if(0==(i=o!=f?o>f?1:-1:eN(n.b,t.b,o)))return rK(),uB;1==i?(h=u,a=tz(n.b,o,t.b,f)):(h=c,a=tz(t.b,f,n.b,o))}return tW(s=new ti(h,a.length,a)),s}function iS(n){var t,e,r,i;if(rj(),null==n)throw new nf("null string");if((t=t6(n)).length<27||t.length>45)throw new no(oM);for(r=0;rft.length)throw new V;if(o=null,i=null,67==r[0]?(i=uZ,o=u6):68==r[0]?(i=uX,o=u5):70==r[0]?(i=uY,o=u9):72==r[0]?e>6&&(68==r[5]?(i=u1,o=u7):69==r[5]?(i=u0,o=u8):85==r[5]&&(i=u2,o=fn)):85==r[0]&&(80==r[1]?(i=u3,o=fe):78==r[1]&&(i=u4,o=ft)),i&&e==o.length){for(t=1;tl||r+i>s)throw new q;if(((1&h.c)==0||(4&h.c)!=0)&&b!=c){if(a=tQ(n,11),o=tQ(e,11),nT(n)===nT(e)&&tr;)e8(o,f,a[--t]);else for(f=r+i;ra.r()&&(s=s.cb()),c=eJ(e+(o>u?o:u)),s=(i=o-u)>0?(ib(),i>19!=0&&(t=eP(t),c=!0),u=((b=(a=t).l)&b-1)!=0||((l=a.m)&l-1)!=0||((h=a.h)&h-1)!=0||0==h&&0==l&&0==b?-1:0==h&&0==l&&0!=b?ec(b):0==h&&0!=l&&0==b?ec(l)+22:0!=h&&0==l&&0==b?ec(h)+44:-1,o=!1,i=!1,r=!1,524288==n.h&&0==n.m&&0==n.l){if(i=!0,o=!0,-1!=u)return f=rJ(n,u),c&&eQ(f),e&&(o7=tm(0,0,0)),f;n=nQ((eS(),ui)),r=!0,c=!c}else~~n.h>>19!=0&&(o=!0,n=eP(n),r=!0,c=!c);return -1!=u?(g=n,w=c,d=o,_=rJ(g,u),w&&eQ(_),e&&(v=g,u<=22?(m=v.l&(1<=0&&((w=(b=n).h-u.h)<0||(l=b.l-u.l,(w+=~~(g=b.m-u.m+(~~l>>22))>>22)<0||(b.l=4194303&l,b.m=4194303&g,b.h=1048575&w,0))||(c<22?f.l|=1<>>1,u.m=~~a>>>1|(1&h)<<21,u.l=~~s>>>1|(1&a)<<21,--c;return e&&eQ(f),o&&(r?(o7=eP(n),i&&(o7=eY(o7,(eS(),uu)))):o7=tm(n.l,n.m,n.h)),f}(r?n:tm(n.l,n.m,n.h),t,c,o,i,e):(e&&(o7=o?eP(n):tm(n.l,n.m,n.h)),tm(0,0,0))}function iI(n){var t=[];for(var e in n){var r=typeof n[e];r!=oP?t[t.length]=r:n[e]instanceof Array?t[t.length]=oS:o&&o.bigdecimal&&o.bigdecimal.BigInteger&&n[e]instanceof o.bigdecimal.BigInteger?t[t.length]=i8:o&&o.bigdecimal&&o.bigdecimal.BigDecimal&&n[e]instanceof o.bigdecimal.BigDecimal?t[t.length]=i5:o&&o.bigdecimal&&o.bigdecimal.RoundingMode&&n[e]instanceof o.bigdecimal.RoundingMode?t[t.length]=og:o&&o.bigdecimal&&o.bigdecimal.MathContext&&n[e]instanceof o.bigdecimal.MathContext?t[t.length]=oh:t[t.length]=oP}return t.join(iV)}function iE(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_,v,m;return e=8191&n.l,r=~~n.l>>13|(15&n.m)<<9,i=~~n.m>>4&8191,o=~~n.m>>17|(255&n.h)<<5,u=~~(1048320&n.h)>>8,f=8191&t.l,c=~~t.l>>13|(15&t.m)<<9,s=~~t.m>>4&8191,a=~~t.m>>17|(255&t.h)<<5,h=~~(1048320&t.h)>>8,w=e*f,d=r*f,_=i*f,v=o*f,m=u*f,0!=c&&(d+=e*c,_+=r*c,v+=i*c,m+=o*c),0!=s&&(_+=e*s,v+=r*s,m+=i*s),0!=a&&(v+=e*a,m+=r*a),0!=h&&(m+=e*h),b=(4194303&w)+((511&d)<<13),l=(~~w>>22)+(~~d>>9)+((262143&_)<<4)+((31&v)<<17),g=(~~_>>18)+(~~v>>5)+((4095&m)<<8),l+=~~b>>22,b&=4194303,g+=~~l>>22,tm(b,l&=4194303,g&=1048575)}function iR(n,t,e){var r,i,o,u,f,c,s,a;if(a=rr(eX(e3(e.b),oK))+(t.e>0?t.e:nU((t.b-1)*.3010299956639812)+1)-(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1),c=i=n.f-t.f,o=1,f=uv.length-1,s=tJ(f5,{6:1},17,[(n.d||(n.d=eU(n.g)),n.d)]),0==e.b||0==n.b&&-1!=n.g||0==t.b&&-1!=t.g)return iA(n,t);if(a>0&&(e8(s,0,en((n.d||(n.d=eU(n.g)),n.d),iv(a))),c+=a),u=(s=r3(s[0],(t.d||(t.d=eU(t.g)),t.d)))[0],0!=s[1].r())r=rn(eF(s[1]),(t.d||(t.d=eU(t.g)),t.d)),u=iC(en(u,(rK(),ux)),eW(e3(s[0].r()*(5+r)))),++c;else for(;!u.gb(0);)if(0==(s=r3(u,uv[o]))[1].r()&&c-o>=i)c-=o,o=0)return n;return 0==e?np(n.b,t.b)+1<54?new tr(n.g-t.g,n.f):new tM(is((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d)),n.f):e>0?e0?t.e:nU((t.b-1)*.3010299956639812)+1)+o>(n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)+1||0==n.b&&-1!=n.g)rK(),r=uB;else if(0==o)r=ia((n.d||(n.d=eU(n.g)),n.d),(t.d||(t.d=eU(t.g)),t.d));else if(o>0)u=iv(o),r=ia((n.d||(n.d=eU(n.g)),n.d),en((t.d||(t.d=eU(t.g)),t.d),u)),r=en(r,u);else{for(u=iv(-o),r=ia(en((n.d||(n.d=eU(n.g)),n.d),u),(t.d||(t.d=eU(t.g)),t.d));!r.gb(0);)if(0==(f=r3(r,uv[e]))[1].r()&&c-e>=o)c-=e,e=0;){if(w[h]==c)s=-1;else if(s=nx(m=r0(eX(rL(ts(e3(w[h]),o3),32),ts(e3(w[h-1]),o3)),c)),v=nx(rJ(m,32)),0!=s){_=!1,++s;do{if(--s,_)break;l=iE(ts(e3(s),o3),ts(e3(d[o-2]),o3)),y=eX(rL(e3(v),32),ts(e3(w[h-2]),o3)),32>rH(nx(rU(g=eX(ts(e3(v),o3),ts(e3(c),o3)),32)))?_=!0:v=nx(g)}while(rB(th(l,o$),th(y,o$)))}if(0!=s&&0!=function(n,t,e,r,i){var o,u,f;for(f=0,o=oz,u=oz;f0)e8(b,0,ia((n.d||(n.d=eU(n.g)),n.d),en((t.d||(t.d=eU(t.g)),t.d),iv(o)))),h=o<(a-l+1>0?a-l+1:0)?o:a-l+1>0?a-l+1:0,e8(b,0,en(b[0],iv(h)));else if(u=-o<(a-i>0?a-i:0)?-o:a-i>0?a-i:0,b=r3(en((n.d||(n.d=eU(n.g)),n.d),iv(u)),(t.d||(t.d=eU(t.g)),t.d)),h+=u,u=-h,0!=b[1].r()&&u>0&&(0==(r=new nk(b[1]).q()+u-t.q())&&(e8(b,1,ia(en(b[1],iv(u)),(t.d||(t.d=eU(t.g)),t.d))),r=(d=b[1].r())<0?-d:d),r>0))throw new nr(ou);if(0==b[0].r())return eL(o);for(w=b[0],g=(c=new nk(b[0])).q(),f=1;!w.gb(0);)if(0==(b=r3(w,uv[f]))[1].r()&&(g-f>=a||h-f>=o))g-=f,h-=f,fa)throw new nr(ou);return c.f=eJ(h),tR(c,w),c}function iT(){var n;for(n=0,iT=l,uz=tJ(fd,{6:1},-1,[0,0,1854,1233,927,747,627,543,480,431,393,361,335,314,295,279,265,253,242,232,223,216,181,169,158,150,145,140,136,132,127,123,119,114,110,105,101,96,92,87,83,78,73,69,64,59,54,49,44,38,32,26,1]),uJ=tL(f5,{6:1},17,(uK=tJ(fd,{6:1},-1,[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021])).length,0);n=0;--c)w=function(n){var t,e,r;return rA(n,oz)?(e=nP(n,o2),r=n3(n,o2)):(e=nP(t=rU(n,1),o0),r=eX(rL(r=n3(t,o0),1),ts(n,oJ))),ta(rL(r,32),ts(e,o3))}(eX(rL(y,32),ts(e3(M[c]),o3))),M[c]=nx(w),y=e3(nx(rJ(w,32)));d=nx(y),g=e;do v[--e]=48+d%10&65535;while(0!=(d=~~(d/10))&&0!=e)for(f=0,r=9-g+e;f0;++f)v[--e]=48;for(a=x-1;0==M[a];--a)if(0==a)break n;x=a+1}for(;48==v[e];)++e}if(h=C<0,o=_-e-t-1,0==t)return h&&(v[--e]=45),tU(v,e,_-e);if(t>0&&o>=-6){if(o>=0){for(s=e+o,a=_-1;a>=s;--a)v[a+1]=v[a];return v[++s]=46,h&&(v[--e]=45),tU(v,e,_-e+1)}for(a=2;a<-o+1;++a)v[--e]=48;return v[--e]=46,v[--e]=48,h&&(v[--e]=45),tU(v,e,_-e)}return(S=e+1,m=new W,h&&(m.b.b+=iz),_-S>=1)?(tI(m,v[e]),m.b.b+=iJ,N=m.b,I=tU(v,e+1,_-e-1),N.b+=I):(E=m.b,R=tU(v,e,_-e),E.b+=R),m.b.b+=of,o>0&&(m.b.b+=iG),O=m.b,O.b+=i$+o,m.b.b}f&&f({moduleName:"gwtapp",sessionId:c,subSystem:"startup",evtGroup:"moduleStartup",millis:new Date().getTime(),type:"moduleEvalStart"});var iF,iH,i$="",iV=" ",iq='"',iG="+",iz="-",iJ=".",iK="0",iW="0.",iZ="0.0",iX="0.00",iY="0.000",i1="0.0000",i0="0.00000",i2="0.000000",i4="0E",i3="0E+",i6=":",i5="BigDecimal",i9="BigDecimal MathContext",i7="BigDecimal;",i8="BigInteger",on="BigInteger divide by zero",ot="BigInteger not invertible.",oe="BigInteger: modulus not positive",or="BigInteger;",oi="CSS1Compat",oo="Division by zero",ou="Division impossible",of="E",oc='For input string: "',os="Infinite or NaN",oa="Invalid Operation",oh="MathContext",ob="Negative bit address",ol="Rounding necessary",og="RoundingMode",ow="RoundingMode;",od="String",op="[Lcom.iriscouch.gwtapp.client.",o_="[Ljava.lang.",ov="[Ljava.math.",om="\\.",oy="__gwtex_wrap",oC="anonymous",oS="array",oM="bad string format",ox="bigdecimal",oB="com.google.gwt.core.client.",oA="com.google.gwt.core.client.impl.",oN="com.iriscouch.gwtapp.client.",oI="java.lang.",oE="java.math.",oR="java.util.",oO="msie",oD="null",ok="number",oL="number MathContext",oU="number number",oP="object",oQ="opera",oT="org.timepedia.exporter.client.",oj="safari",oF="string",oH="undefined",o$={l:0,m:0,h:524288},oV={l:0,m:4193280,h:1048575},oq={l:4194298,m:4194303,h:1048575},oG={l:4194303,m:4194303,h:1048575},oz={l:0,m:0,h:0},oJ={l:1,m:0,h:0},oK={l:2,m:0,h:0},oW={l:5,m:0,h:0},oZ={l:10,m:0,h:0},oX={l:11,m:0,h:0},oY={l:18,m:0,h:0},o1={l:48,m:0,h:0},o0={l:877824,m:119,h:0},o2={l:1755648,m:238,h:0},o4={l:4194303,m:511,h:0},o3={l:4194303,m:1023,h:0},o6={l:0,m:1024,h:0};(iH=s.prototype={}).eQ=function(n){return this===n},iH.gC=function(){return fc},iH.hC=function(){return nj(this)},iH.tS=function(){return this.gC().d+"@"+function(n){var t,e;if(t=tL(fJ,{6:1},-1,8,1),r_(),e=7,n>=0)for(;n>15;)t[e--]=uR[15&n],n>>=4;else for(;e>0;)t[e--]=uR[15&n],n>>=4;return t[e]=uR[15&n],t4(t,e,8)}(this.hC())},iH.toString=function(){return this.tS()},iH.tM=l,iH.cM={},(iH=a.prototype=new s).gC=function(){return fa},iH.j=function(){return this.f},iH.tS=function(){var n,t;return n=this.gC().d,null!=(t=this.j())?n+": "+t:n},iH.cM={6:1,15:1},iH.f=null,(iH=h.prototype=new a).gC=function(){return fh},iH.cM={6:1,15:1},(iH=ne.prototype=b.prototype=new h).gC=function(){return fb},iH.cM={6:1,12:1,15:1},(iH=n1.prototype=(function(){}).prototype=new b).gC=function(){return fl},iH.j=function(){var n,t,e,r,i;return null==this.d&&(this.e=null==(e=this.c)?oD:tn(e)?null==(r=t9(e))?null:r.name:nG(e,1)?od:(nF(e)?e.gC():fg).d,this.b=tn(n=this.c)?null==(i=t9(n))?null:i.message:n+i$,this.d="("+this.e+"): "+this.b+(tn(t=this.c)?function(n){var t=i$;try{for(var e in n)if("name"!=e&&"message"!=e&&"toString"!=e)try{t+="\n "+e+": "+n[e]}catch(r){}}catch(i){}return t}(t9(t)):i$)),this.d},iH.cM={6:1,12:1,15:1},iH.b=null,iH.c=null,iH.d=null,iH.e=null,(iH=g.prototype=new s).gC=function(){return fw};var o5=0,o9=0;(iH=w.prototype=(function(){}).prototype=new g).gC=function(){return fv},iH.b=null,iH.c=null,(iH=d.prototype=_.prototype=new s).k=function(){for(var n={},t=[],e=arguments.callee.caller.caller;e;){var r,i,o=this.n(e.toString());t.push(o);var u=i6+o,f=n[u];if(f){for(r=0,i=f.length;r0?i:oC},iH.gC=function(){return fm},iH.o=function(n){return[]},(iH=v.prototype=new _).k=function(){return tl(this.o(tw()),this.p())},iH.gC=function(){return fS},iH.o=function(n){return eR(this,n)},iH.p=function(){return 2},(iH=m.prototype=(function(){}).prototype=new v).k=function(){return es(this)},iH.n=function(n){var t,e;return 0==n.length||(0==(e=e9(n)).indexOf("at ")&&(e=n7(e,3)),-1==(t=e.indexOf("["))&&(t=e.indexOf("(")),-1==t)?oC:(-1!=(t=(e=e9(e.substr(0,t-0))).indexOf("."))&&(e=n7(e,t+1)),e.length>0?e:oC)},iH.gC=function(){return fM},iH.o=function(n){return t2(this,n)},iH.p=function(){return 3},(iH=y.prototype=new s).gC=function(){return fx},(iH=C.prototype=(function(){}).prototype=new y).gC=function(){return fB},iH.b=i$,(iH=S.prototype=(function(){}).prototype=new s).gC=function(){return this.aC},iH.aC=null,iH.qI=0;var o7=null,o8=null;(iH=M.prototype=(function(){}).prototype=new s).gC=function(){return fI},iH.cM={2:1},(iH=x.prototype=new s).gC=function(){return fR},iH.cM={6:1,10:1};var un=null;(iH=eo.prototype=tr.prototype=tM.prototype=tA.prototype=Z.prototype=ep.prototype=eu.prototype=tB.prototype=tx.prototype=ez.prototype=n2.prototype=n4.prototype=te.prototype=tS.prototype=nk.prototype=B.prototype=new x).eQ=function(n){return e0(this,n)},iH.gC=function(){return fO},iH.hC=function(){return rv(this)},iH.q=function(){return rT(this)},iH.r=function(){return ew(this)},iH.tS=function(){return id(this)},iH.cM={6:1,8:1,10:1,16:1},iH.b=0,iH.c=0,iH.d=null,iH.e=0,iH.f=0,iH.g=0,iH.i=null;var ut,ue,ur,ui,uo,uu,uf,uc,us,ua,uh,ub,ul,ug,uw,ud,up,u_=null,uv=null,um=null;(iH=nL.prototype=ng.prototype=(function(){}).prototype=new B).s=function(n){var t,e,r;if((e=iI(n))==i$)t=0>ew(this)?ed(this):this;else if(e==oh)t=0>(r=t7(this,new iS(n[0].toString()))).r()?ed(r):r;else throw new ne("Unknown call signature for interim = super.abs: "+e);return new nL(t)},iH.t=function(n){var t,e;if((e=iI(n))==i5)t=r1(this,new Z(n[0].toString()));else if(e==i9)t=function(n,t,e){var r,i,o,u,f;if(r=n.f-t.f,0==t.b&&-1!=t.g||0==n.b&&-1!=n.g||0==e.b)return t7(r1(n,t),e);if((n.e>0?n.e:nU((n.b-1)*.3010299956639812)+1)0?t.e:nU((t.b-1)*.3010299956639812)+1)<-r-1))return t7(r1(n,t),e);i=n,u=t}return e.b>=(i.e>0?i.e:nU((i.b-1)*.3010299956639812)+1)?t7(r1(n,t),e):(f=(o=i.r())==u.r()?iC(rW((i.d||(i.d=eU(i.g)),i.d),10),eW(e3(o))):iC(rW(f=is((i.d||(i.d=eU(i.g)),i.d),eW(e3(o))),10),eW(e3(9*o))),t7(i=new tM(f,i.f+1),e))}(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.add: "+e);return new nL(t)},iH.u=function(){return~~(nx(t8(this,8))<<24)>>24},iH.v=function(n){return iu(this,n)},iH.w=function(n){var t,e,r,i;if((i=iI(n))==i5)e=eb(this,new Z(n[0].toString()));else if(i==i9)e=el(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.divideAndRemainder: "+i);for(t=0,r=tL(fk,{6:1},3,e.length,0);t129?n*=1/0:n=t5(id(this)),n},iH.gC=function(){return fD},iH.hC=function(){return rv(this)},iH.B=function(){var n;return this.f<=-32||this.f>(this.e>0?this.e:nU((this.b-1)*.3010299956639812)+1)?0:(n=new n0(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eU(this.g)),this.d):this.f<0?en((this.d||(this.d=eU(this.g)),this.d),iv(-this.f)):ia((this.d||(this.d=eU(this.g)),this.d),iv(this.f)))).f*n.b[0]},iH.C=function(){return nx(t8(this,32))},iH.D=function(){return nx(t8(this,32))},iH.E=function(){return t5(id(this))},iH.F=function(n){return new nL(iu(this,n)>=0?this:n)},iH.G=function(n){return new nL(0>=iu(this,n)?this:n)},iH.H=function(n){return new nL(rz(this,this.f+n))},iH.I=function(n){return new nL(rz(this,this.f-n))},iH.J=function(n){var t,e;if((e=iI(n))==i5)t=rD(this,new Z(n[0].toString()));else if(e==i9)t=tb(this,new Z(n[0].toString()),new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.multiply: "+e);return new nL(t)},iH.K=function(n){var t,e;if((e=iI(n))==i$)t=ed(this);else if(e==oh)t=ed(t7(this,new iS(n[0].toString())));else throw new ne("Unknown call signature for interim = super.negate: "+e);return new nL(t)},iH.L=function(n){var t,e;if((e=iI(n))==i$)t=this;else if(e==oh)t=t7(this,new iS(n[0].toString()));else throw new ne("Unknown call signature for interim = super.plus: "+e);return new nL(t)},iH.M=function(n){var t,e;if((e=iI(n))==ok)t=rw(this,n[0]);else if(e==oL)t=function(n,t,e){var r,i,o,u,f,c;if(o=t<0?-t:t,u=e.b,i=ei(n8(o))+1,f=e,0==t||0==n.b&&-1!=n.g&&t>0)return rw(n,t);if(o>999999999||0==u&&t<0||u>0&&i>u)throw new nr(oa);for(u>0&&(f=new eK(u+i+1,e.c)),r=t7(n,f),c=~~function(n){var t;if(n<0)return -2147483648;if(0==n)return 0;for(t=1073741824;(t&n)==0;t>>=1);return t}(o)>>1;c>0;)r=tb(r,r,f),(o&c)==c&&(r=tb(r,n,f)),c>>=1;return t<0&&(r=iR(ug,r,f)),ic(r,e),r}(this,n[0],new iS(n[1].toString()));else throw new ne("Unknown call signature for interim = super.pow: "+e);return new nL(t)},iH.q=function(){return rT(this)},iH.N=function(n){var t,e;if((e=iI(n))==i5)t=eb(this,new Z(n[0].toString()))[1];else if(e==i9)t=el(this,new Z(n[0].toString()),new iS(n[1].toString()))[1];else throw new ne("Unknown call signature for interim = super.remainder: "+e);return new nL(t)},iH.O=function(n){return new nL(t7(this,new iS(ea(n.b))))},iH.P=function(){return ei(this.f)},iH.Q=function(n){var t,e;return new nL((t=this,(e=t.f-n,t.b<54)?0==t.g?eL(e):new tr(t.g,eJ(e)):new tS((t.d||(t.d=eU(t.g)),t.d),eJ(e))))},iH.R=function(n){var t,e;if((e=iI(n))==ok)t=rY(this,n[0],(iB(),u4));else if(e==oU)t=rY(this,n[0],rP(n[1]));else if("number RoundingMode"==e)t=rY(this,n[0],tc(n[1].toString()));else throw new ne("Unknown call signature for interim = super.setScale: "+e);return new nL(t)},iH.S=function(){return~~(nx(t8(this,16))<<16)>>16},iH.r=function(){return ew(this)},iH.T=function(){return new nL(function(n){var t,e,r,i,o;if(t=1,e=uv.length-1,r=n.f,0==n.b&&-1!=n.g)return new Z(iK);for(n.d||(n.d=eU(n.g)),o=n.d;!o.gb(0);)if(0==(i=r3(o,uv[t]))[1].r())r-=t,t0?i.e:nU((i.b-1)*.3010299956639812)+1)0?r.e:nU((r.b-1)*.3010299956639812)+1)?(f=(c=ew(r))!=i.r()?iC(rW((r.d||(r.d=eU(r.g)),r.d),10),eW(e3(c))):iC(rW(f=is((r.d||(r.d=eU(r.g)),r.d),eW(e3(c))),10),eW(e3(9*c))),t7(new tM(f,r.f+1),o)):t7(iO(r,i),o);else throw new ne("Unknown call signature for interim = super.subtract: "+e);return new nL(t)},iH.V=function(){return new n0(0==this.f||0==this.b&&-1!=this.g?(this.d||(this.d=eU(this.g)),this.d):this.f<0?en((this.d||(this.d=eU(this.g)),this.d),iv(-this.f)):ia((this.d||(this.d=eU(this.g)),this.d),iv(this.f)))},iH.W=function(){return new n0(r6(this))},iH.X=function(){return function(n){var t,e,r,i,o,u,f,c;if(u=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f)return u;if(t=0>(n.d||(n.d=eU(n.g)),n.d).r()?2:1,r=u.length,i=-n.f+r-t,c=new nV(u),n.f>0&&i>=-6)i>=0?n9(c,r-ei(n.f),iJ):(tt(c.b,t-1,t-1,iW),n9(c,t+1,tU(us,0,-ei(i)-1)));else{if(e=r-t,0!=(f=ei(i%3))&&(0==(n.d||(n.d=eU(n.g)),n.d).r()?i+=f=f<0?-f:3-f:(i-=f=f<0?f+3:f,t+=f),e<3))for(o=f-e;o>0;--o)n9(c,r++,iK);r-t>=1&&(tt(c.b,t,t,iJ),++r),0!=i&&(tt(c.b,r,r,of),i>0&&n9(c,++r,iG),n9(c,++r,i$+r4(r2(i))))}return c.b.b}(this)},iH.Y=function(){return function(n){var t,e,r,i,o,u;if(r=ij((n.d||(n.d=eU(n.g)),n.d),0),0==n.f||0==n.b&&-1!=n.g&&n.f<0)return r;if(t=0>ew(n)?1:0,e=n.f,i=new W(r.length+1+((o=ei(n.f))<0?-o:o)),1==t&&(i.b.b+=iz),n.f>0){if((e-=r.length-t)>=0){for(i.b.b+=iW;e>us.length;e-=us.length)tq(i,us);n5(i,us,ei(e)),nI(i,n7(r,t))}else nI(i,(u=ei(e=t-e),r.substr(t,u-t))),i.b.b+=iJ,nI(i,n7(r,ei(e)))}else{for(nI(i,n7(r,t));e<-us.length;e+=us.length)tq(i,us);n5(i,us,ei(-e))}return i.b.b}(this)},iH.tS=function(){return id(this)},iH.Z=function(){return new nL(new tr(1,this.f))},iH.$=function(){return new n0((this.d||(this.d=eU(this.g)),this.d))},iH.cM={3:1,6:1,8:1,10:1,16:1,24:1},(iH=F.prototype=(function(){}).prototype=new s).gC=function(){return fL};var uy=!1;(iH=ro.prototype=ri.prototype=ti.prototype=e5.prototype=t$.prototype=ra.prototype=nq.prototype=iy.prototype=A.prototype=new x)._=function(){return this.f<0?new ti(1,this.e,this.b):this},iH.ab=function(){return eV(this)},iH.eQ=function(n){return e$(this,n)},iH.gC=function(){return fU},iH.bb=function(){return t1(this)},iH.hC=function(){return eD(this)},iH.cb=function(){return 0==this.f?this:new ti(-this.f,this.e,this.b)},iH.db=function(n){return rk(this,n)},iH.eb=function(n){return tX(this,n)},iH.fb=function(n){return tY(this,n)},iH.r=function(){return this.f},iH.gb=function(n){return rQ(this,n)},iH.tS=function(){return ij(this,0)},iH.cM={6:1,8:1,10:1,17:1},iH.b=null,iH.c=-2,iH.d=0,iH.e=0,iH.f=0;var uC,uS,uM,ux,uB,uA=null;(iH=n0.prototype=nO.prototype=nD.prototype=(function(){}).prototype=new A)._=function(){return new n0(this.f<0?new ti(1,this.e,this.b):this)},iH.hb=function(n){return new n0(iC(this,n))},iH.ib=function(n){return new n0(0==n.f||0==this.f?(rK(),uB):e$(n,(rK(),uC))?this:e$(this,uC)?n:this.f>0?n.f>0?function(n,t){var e,r,i,o;if(i=nd(n.e,t.e),(e=np(eg(n),eg(t)))>=i)return rK(),uB;for(r=tL(fd,{6:1},-1,i,1);e0?rG(n,this):this.e>n.e?ip(this,n):ip(n,this))},iH.jb=function(n){return new n0(0==n.f?this:0==this.f?(rK(),uB):e$(this,(rK(),uC))?new n0(r7(n)):e$(n,uC)?uB:this.f>0?n.f>0?function(n,t){var e,r,i,o;for(i=tL(fd,{6:1},-1,n.e,1),r=nd(n.e,t.e),e=eg(n);e=n.e)return n;for(o=tL(fd,{6:1},-1,u=nd(n.e,t.e),1),e=i;e0?function(n,t){var e,r,i,o,u,f,c;if(i=eg(n),o=eg(t),i>=t.e)return n;if(c=np(n.e,t.e),r=i,o>i){for(f=tL(fd,{6:1},-1,c,1),u=nd(n.e,o);r=t.e)return rK(),uB;if(u=tL(fd,{6:1},-1,f=t.e,1),e=i,i0)for(;e34028234663852886e22?1/0:n<-34028234663852886e22?-1/0:n},iH.qb=function(n){return new n0(rE(this,n))},iH.gC=function(){return fP},iH.bb=function(){return t1(this)},iH.hC=function(){return eD(this)},iH.B=function(){return this.f*this.b[0]},iH.rb=function(n){return function(n,t){var e,r;if(iT(),t<=0||1==n.e&&2==n.b[0])return!0;if(!rQ(n,0))return!1;if(1==n.e&&(-1024&n.b[0])==0)return function(n,t){var e,r,i,o;for(r=0,e=n.length-1;r<=e;)if((o=n[i=r+(~~(e-r)>>1)])t))return i;e=i-1}return-r-1}(uK,n.b[0])>=0;for(r=1;r>1)?r:1+(~~(t-1)>>1))}(new n0(this.f<0?new ti(1,this.e,this.b):this),n)},iH.sb=function(){return t5(ij(this,0))},iH.tb=function(n){return new n0(1==rn(this,n)?this:n)},iH.ub=function(n){return new n0(-1==rn(this,n)?this:n)},iH.vb=function(n){return new n0(et(this,n))},iH.wb=function(n){return new n0(rR(this,n))},iH.xb=function(n,t){return new n0(rq(this,n,t))},iH.yb=function(n){return new n0(en(this,n))},iH.cb=function(){return new n0(0==this.f?this:new ti(-this.f,this.e,this.b))},iH.zb=function(){return new n0(function(n){if(n.f<0)throw new nr("start < 0: "+n);return function(n){var t,e,r,i,o,u,f,c;if(iT(),o=tL(fd,{6:1},-1,uK.length,1),r=tL(f_,{6:1},-1,1024,2),1==n.e&&n.b[0]>=0&&n.b[0]=uK[e];++e);return uJ[e]}for(f=new ti(1,n.e,tL(fd,{6:1},-1,n.e+1,1)),ix(n.b,0,f.b,0,n.e),rQ(n,0)?tK(f,2):f.b[0]|=1,i=f.ab(),t=2;i0?n.f>0?this.e>n.e?rl(this,n):rl(n,this):ig(this,n):n.f>0?ig(n,this):eg(n)>eg(this)?rZ(n,this):rZ(this,n))},iH.db=function(n){return new n0(rk(this,n))},iH.Cb=function(n){return new n0(rF(this,n))},iH.Db=function(n){return new n0(rQ(this,n)?this:it(this,n))},iH.eb=function(n){return new n0(tX(this,n))},iH.fb=function(n){return new n0(tY(this,n))},iH.r=function(){return this.f},iH.Eb=function(n){return new n0(is(this,n))},iH.gb=function(n){return rQ(this,n)},iH.Fb=function(n){var t,e;if((e=iI(n))==i$)t=ij(this,0);else if(e==ok)t=function(n,t){var e,r,i,o,u,f,c,s,a,h,b,l,g,w,d,_;if(iM(),g=n.f,s=n.e,u=n.b,0==g)return iK;if(1==s)return _=ts(e3(u[0]),o3),g<0&&(_=eP(_)),function(n,t){var e,r,i;if(10==t||t<2||t>36)return i$+r4(n);if(e=tL(fJ,{6:1},-1,65,1),r_(),r=64,i=e3(t),rA(n,oz)){for(;rA(n,i);)e[r--]=uR[nx(n3(n,i))],n=iN(n,i,!1);e[r]=uR[nx(n)]}else{for(;!rB(n,eP(i));)e[r--]=uR[nx(eP(n3(n,i)))],n=iN(n,i,!1);e[r--]=uR[nx(eP(n))],e[r]=45}return t4(e,r,65)}(_,t);if(10==t||t<2||t>36)return ij(n,0);if(l=tL(fJ,{6:1},-1,b=ei(eV(new n0(n.f<0?new ti(1,n.e,n.b):n))/(Math.log(t)/Math.log(2))+(g<0?1:0))+1,1),i=b,16!=t)for(ix(u,0,w=tL(fd,{6:1},-1,s,1),0,s),d=s,r=uU[t],e=uL[t-2];;){h=ir(w,w,d,e),a=i;do l[--i]=ev(h%t,t);while(0!=(h=~~(h/t))&&0!=i)for(f=0,o=r-a+i;f0;++f)l[--i]=48;for(f=d-1;f>0&&0==w[f];--f);if(1==(d=f+1)&&0==w[0])break}else for(f=0;f0;++c)h=~~u[f]>>(c<<2)&15,l[--i]=ev(h,16);for(;48==l[i];)++i;return -1==g&&(l[--i]=45),tU(l,i,b-i)}(this,n[0]);else throw new ne("Unknown call signature for result = super.toString: "+e);return t},iH.Gb=function(n){return new n0(0==n.f?this:0==this.f?n:e$(n,(rK(),uC))?new n0(r7(this)):e$(this,uC)?new n0(r7(n)):this.f>0?n.f>0?this.e>n.e?rg(this,n):rg(n,this):iL(this,n):n.f>0?iL(n,this):eg(n)>eg(this)?ii(n,this):ii(this,n))},iH.cM={4:1,6:1,8:1,10:1,17:1,24:1},(iH=j.prototype=(function(){}).prototype=new s).gC=function(){return fT};var uN=!1;(iH=nv.prototype=nm.prototype=(function(){}).prototype=new s).gC=function(){return fj},iH.Hb=function(){return this.b.b},iH.Ib=function(){return new Y(this.b.c)},iH.hC=function(){return nM(this.b)},iH.tS=function(){return ea(this.b)},iH.cM={24:1},iH.b=null,(iH=T.prototype=(function(){}).prototype=new s).gC=function(){return fF};var uI=!1;(iH=Y.prototype=ny.prototype=(function(){}).prototype=new s).gC=function(){return fH},iH.Jb=function(){return this.b.b},iH.tS=function(){return this.b.b},iH.cM={5:1,24:1},iH.b=null,(iH=J.prototype=(function(){}).prototype=new s).gC=function(){return fV};var uE=!1;(iH=nr.prototype=(function(){}).prototype=new b).gC=function(){return fq},iH.cM={6:1,12:1,15:1},(iH=ni.prototype=$.prototype=(function(){}).prototype=new b).gC=function(){return fz},iH.cM={6:1,12:1,15:1},(iH=N.prototype=(function(){}).prototype=new s).gC=function(){return fK},iH.tS=function(){return((2&this.c)!=0?"interface ":(1&this.c)!=0?i$:"class ")+this.d},iH.b=null,iH.c=0,iH.d=null,(iH=H.prototype=(function(){}).prototype=new b).gC=function(){return fW},iH.cM={6:1,12:1,15:1},(iH=I.prototype=new s).eQ=function(n){return this===n},iH.gC=function(){return fs},iH.hC=function(){return nj(this)},iH.tS=function(){return this.b},iH.cM={6:1,8:1,9:1},iH.b=null,iH.c=0,(iH=no.prototype=V.prototype=E.prototype=new b).gC=function(){return fZ},iH.cM={6:1,12:1,15:1},(iH=nu.prototype=q.prototype=R.prototype=new b).gC=function(){return fG},iH.cM={6:1,12:1,15:1},(iH=nf.prototype=G.prototype=(function(){}).prototype=new b).gC=function(){return fX},iH.cM={6:1,12:1,15:1},(iH=nw.prototype=(function(){}).prototype=new E).gC=function(){return fY},iH.cM={6:1,12:1,15:1},(iH=to.prototype=(function(){}).prototype=new s).gC=function(){return fy},iH.tS=function(){return this.b+iJ+this.d+"(Unknown Source"+(this.c>=0?i6+this.c:i$)+")"},iH.cM={6:1,13:1},iH.b=null,iH.c=0,iH.d=null,(iH=String.prototype).eQ=function(n){return tj(this,n)},iH.gC=function(){return fA},iH.hC=function(){var n,t;return nJ(),null!=(t=uD[n=i6+this])?t:(null==(t=uO[n])&&(t=function(n){var t,e,r,i;for(t=0,i=(r=n.length)-4,e=0;e Date: Thu, 27 Oct 2022 08:49:27 +0900 Subject: [PATCH 25/27] Fix --- .../src/simplify/expr/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs b/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs index 5482bd38dcf4..5dd1e1ee2cec 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs @@ -258,10 +258,15 @@ impl SimplifyExpr { } if exprs.is_empty() { - *expr = Expr::Seq(SeqExpr { - span: val.span(), - exprs: vec![0.into(), val], - }); + if val.directness_maters() { + *expr = Expr::Seq(SeqExpr { + span: val.span(), + exprs: vec![0.into(), val], + }); + } else { + *expr = *val; + } + return; } From 36a87b4eae7eae697c50d0ea766be3953e56599d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 27 Oct 2022 08:51:56 +0900 Subject: [PATCH 26/27] fixup --- .../src/simplify/expr/mod.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs b/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs index 5dd1e1ee2cec..5482bd38dcf4 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs @@ -258,15 +258,10 @@ impl SimplifyExpr { } if exprs.is_empty() { - if val.directness_maters() { - *expr = Expr::Seq(SeqExpr { - span: val.span(), - exprs: vec![0.into(), val], - }); - } else { - *expr = *val; - } - + *expr = Expr::Seq(SeqExpr { + span: val.span(), + exprs: vec![0.into(), val], + }); return; } From e557b795fccede9980966750d3e21a31b3f28785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 27 Oct 2022 08:54:53 +0900 Subject: [PATCH 27/27] Fix tests --- .../src/simplify/expr/tests.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/swc_ecma_transforms_optimization/src/simplify/expr/tests.rs b/crates/swc_ecma_transforms_optimization/src/simplify/expr/tests.rs index 0fb0fc775ff4..b810fbfbf10d 100644 --- a/crates/swc_ecma_transforms_optimization/src/simplify/expr/tests.rs +++ b/crates/swc_ecma_transforms_optimization/src/simplify/expr/tests.rs @@ -977,15 +977,15 @@ fn test_fold_comparison4() { #[test] fn test_fold_get_elem1() { - fold("x = [,10][0]", "x = void 0"); - fold("x = [10, 20][0]", "x = 10"); - fold("x = [10, 20][1]", "x = 20"); + fold("x = [,10][0]", "x = (0, void 0)"); + fold("x = [10, 20][0]", "x = (0, 10)"); + fold("x = [10, 20][1]", "x = (0, 20)"); // fold("x = [10, 20][-1]", "x = void 0;"); // fold("x = [10, 20][2]", "x = void 0;"); fold("x = [foo(), 0][1]", "x = (foo(), 0);"); - fold("x = [0, foo()][1]", "x = foo()"); + fold("x = [0, foo()][1]", "x = (0, foo())"); // fold("x = [0, foo()][0]", "x = (foo(), 0)"); fold_same("for([1][0] in {});"); } @@ -1008,11 +1008,11 @@ fn test_fold_get_elem2_2() { #[test] fn test_fold_array_lit_spread_get_elem() { - fold("x = [...[0 ]][0]", "x = 0;"); - fold("x = [0, 1, ...[2, 3, 4]][3]", "x = 3;"); - fold("x = [...[0, 1], 2, ...[3, 4]][3]", "x = 3;"); - fold("x = [...[...[0, 1], 2, 3], 4][0]", "x = 0"); - fold("x = [...[...[0, 1], 2, 3], 4][3]", "x = 3"); + fold("x = [...[0 ]][0]", "x = (0, 0);"); + fold("x = [0, 1, ...[2, 3, 4]][3]", "x = (0, 3);"); + fold("x = [...[0, 1], 2, ...[3, 4]][3]", "x = (0, 3);"); + fold("x = [...[...[0, 1], 2, 3], 4][0]", "x = (0, 0)"); + fold("x = [...[...[0, 1], 2, 3], 4][3]", "x = (0, 3)"); // fold("x = [...[]][100]", "x = void 0;"); // fold("x = [...[0]][100]", "x = void 0;"); }