From d891038bdd32c4455ac739ec48be596734af4e27 Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 6 Apr 2022 12:26:41 +0800 Subject: [PATCH 01/27] first --- ...switchBreakStatements_es2015.2.minified.js | 10 +++ .../switchBreakStatements_es5.2.minified.js | 10 +++ .../switchStatements_es2015.2.minified.js | 38 +++++++++ .../switchStatements_es5.2.minified.js | 9 ++ crates/swc_ecma_ast/src/stmt.rs | 10 +++ .../src/compress/optimize/switches.rs | 83 +++++++++++++++++-- crates/swc_ecma_minifier/src/option/mod.rs | 2 +- .../compress/switch/drop_case/output.js | 5 +- .../compress/switch/drop_default_1/output.js | 5 +- .../compress/switch/drop_default_2/output.js | 5 +- .../compress/switch/issue_1690_2/output.js | 3 +- .../compress/switch/issue_1698/output.js | 7 +- .../compress/switch/issue_376/output.js | 5 +- 13 files changed, 160 insertions(+), 32 deletions(-) diff --git a/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js index e69de29bb2d1..b3d67ec92f2f 100644 --- a/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js @@ -0,0 +1,10 @@ +switch(''){ + case 'a': + break; +} +ONE: if (0) break ONE; +TWO: THREE: if (0) break THREE; +FOUR: if (0) { + FIVE: if (0) break FOUR; +} +SEVEN: ; diff --git a/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js index e69de29bb2d1..72b2beeb38ac 100644 --- a/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js @@ -0,0 +1,10 @@ +switch(""){ + case "a": + break; +} +ONE: if (0) break ONE; +TWO: THREE: if (0) break THREE; +FOUR: if (0) { + FIVE: if (0) break FOUR; +} +SEVEN: ; diff --git a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js index 02337d664162..9a2c18c2d4ff 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js @@ -6,3 +6,41 @@ var M; M1.fn = fn; }(M || (M = {})), new class { }(), new Object(); +}(M || (M = {})), x){ + case '': + case 12: + case !0: + case null: + case void 0: + case new Date(12): + case new Object(): + case /[a-z]/: + case []: + case {}: + case { + id: 12 + }: + case [ + 'a' + ]: + case typeof x: + case typeof M: + case M.fn(1): + case (x)=>'' + : + case '': + default: +} +class C { +} +switch(new C()){ + case new class extends C { + }(): + case { + id: 12, + name: '' + }: + case new C(): +} +new Date(12), new Object(), (x)=>'' +; diff --git a/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js index a463698f4be1..68581f001b24 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js @@ -15,3 +15,12 @@ var M, C = function() { return D; }(C); new C(), new Object(); +switch(new C()){ + case new D(): + case { + id: 12, + name: "" + }: + case new C(): +} +new Date(12), new Object(); diff --git a/crates/swc_ecma_ast/src/stmt.rs b/crates/swc_ecma_ast/src/stmt.rs index 071efdd911e4..2e7edc2dc274 100644 --- a/crates/swc_ecma_ast/src/stmt.rs +++ b/crates/swc_ecma_ast/src/stmt.rs @@ -345,6 +345,16 @@ pub struct SwitchCase { pub cons: Vec, } +impl Take for SwitchCase { + fn dummy() -> Self { + Self { + span: DUMMY_SP, + test: None, + cons: Vec::new(), + } + } +} + #[ast_node("CatchClause")] #[derive(Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 8834cade3314..670bd8742248 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -1,6 +1,6 @@ use std::mem::take; -use swc_common::{util::take::Take, EqIgnoreSpan, DUMMY_SP}; +use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::{ident::IdentLike, prepend, ExprExt, StmtExt, Type, Value::Known}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; @@ -329,10 +329,65 @@ where } } - pub(super) fn optimize_switches(&mut self, _s: &mut Stmt) { - if !self.options.switches || self.ctx.stmt_labelled {} + /// Try turn switch into if and remove empty switch + pub(super) fn optimize_switches(&mut self, s: &mut Stmt) { + if !self.options.switches { + return; + } + + if let Stmt::Switch(sw) = s { + match &mut *sw.cases { + [] => { + *s = Stmt::Expr(ExprStmt { + span: sw.span, + expr: sw.discriminant.take(), + }) + } + [case] => { + let mut v = BreakFinder { + found_unlabelled_break_for_stmt: false, + }; + case.visit_with(&mut v); + if v.found_unlabelled_break_for_stmt { + return; + } - // + let case = case.take(); + let discriminant = sw.discriminant.take(); + + if let Some(test) = case.test { + let test = Box::new(Expr::Bin(BinExpr { + left: discriminant, + right: test, + op: op!("==="), + span: DUMMY_SP, + })); + + *s = Stmt::If(IfStmt { + span: sw.span, + test, + cons: Box::new(Stmt::Block(BlockStmt { + span: DUMMY_SP, + stmts: case.cons, + })), + alt: None, + }) + } else { + // is default + let mut stmts = vec![Stmt::Expr(ExprStmt { + span: discriminant.span(), + expr: discriminant, + })]; + stmts.extend(case.cons); + *s = Stmt::Block(BlockStmt { + span: sw.span, + stmts, + }) + } + } + _ => (), + } + } } } @@ -350,22 +405,32 @@ impl Visit for BreakFinder { } } - /// We don't care about breaks in a lop[ + /// We don't care about breaks in a loop fn visit_for_stmt(&mut self, _: &ForStmt) {} - /// We don't care about breaks in a lop[ + /// We don't care about breaks in a loop fn visit_for_in_stmt(&mut self, _: &ForInStmt) {} - /// We don't care about breaks in a lop[ + /// We don't care about breaks in a loop fn visit_for_of_stmt(&mut self, _: &ForOfStmt) {} - /// We don't care about breaks in a lop[ + /// We don't care about breaks in a loop fn visit_do_while_stmt(&mut self, _: &DoWhileStmt) {} - /// We don't care about breaks in a lop[ + /// We don't care about breaks in a loop fn visit_while_stmt(&mut self, _: &WhileStmt) {} fn visit_function(&mut self, _: &Function) {} fn visit_arrow_expr(&mut self, _: &ArrowExpr) {} + + fn visit_class(&mut self, _: &Class) {} +} + +fn ends_with_break(stmts: &[Stmt]) -> bool { + if let Some(last) = stmts.last() { + last.is_break_stmt() + } else { + false + } } diff --git a/crates/swc_ecma_minifier/src/option/mod.rs b/crates/swc_ecma_minifier/src/option/mod.rs index 9d4ed91f51db..9859a9af318b 100644 --- a/crates/swc_ecma_minifier/src/option/mod.rs +++ b/crates/swc_ecma_minifier/src/option/mod.rs @@ -254,7 +254,7 @@ pub struct CompressOptions { #[serde(alias = "side_effects")] pub side_effects: bool, - #[serde(default)] + #[serde(default = "true_by_default")] #[serde(alias = "switches")] pub switches: bool, diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case/output.js index 27ad6466c347..a3a043e13da0 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case/output.js @@ -1,4 +1 @@ -switch (foo) { - case "bar": - baz(); -} +if ("bar" === foo) baz(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_default_1/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_default_1/output.js index 27ad6466c347..a3a043e13da0 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_default_1/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_default_1/output.js @@ -1,4 +1 @@ -switch (foo) { - case "bar": - baz(); -} +if ("bar" === foo) baz(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_default_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_default_2/output.js index 27ad6466c347..a3a043e13da0 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_default_2/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_default_2/output.js @@ -1,4 +1 @@ -switch (foo) { - case "bar": - baz(); -} +if ("bar" === foo) baz(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1690_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1690_2/output.js index 2d24c7530c8c..5669eec47340 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1690_2/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1690_2/output.js @@ -1,2 +1 @@ -switch (console.log("PASS")) { -} +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1698/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1698/output.js index ccb7fc9aa059..6d0620725948 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1698/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1698/output.js @@ -1,6 +1,5 @@ var a = 1; -!(function () { - switch (a++) { - } -})(); +!function() { + a++; +}(); console.log(a); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_376/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_376/output.js index 9e2d9a5c3d7c..20deee1d37a9 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_376/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_376/output.js @@ -1,4 +1 @@ -switch (true) { - case boolCondition: - console.log(1); -} +if (true === boolCondition) console.log(1); From f28b389adef4537ced1c76aad2efec3327f2648c Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 6 Apr 2022 13:51:52 +0800 Subject: [PATCH 02/27] options --- ...DestructuredVariables_es2015.2.minified.js | 1 - ...entDestructuredVariables_es5.2.minified.js | 1 - .../parserRealSource6_es2015.2.minified.js | 1 - .../parserRealSource6_es5.2.minified.js | 1 - .../parserindenter_es2015.2.minified.js | 1 - .../parserindenter_es5.2.minified.js | 1 - ...eralMatchedInSwitch01_es2015.2.minified.js | 1 - ...LiteralMatchedInSwitch01_es5.2.minified.js | 1 - ...ithSwitchStatements01_es2015.2.minified.js | 7 +++++ ...lsWithSwitchStatements01_es5.2.minified.js | 7 +++++ ...ithSwitchStatements03_es2015.2.minified.js | 11 ++++++++ ...lsWithSwitchStatements03_es5.2.minified.js | 11 ++++++++ ...ithSwitchStatements04_es2015.2.minified.js | 8 ++++++ ...lsWithSwitchStatements04_es5.2.minified.js | 8 ++++++ ...switchBreakStatements_es2015.2.minified.js | 4 --- .../switchBreakStatements_es5.2.minified.js | 4 --- .../switchStatements_es2015.2.minified.js | 13 +--------- .../switchStatements_es5.2.minified.js | 26 +++++++++++++++++++ ...ingInSwitchAndCaseES6_es2015.2.minified.js | 1 + ...StringInSwitchAndCaseES6_es5.2.minified.js | 7 +---- ...StringInSwitchAndCase_es2015.2.minified.js | 1 + ...ateStringInSwitchAndCase_es5.2.minified.js | 7 +---- ...fFormFunctionEquality_es2015.2.minified.js | 1 + ...rdOfFormFunctionEquality_es5.2.minified.js | 1 + crates/swc_ecma_minifier/src/option/terser.rs | 1 + 25 files changed, 86 insertions(+), 40 deletions(-) diff --git a/crates/swc/tests/tsc-references/dependentDestructuredVariables_es2015.2.minified.js b/crates/swc/tests/tsc-references/dependentDestructuredVariables_es2015.2.minified.js index 630ce9adb51f..4ef56ceb0118 100644 --- a/crates/swc/tests/tsc-references/dependentDestructuredVariables_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/dependentDestructuredVariables_es2015.2.minified.js @@ -11,7 +11,6 @@ const reducer = (op, args)=>{ break; case "concat": console.log(args.firstArr.concat(args.secondArr)); - break; } }; reducer("add", { diff --git a/crates/swc/tests/tsc-references/dependentDestructuredVariables_es5.2.minified.js b/crates/swc/tests/tsc-references/dependentDestructuredVariables_es5.2.minified.js index a774abd671ed..c9883e6cceff 100644 --- a/crates/swc/tests/tsc-references/dependentDestructuredVariables_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/dependentDestructuredVariables_es5.2.minified.js @@ -12,7 +12,6 @@ var reducer = function(op, args) { break; case "concat": console.log(args.firstArr.concat(args.secondArr)); - break; } }; reducer("add", { diff --git a/crates/swc/tests/tsc-references/parserRealSource6_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource6_es2015.2.minified.js index 2982eec3655f..e064a1dd1a79 100644 --- a/crates/swc/tests/tsc-references/parserRealSource6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource6_es2015.2.minified.js @@ -77,7 +77,6 @@ var TypeScript; context.skipNextFuncDeclForClass ? context.skipNextFuncDeclForClass = !1 : (context.scopeGetter = function() { return funcDecl.isConstructor && hasFlag(funcDecl.fncFlags, FncFlags.ClassMethod) && ast.type && ast.type.enclosingType ? ast.type.enclosingType.constructorScope : funcDecl.scopeType ? funcDecl.scopeType.containedScope : funcDecl.type ? funcDecl.type.containedScope : null; }, context.scopeStartAST = ast); - break; } walker.options.goChildren = !0; } else walker.options.goChildren = !1; diff --git a/crates/swc/tests/tsc-references/parserRealSource6_es5.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource6_es5.2.minified.js index 1e503a595d6c..797d54b5ca1c 100644 --- a/crates/swc/tests/tsc-references/parserRealSource6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource6_es5.2.minified.js @@ -42,7 +42,6 @@ import * as swcHelpers from "@swc/helpers"; context.skipNextFuncDeclForClass ? context.skipNextFuncDeclForClass = !1 : (context.scopeGetter = function() { return funcDecl.isConstructor && hasFlag(funcDecl.fncFlags, FncFlags.ClassMethod) && ast.type && ast.type.enclosingType ? ast.type.enclosingType.constructorScope : funcDecl.scopeType ? funcDecl.scopeType.containedScope : funcDecl.type ? funcDecl.type.containedScope : null; }, context.scopeStartAST = ast); - break; } walker.options.goChildren = !0; } else walker.options.goChildren = !1; diff --git a/crates/swc/tests/tsc-references/parserindenter_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserindenter_es2015.2.minified.js index 7e4be735e862..4382e8b8ded4 100644 --- a/crates/swc/tests/tsc-references/parserindenter_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserindenter_es2015.2.minified.js @@ -246,7 +246,6 @@ var Formatting; break; case AuthorTokenKind.atkLBrack: updateStartOffset = node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkArray; - break; } updateStartOffset && ParseNodeExtensions.SetNodeSpan(node, token.Span.startPosition(), node.AuthorNode.Details.EndOffset); } diff --git a/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js b/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js index d3d1fbbc9883..d202a95c2319 100644 --- a/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js @@ -219,7 +219,6 @@ import * as swcHelpers from "@swc/helpers"; break; case AuthorTokenKind.atkLBrack: updateStartOffset = node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkArray; - break; } updateStartOffset && ParseNodeExtensions.SetNodeSpan(node, token.Span.startPosition(), node.AuthorNode.Details.EndOffset); } diff --git a/crates/swc/tests/tsc-references/stringLiteralMatchedInSwitch01_es2015.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralMatchedInSwitch01_es2015.2.minified.js index 0a458489f2d9..292febe1edee 100644 --- a/crates/swc/tests/tsc-references/stringLiteralMatchedInSwitch01_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralMatchedInSwitch01_es2015.2.minified.js @@ -5,5 +5,4 @@ switch(foo){ break; default: foo = foo[0]; - break; } diff --git a/crates/swc/tests/tsc-references/stringLiteralMatchedInSwitch01_es5.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralMatchedInSwitch01_es5.2.minified.js index 0a458489f2d9..292febe1edee 100644 --- a/crates/swc/tests/tsc-references/stringLiteralMatchedInSwitch01_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralMatchedInSwitch01_es5.2.minified.js @@ -5,5 +5,4 @@ switch(foo){ break; default: foo = foo[0]; - break; } diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es2015.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es2015.2.minified.js index e69de29bb2d1..9025d4c9edfd 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es2015.2.minified.js @@ -0,0 +1,7 @@ +let x, y; +switch(x){ + case "foo": + break; + case "bar": + case y: +} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es5.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es5.2.minified.js index e69de29bb2d1..640327e9a3c1 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es5.2.minified.js @@ -0,0 +1,7 @@ +var x, y; +switch(x){ + case "foo": + break; + case "bar": + case y: +} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es2015.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es2015.2.minified.js index e69de29bb2d1..1d2ee654888a 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es2015.2.minified.js @@ -0,0 +1,11 @@ +let x, z; +switch(x){ + case randBool() ? "foo" : "baz": + case randBool(), "bar": + case "bar": + case "baz": + case "foo": + break; + case "bar": + case z || "baz": +} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es5.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es5.2.minified.js index e69de29bb2d1..6013014f3474 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es5.2.minified.js @@ -0,0 +1,11 @@ +var x, z; +switch(x){ + case randBool() ? "foo" : "baz": + case randBool(), "bar": + case "bar": + case "baz": + case "foo": + break; + case "bar": + case z || "baz": +} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es2015.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es2015.2.minified.js index e69de29bb2d1..068d5a3ef978 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es2015.2.minified.js @@ -0,0 +1,8 @@ +let x, y; +switch(y){ + case x: + case "foo": + case "baz": + break; + case x: +} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es5.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es5.2.minified.js index e69de29bb2d1..4f4db3f8f566 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es5.2.minified.js @@ -0,0 +1,8 @@ +var x, y; +switch(y){ + case x: + case "foo": + case "baz": + break; + case x: +} diff --git a/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js index b3d67ec92f2f..110e6d502e11 100644 --- a/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js @@ -1,7 +1,3 @@ -switch(''){ - case 'a': - break; -} ONE: if (0) break ONE; TWO: THREE: if (0) break THREE; FOUR: if (0) { diff --git a/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js index 72b2beeb38ac..110e6d502e11 100644 --- a/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js @@ -1,7 +1,3 @@ -switch(""){ - case "a": - break; -} ONE: if (0) break ONE; TWO: THREE: if (0) break THREE; FOUR: if (0) { diff --git a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js index 9a2c18c2d4ff..6bed8df910c0 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js @@ -28,19 +28,8 @@ var M; case M.fn(1): case (x)=>'' : - case '': - default: } class C { } -switch(new C()){ - case new class extends C { - }(): - case { - id: 12, - name: '' - }: - case new C(): -} -new Date(12), new Object(), (x)=>'' +new C(), new C(), new Date(12), new Object(), (x)=>'' ; diff --git a/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js index 68581f001b24..290ef64b756b 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js @@ -3,6 +3,31 @@ import * as swcHelpers from "@swc/helpers"; return ""; }; var M, C = function() { +}, x){ + case "": + case 12: + case !0: + case null: + case void 0: + case new Date(12): + case new Object(): + case /[a-z]/: + case []: + case {}: + case { + id: 12 + }: + case [ + "a" + ]: + case void 0 === x ? "undefined" : swcHelpers.typeOf(x): + case void 0 === M ? "undefined" : swcHelpers.typeOf(M): + case M.fn(1): + case function(x) { + return ""; + }: +} +var M, x, C = function() { "use strict"; swcHelpers.classCallCheck(this, C); }, D = function(C1) { @@ -24,3 +49,4 @@ switch(new C()){ case new C(): } new Date(12), new Object(); +new C(), new C(), new Date(12), new Object(); diff --git a/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es2015.2.minified.js b/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es2015.2.minified.js index e69de29bb2d1..d67c8c8a7dbe 100644 --- a/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es2015.2.minified.js @@ -0,0 +1 @@ +"def1def"; diff --git a/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es5.2.minified.js index 1d69cccfe3d2..94b1286af1d2 100644 --- a/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es5.2.minified.js @@ -1,6 +1 @@ -switch("abc".concat(0, "abc")){ - case "abc": - case "123": - case "abc".concat(0, "abc"): - "def".concat(1, "def"); -} +"abc".concat(0, "abc"), "abc".concat(0, "abc"), "def".concat(1, "def"); diff --git a/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es2015.2.minified.js b/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es2015.2.minified.js index e69de29bb2d1..d67c8c8a7dbe 100644 --- a/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es2015.2.minified.js @@ -0,0 +1 @@ +"def1def"; diff --git a/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es5.2.minified.js index 1d69cccfe3d2..94b1286af1d2 100644 --- a/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es5.2.minified.js @@ -1,6 +1 @@ -switch("abc".concat(0, "abc")){ - case "abc": - case "123": - case "abc".concat(0, "abc"): - "def".concat(1, "def"); -} +"abc".concat(0, "abc"), "abc".concat(0, "abc"), "def".concat(1, "def"); diff --git a/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es2015.2.minified.js index 3d01e9dbaf6d..39774c3fd3ea 100644 --- a/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es2015.2.minified.js @@ -1 +1,2 @@ isString1(0, ""), isString1(0, ""), isString2(""); +isString1(0, "") === isString2(""), isString1(0, "") === isString2(""); diff --git a/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es5.2.minified.js b/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es5.2.minified.js index 3d01e9dbaf6d..39774c3fd3ea 100644 --- a/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es5.2.minified.js @@ -1 +1,2 @@ isString1(0, ""), isString1(0, ""), isString2(""); +isString1(0, "") === isString2(""), isString1(0, "") === isString2(""); diff --git a/crates/swc_ecma_minifier/src/option/terser.rs b/crates/swc_ecma_minifier/src/option/terser.rs index fb99f6e61638..9ee96f6c2106 100644 --- a/crates/swc_ecma_minifier/src/option/terser.rs +++ b/crates/swc_ecma_minifier/src/option/terser.rs @@ -372,6 +372,7 @@ impl TerserCompressorOptions { side_effects: self.side_effects.unwrap_or(self.defaults), // TODO: Use self.defaults switches: self.switches.unwrap_or(false), + switches: self.switches.unwrap_or(self.defaults), top_retain: self.top_retain.map(From::from).unwrap_or_default(), top_level: self.toplevel.map(From::from), typeofs: self.typeofs.unwrap_or(self.defaults), From c1e24fd471900b0af61239d7b659eefb8d8dcd5e Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 6 Apr 2022 16:19:05 +0800 Subject: [PATCH 03/27] update tests --- .../tests/fixture/issues/2257/full/output.js | 12 -- .../fixture/issues/emotion/react/1/output.js | 4 - .../fixture/issues/emotion/react/2/output.js | 3 - .../tests/fixture/issues/moment/1/output.js | 23 +--- .../fixture/issues/quagga2/1.4.2/1/output.js | 12 +- .../d6e1aeb5-38a8d7ae57119c23/output.js | 51 ++------ .../pages/index-cb36c1bf7f830e3c/output.js | 112 ++++++++---------- .../8a28b14e.d8fbda268ed281a1/output.js | 9 -- .../785-e1932cc99ac3bb67/output.js | 1 + .../tests/projects/output/angular-1.2.5.js | 2 - .../projects/output/jquery.mobile-1.4.2.js | 6 - .../tests/projects/output/mootools-1.4.5.js | 1 - .../tests/projects/output/react-17.0.2.js | 2 - .../tests/projects/output/react-dom-17.0.2.js | 57 ++------- 14 files changed, 80 insertions(+), 215 deletions(-) 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 5020437eb75c..758e2290ec60 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 @@ -1002,7 +1002,6 @@ value: value, done: !1 }); - break; } (front = front.next) ? resume(front.key, front.arg) : back = null; } @@ -8906,7 +8905,6 @@ break; case FRAGMENT: chr != EOF && (url.fragment += percentEncode(chr, fragmentPercentEncodeSet)); - break; } pointer++; } @@ -14413,8 +14411,6 @@ if (null !== (b = c.updateQueue)) { if (a = null, null !== c.child) switch(c.child.tag){ case 5: - a = c.child.stateNode; - break; case 1: a = c.child.stateNode; } @@ -14529,8 +14525,6 @@ var d = !1; break; case 3: - b = b.containerInfo, d = !0; - break; case 4: b = b.containerInfo, d = !0; break; @@ -14810,8 +14804,6 @@ case 1: throw Error(y(345)); case 2: - Uj(a); - break; case 3: if (Ii(a, c), (62914560 & c) === c && 10 < (d = jj + 500 - O())) { if (0 !== Uc(a, 0)) break; @@ -14903,8 +14895,6 @@ fh(); break; case 13: - H(P); - break; case 19: H(P); break; @@ -15189,8 +15179,6 @@ var L = Z.stateNode; switch(Z.tag){ case 5: - q = L; - break; default: q = L; } diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/1/output.js index 0f780bb68c14..becc1a784f8a 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/1/output.js @@ -156,7 +156,6 @@ break; case 92: next1(); - break; } return position; } @@ -571,9 +570,6 @@ var previousCursor = cursor, result = interpolation(mergedProps); return cursor = previousCursor, handleInterpolation(mergedProps, registered, result); } - break; - case 'string': - break; } if (null == registered) return interpolation; var cached = registered[interpolation]; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js index d7d13bc0b3a6..5e47eac1000d 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/emotion/react/2/output.js @@ -85,9 +85,6 @@ function handleInterpolation(mergedProps, registered, interpolation) { var previousCursor = cursor, result = interpolation(mergedProps); return cursor = previousCursor, handleInterpolation(mergedProps, registered, result); } - break; - case 'string': - break; } if (null == registered) return interpolation; var cached = registered[interpolation]; 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 1a5fc5a023b9..33815b12f24c 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 @@ -1303,7 +1303,6 @@ break; case 'second': time = this._d.valueOf(), time += 1000 - (time % (divisor2 = 1000) + divisor2) % divisor2 - 1; - break; } return this._d.setTime(time), hooks.updateOffset(this, !0), this; }, proto.format = function(inputString) { @@ -1394,7 +1393,6 @@ break; case 'second': time = this._d.valueOf(), time -= (time % (divisor4 = 1000) + divisor4) % divisor4; - break; } return this._d.setTime(time), hooks.updateOffset(this, !0), this; }, proto.subtract = subtract, proto.toArray = function() { @@ -1588,20 +1586,12 @@ this._config = config, this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + '|' + /\d{1,2}/.source); }, proto$1.eras = function(m, format) { var i, l, date, eras = this._eras || getLocale('en')._eras; - for(i = 0, l = eras.length; i < l; ++i){ - switch(typeof eras[i].since){ - case 'string': - date = hooks(eras[i].since).startOf('day'), eras[i].since = date.valueOf(); - break; - } - switch(typeof eras[i].until){ - case 'undefined': - eras[i].until = Infinity; - break; - case 'string': - date = hooks(eras[i].until).startOf('day').valueOf(), eras[i].until = date.valueOf(); - break; - } + for(i = 0, l = eras.length; i < l; ++i)switch('string' == typeof eras[i].since && (date = hooks(eras[i].since).startOf('day'), eras[i].since = date.valueOf()), typeof eras[i].until){ + case 'undefined': + eras[i].until = Infinity; + break; + case 'string': + date = hooks(eras[i].until).startOf('day').valueOf(), eras[i].until = date.valueOf(); } return eras; }, proto$1.erasParse = function(eraName, format, strict) { @@ -1617,7 +1607,6 @@ break; case 'NNNNN': if (narrow === eraName) return eras[i]; - break; } else if ([ name, diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js index 784c1bf9efe5..6053b8b0de38 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/quagga2/1.4.2/1/output.js @@ -1537,7 +1537,6 @@ break; case Rasterizer.CONTOUR_DIR.UNKNOWN_DIR: ctx.strokeStyle = 'green'; - break; } p = q.firstVertex, ctx.beginPath(), ctx.moveTo(p.x, p.y); do p = p.next, ctx.lineTo(p.x, p.y); @@ -4380,7 +4379,6 @@ break; case this.STOP_CODE: done = !0; - break; } break; case this.CODE_B: @@ -4397,7 +4395,6 @@ break; case this.STOP_CODE: done = !0; - break; } break; case this.CODE_C: @@ -4411,9 +4408,7 @@ break; case this.STOP_CODE: done = !0; - break; } - break; } else done = !0; unshift && (codeset = codeset === this.CODE_A ? this.CODE_B : this.CODE_A); @@ -6867,11 +6862,7 @@ } function readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd) { var type = file.getUint16(entryOffset + 2, !bigEnd), numValues = file.getUint32(entryOffset + 4, !bigEnd); - switch(type){ - case 3: - if (1 === numValues) return file.getUint16(entryOffset + 8, !bigEnd); - } - return null; + return 3 === type && 1 === numValues ? file.getUint16(entryOffset + 8, !bigEnd) : null; } function getStringFromBuffer(buffer, start, length) { for(var outstr = '', n = start; n < start + length; n++)outstr += String.fromCharCode(buffer.getUint8(n)); @@ -7151,7 +7142,6 @@ break; case 8: drawAngle = -90 * TO_RADIANS; - break; } return 0 !== drawAngle ? (_ctx.translate(_canvasSize.x / 2, _canvasSize.y / 2), _ctx.rotate(drawAngle), _ctx.drawImage(drawable, -_canvasSize.y / 2, -_canvasSize.x / 2, _canvasSize.y, _canvasSize.x), _ctx.rotate(-drawAngle), _ctx.translate(-_canvasSize.x / 2, -_canvasSize.y / 2)) : _ctx.drawImage(drawable, 0, 0, _canvasSize.x, _canvasSize.y), ctxData = _ctx.getImageData(_sx, _sy, _size.x, _size.y).data, doHalfSample ? Object(cv_utils.e)(ctxData, _size, _data) : Object(cv_utils.c)(ctxData, _data, _streamConfig), !0; } 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 94cacddd3a90..4499d0feee1d 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 @@ -9700,7 +9700,6 @@ break; default: i += 3; - break; } buffer = buffer.subarray(syncPoint), i -= syncPoint, syncPoint = 0; }, this.reset = function() { @@ -9750,7 +9749,6 @@ break; case 0x09: event.nalUnitType = 'access_unit_delimiter_rbsp'; - break; } self.trigger('data', event); }), nalByteStream.on('done', function() { @@ -9890,7 +9888,6 @@ expGolombDecoder.readUnsignedByte() << 8 | expGolombDecoder.readUnsignedByte(), expGolombDecoder.readUnsignedByte() << 8 | expGolombDecoder.readUnsignedByte() ]; - break; } sarRatio && (sarRatio[0], sarRatio[1]); } @@ -10345,7 +10342,6 @@ break; } result.seiNals.push(seiNal); - break; } return result; }, parseSamples = function(truns, baseMediaDecodeTime, tfhd) { @@ -10649,7 +10645,6 @@ break; default: frameI += 3; - break; } return frameBuffer = frameBuffer.subarray(frameSyncPoint), frameI -= frameSyncPoint, frameSyncPoint = 0, frameBuffer && frameBuffer.byteLength > 3 && 'slice_layer_without_partitioning_rbsp_idr' === parseNalUnitType(0x1f & frameBuffer[frameSyncPoint + 3]) && (foundKeyFrame = !0), foundKeyFrame; } @@ -10666,7 +10661,6 @@ pmt.table = pmt.table || {}, Object.keys(table).forEach(function(key) { pmt.table[key] = table[key]; }); - break; } startIndex += MP2T_PACKET_LENGTH, endIndex += MP2T_PACKET_LENGTH; continue; @@ -10676,12 +10670,7 @@ }, parseAudioPes_ = function(bytes, pmt, result) { for(var packet, pesType, pusi, parsed, startIndex = 0, endIndex = MP2T_PACKET_LENGTH, endLoop = !1; endIndex <= bytes.byteLength;){ if (0x47 === bytes[startIndex] && (0x47 === bytes[endIndex] || endIndex === bytes.byteLength)) { - switch(packet = bytes.subarray(startIndex, endIndex), probe.ts.parseType(packet, pmt.pid)){ - case 'pes': - pesType = probe.ts.parsePesType(packet, pmt.table), pusi = probe.ts.parsePayloadUnitStartIndicator(packet), 'audio' === pesType && pusi && (parsed = probe.ts.parsePesTime(packet)) && (parsed.type = 'audio', result.audio.push(parsed), endLoop = !0); - break; - } - if (endLoop) break; + if (packet = bytes.subarray(startIndex, endIndex), 'pes' === probe.ts.parseType(packet, pmt.pid) && (pesType = probe.ts.parsePesType(packet, pmt.table), pusi = probe.ts.parsePayloadUnitStartIndicator(packet), 'audio' === pesType && pusi && (parsed = probe.ts.parsePesTime(packet)) && (parsed.type = 'audio', result.audio.push(parsed), endLoop = !0)), endLoop) break; startIndex += MP2T_PACKET_LENGTH, endIndex += MP2T_PACKET_LENGTH; continue; } @@ -10689,12 +10678,7 @@ } for(startIndex = (endIndex = bytes.byteLength) - MP2T_PACKET_LENGTH, endLoop = !1; startIndex >= 0;){ if (0x47 === bytes[startIndex] && (0x47 === bytes[endIndex] || endIndex === bytes.byteLength)) { - switch(packet = bytes.subarray(startIndex, endIndex), probe.ts.parseType(packet, pmt.pid)){ - case 'pes': - pesType = probe.ts.parsePesType(packet, pmt.table), pusi = probe.ts.parsePayloadUnitStartIndicator(packet), 'audio' === pesType && pusi && (parsed = probe.ts.parsePesTime(packet)) && (parsed.type = 'audio', result.audio.push(parsed), endLoop = !0); - break; - } - if (endLoop) break; + if (packet = bytes.subarray(startIndex, endIndex), 'pes' === probe.ts.parseType(packet, pmt.pid) && (pesType = probe.ts.parsePesType(packet, pmt.table), pusi = probe.ts.parsePayloadUnitStartIndicator(packet), 'audio' === pesType && pusi && (parsed = probe.ts.parsePesTime(packet)) && (parsed.type = 'audio', result.audio.push(parsed), endLoop = !0)), endLoop) break; startIndex -= MP2T_PACKET_LENGTH, endIndex -= MP2T_PACKET_LENGTH; continue; } @@ -10706,20 +10690,16 @@ size: 0 }; endIndex < bytes.byteLength;){ if (0x47 === bytes[startIndex] && 0x47 === bytes[endIndex]) { - switch(packet = bytes.subarray(startIndex, endIndex), probe.ts.parseType(packet, pmt.pid)){ - case 'pes': - if (pesType = probe.ts.parsePesType(packet, pmt.table), pusi = probe.ts.parsePayloadUnitStartIndicator(packet), 'video' === pesType && (pusi && !endLoop && (parsed = probe.ts.parsePesTime(packet)) && (parsed.type = 'video', result.video.push(parsed), endLoop = !0), !result.firstKeyFrame)) { - if (pusi && 0 !== currentFrame.size) { - for(frame = new Uint8Array(currentFrame.size), i = 0; currentFrame.data.length;)pes = currentFrame.data.shift(), frame.set(pes, i), i += pes.byteLength; - if (probe.ts.videoPacketContainsKeyFrame(frame)) { - var firstKeyFrame = probe.ts.parsePesTime(frame); - firstKeyFrame ? (result.firstKeyFrame = firstKeyFrame, result.firstKeyFrame.type = 'video') : console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself."); - } - currentFrame.size = 0; - } - currentFrame.data.push(packet), currentFrame.size += packet.byteLength; + if (packet = bytes.subarray(startIndex, endIndex), 'pes' === probe.ts.parseType(packet, pmt.pid) && (pesType = probe.ts.parsePesType(packet, pmt.table), pusi = probe.ts.parsePayloadUnitStartIndicator(packet), 'video' === pesType && (pusi && !endLoop && (parsed = probe.ts.parsePesTime(packet)) && (parsed.type = 'video', result.video.push(parsed), endLoop = !0), !result.firstKeyFrame))) { + if (pusi && 0 !== currentFrame.size) { + for(frame = new Uint8Array(currentFrame.size), i = 0; currentFrame.data.length;)pes = currentFrame.data.shift(), frame.set(pes, i), i += pes.byteLength; + if (probe.ts.videoPacketContainsKeyFrame(frame)) { + var firstKeyFrame = probe.ts.parsePesTime(frame); + firstKeyFrame ? (result.firstKeyFrame = firstKeyFrame, result.firstKeyFrame.type = 'video') : console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself."); } - break; + currentFrame.size = 0; + } + currentFrame.data.push(packet), currentFrame.size += packet.byteLength; } if (endLoop && result.firstKeyFrame) break; startIndex += MP2T_PACKET_LENGTH, endIndex += MP2T_PACKET_LENGTH; @@ -10729,12 +10709,7 @@ } for(startIndex = (endIndex = bytes.byteLength) - MP2T_PACKET_LENGTH, endLoop = !1; startIndex >= 0;){ if (0x47 === bytes[startIndex] && 0x47 === bytes[endIndex]) { - switch(packet = bytes.subarray(startIndex, endIndex), probe.ts.parseType(packet, pmt.pid)){ - case 'pes': - pesType = probe.ts.parsePesType(packet, pmt.table), pusi = probe.ts.parsePayloadUnitStartIndicator(packet), 'video' === pesType && pusi && (parsed = probe.ts.parsePesTime(packet)) && (parsed.type = 'video', result.video.push(parsed), endLoop = !0); - break; - } - if (endLoop) break; + if (packet = bytes.subarray(startIndex, endIndex), 'pes' === probe.ts.parseType(packet, pmt.pid) && (pesType = probe.ts.parsePesType(packet, pmt.table), pusi = probe.ts.parsePayloadUnitStartIndicator(packet), 'video' === pesType && pusi && (parsed = probe.ts.parsePesTime(packet)) && (parsed.type = 'video', result.video.push(parsed), endLoop = !0)), endLoop) break; startIndex -= MP2T_PACKET_LENGTH, endIndex -= MP2T_PACKET_LENGTH; continue; } @@ -10776,7 +10751,6 @@ break; default: byteIndex++; - break; } if (endLoop) return null; } @@ -10809,7 +10783,6 @@ break; case streamTypes.ADTS_STREAM_TYPE: result.audio = [], parseAudioPes_(bytes, pmt, result), 0 === result.audio.length && delete result.audio; - break; } } return result; 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 9ea011d45f8d..b61f2c40282b 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 @@ -1314,7 +1314,6 @@ break; case ATTRIBUTE_NODE: deep = !0; - break; } if (node2 || (node2 = node.cloneNode(!1)), node2.ownerDocument = doc, node2.parentNode = null, deep) for(var child = node.firstChild; child;)node2.appendChild(importNode(doc, child, deep)), child = child.nextSibling; return node2; @@ -2043,7 +2042,6 @@ errorHandler.warning('attribute "' + value1 + '" missed quot(")!!'), addAttribute(attrName, value1, start); case 5: s = 6; - break; } else switch(s){ case 2: @@ -3948,7 +3946,6 @@ "left", "right" ]); - break; } }, /:/, /\s/), cue.region = settings.get("region", null), cue.vertical = settings.get("vertical", ""); try { @@ -4566,7 +4563,6 @@ break; case "end": textPos = cue.position - cue.size; - break; } "" === cue.vertical ? this.applyStyles({ left: this.formatStyle(textPos, "%"), @@ -4620,7 +4616,6 @@ "-x", "+x" ], size = "width"; - break; } var size, step = boxPosition.lineHeight, position = step * Math.round(linePos), maxPosition = containerBox[size] + step, initialAxis = axis1[0]; Math.abs(position) > maxPosition && (position = position < 0 ? -1 : 1, position *= Math.ceil(maxPosition / step) * step), linePos < 0 && (position += "" === cue2.vertical ? containerBox.height : containerBox.width, axis1 = axis1.reverse()), boxPosition.move(initialAxis, position); @@ -4632,7 +4627,6 @@ break; case "end": linePos -= calculatedPercentage; - break; } switch(cue2.vertical){ case "": @@ -4649,7 +4643,6 @@ styleBox.applyStyles({ right: styleBox.formatStyle(linePos, "%") }); - break; } axis1 = [ "+y", @@ -4687,7 +4680,6 @@ break; case "-y": this.top -= toMove, this.bottom -= toMove; - break; } }, BoxPosition.prototype.overlaps = function(b2) { return this.left < b2.right && this.right > b2.left && this.top < b2.bottom && this.bottom > b2.top; @@ -4774,64 +4766,56 @@ } function parseHeader(input3) { input3.match(/X-TIMESTAMP-MAP/) ? parseOptions(input3, function(k1, v1) { - switch(k1){ - case "X-TIMESTAMP-MAP": - var input, settings; - input = v1, settings = new Settings(), parseOptions(input, function(k, v) { - switch(k){ - case "MPEGT": - settings.integer(k + 'S', v); - break; - case "LOCA": - settings.set(k + 'L', parseTimeStamp(v)); - break; - } - }, /[^\d]:/, /,/), self.ontimestampmap && self.ontimestampmap({ - MPEGTS: settings.get("MPEGTS"), - LOCAL: settings.get("LOCAL") - }); - break; + if ("X-TIMESTAMP-MAP" === k1) { + var input, settings; + input = v1, settings = new Settings(), parseOptions(input, function(k, v) { + switch(k){ + case "MPEGT": + settings.integer(k + 'S', v); + break; + case "LOCA": + settings.set(k + 'L', parseTimeStamp(v)); + } + }, /[^\d]:/, /,/), self.ontimestampmap && self.ontimestampmap({ + MPEGTS: settings.get("MPEGTS"), + LOCAL: settings.get("LOCAL") + }); } }, /=/) : parseOptions(input3, function(k2, v2) { - switch(k2){ - case "Region": - !function(input) { - var settings = new Settings(); - if (parseOptions(input, function(k, v) { - switch(k){ - case "id": - settings.set(k, v); - break; - case "width": - settings.percent(k, v); - break; - case "lines": - settings.integer(k, v); - break; - case "regionanchor": - case "viewportanchor": - var xy = v.split(','); - if (2 !== xy.length) break; - var anchor = new Settings(); - if (anchor.percent("x", xy[0]), anchor.percent("y", xy[1]), !anchor.has("x") || !anchor.has("y")) break; - settings.set(k + "X", anchor.get("x")), settings.set(k + "Y", anchor.get("y")); - break; - case "scroll": - settings.alt(k, v, [ - "up" - ]); - break; - } - }, /=/, /\s/), settings.has("id")) { - var region = new (self.vttjs.VTTRegion || self.window.VTTRegion)(); - region.width = settings.get("width", 100), region.lines = settings.get("lines", 3), region.regionAnchorX = settings.get("regionanchorX", 0), region.regionAnchorY = settings.get("regionanchorY", 100), region.viewportAnchorX = settings.get("viewportanchorX", 0), region.viewportAnchorY = settings.get("viewportanchorY", 100), region.scroll = settings.get("scroll", ""), self.onregion && self.onregion(region), self.regionList.push({ - id: settings.get("id"), - region: region - }); - } - }(v2); - break; - } + "Region" === k2 && function(input) { + var settings = new Settings(); + if (parseOptions(input, function(k, v) { + switch(k){ + case "id": + settings.set(k, v); + break; + case "width": + settings.percent(k, v); + break; + case "lines": + settings.integer(k, v); + break; + case "regionanchor": + case "viewportanchor": + var xy = v.split(','); + if (2 !== xy.length) break; + var anchor = new Settings(); + if (anchor.percent("x", xy[0]), anchor.percent("y", xy[1]), !anchor.has("x") || !anchor.has("y")) break; + settings.set(k + "X", anchor.get("x")), settings.set(k + "Y", anchor.get("y")); + break; + case "scroll": + settings.alt(k, v, [ + "up" + ]); + } + }, /=/, /\s/), settings.has("id")) { + var region = new (self.vttjs.VTTRegion || self.window.VTTRegion)(); + region.width = settings.get("width", 100), region.lines = settings.get("lines", 3), region.regionAnchorX = settings.get("regionanchorX", 0), region.regionAnchorY = settings.get("regionanchorY", 100), region.viewportAnchorX = settings.get("viewportanchorX", 0), region.viewportAnchorY = settings.get("viewportanchorY", 100), region.scroll = settings.get("scroll", ""), self.onregion && self.onregion(region), self.regionList.push({ + id: settings.get("id"), + region: region + }); + } + }(v2); }, /:/); } data && (self.buffer += self.decoder.decode(data, { 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 1b9599557277..37e57b5229c3 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 @@ -442,7 +442,6 @@ case e.DOM_DELTA_LINE: case e.DOM_DELTA_PAGE: e.wheelX = 5 * (e.deltaX || 0), e.wheelY = 5 * (e.deltaY || 0); - break; } callback(e); }, destroyer) : addListener(el, "DOMMouseScroll", function(e) { @@ -915,7 +914,6 @@ break; case 88: onCut(e); - break; } }, host); var onCompositionUpdate = function() { @@ -1328,7 +1326,6 @@ break; case "copy": range = editor.moveText(range, dragCursor, !0); - break; } else { var dropData = dataTransfer.getData('Text'); @@ -4515,7 +4512,6 @@ case "remove": var endColumn = delta.end.column, endRow = delta.end.row; row === endRow ? docLines[row] = line.substring(0, startColumn) + line.substring(endColumn) : docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn)); - break; } }; }), ace.define("ace/anchor", [ @@ -7815,9 +7811,6 @@ case "selectionPart": var range = this.selection.getRange(), config = this.renderer.layerConfig; (range.start.row >= config.lastRow || range.end.row <= config.firstRow) && this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead); - break; - default: - break; } "animate" == scrollIntoView && this.renderer.animateScrolling(this.curOp.scrollTop); } @@ -8572,7 +8565,6 @@ case ']': case '}': depth[bracketType]--, -1 === depth[bracketType] && (matchType = 'bracket', found = !0); - break; } } else -1 !== token.type.indexOf('tag-name') && (isNaN(depth[token.value]) && (depth[token.value] = 0), '<' === prevToken.value ? depth[token.value]++ : '\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=an(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=ao(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=as(j,k),a.distance=ar(j,k),al(b,a),a.offsetDirection=aq(a.deltaX,a.deltaY);var d=ap(a.deltaTime,a.deltaX,a.deltaY);a.overallVelocityX=d.x,a.overallVelocityY=d.y,a.overallVelocity=T(d.x)>T(d.y)?d.x:d.y,a.scale=c?au(c.pointers,e):1,a.rotation=c?at(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,am(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function al(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function am(h,a){var d,e,f,g,b=h.lastInterval||a,i=a.timeStamp-b.timeStamp;if(8!=a.eventType&&(i>25||l===b.velocity)){var j=a.deltaX-b.deltaX,k=a.deltaY-b.deltaY,c=ap(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=aq(j,k),h.lastInterval=a}else d=b.velocity,e=b.velocityX,f=b.velocityY,g=b.direction;a.velocity=d,a.velocityX=e,a.velocityY=f,a.direction=g}function an(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ar(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function as(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function at(a,b){return as(b[1],b[0],ai)+as(a[1],a[0],ai)}function au(a,b){return ar(b[0],b[1],ai)/ar(a[0],a[1],ai)}f.prototype={handler:function(){},init:function(){this.evEl&&H(this.element,this.evEl,this.domHandler),this.evTarget&&H(this.target,this.evTarget,this.domHandler),this.evWin&&H(ae(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&I(this.element,this.evEl,this.domHandler),this.evTarget&&I(this.target,this.evTarget,this.domHandler),this.evWin&&I(ae(this.element),this.evWin,this.domHandler)}};var av={mousedown:1,mousemove:2,mouseup:4};function u(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,f.apply(this,arguments)}e(u,f,{handler:function(a){var b=av[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:L,srcEvent:a}))}});var aw={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},ax={2:K,3:"pen",4:L,5:"kinect"},M="pointerdown",N="pointermove pointerup pointercancel";function v(){this.evEl=M,this.evWin=N,f.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}g.MSPointerEvent&&!g.PointerEvent&&(M="MSPointerDown",N="MSPointerMove MSPointerUp MSPointerCancel"),e(v,f,{handler:function(a){var b=this.store,e=!1,d=aw[a.type.toLowerCase().replace("ms","")],f=ax[a.pointerType]||a.pointerType,c=aa(b,a.pointerId,"pointerId");1&d&&(0===a.button||f==K)?c<0&&(b.push(a),c=b.length-1):12&d&&(e=!0),!(c<0)&&(b[c]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),e&&b.splice(c,1))}});var ay={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function w(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,f.apply(this,arguments)}function az(b,d){var a=ab(b.touches),c=ab(b.changedTouches);return 12&d&&(a=ac(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ay[c.type];if(1===a&&(this.started=!0),this.started){var b=az.call(this,c,a);12&a&&b[0].length-b[1].length==0&&(this.started=!1),this.callback(this.manager,a,{pointers:b[0],changedPointers:b[1],pointerType:K,srcEvent:c})}}});var aA={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function x(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},f.apply(this,arguments)}function aB(h,g){var b=ab(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ab(h.changedTouches),f=[],i=this.target;if(d=b.filter(function(a){return Z(a.target,i)}),1===g)for(a=0;a -1&&d.splice(a,1)},2500)}}function aE(b){for(var d=b.srcEvent.clientX,e=b.srcEvent.clientY,a=0;a -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(d){var c=this,a=this.state;function b(a){c.manager.emit(a,d)}a<8&&b(c.options.event+aM(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+aM(a))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ac.threshold&&b&c.direction},attrTest:function(a){return h.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=aN(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),e(p,h,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),e(q,i,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[aG]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=V(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=U(),this.manager.emit(this.options.event,this._input)))}}),e(r,h,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),e(s,h,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return o.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&T(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=aN(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),e(j,i,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[aH]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var a=1;ac.length)&&(a=c.length);for(var b=0,d=new Array(a);bc?c:a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),bc=new h(4),h!=Float32Array&&(bc[0]=0,bc[1]=0,bc[2]=0,bc[3]=0);const aF=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function aG(e,f,g){var h=f[0],i=f[1],j=f[2],k=f[3],l=f[4],m=f[5],n=f[6],o=f[7],p=f[8],q=f[9],r=f[10],s=f[11],t=f[12],u=f[13],v=f[14],w=f[15],a=g[0],b=g[1],c=g[2],d=g[3];return e[0]=a*h+b*l+c*p+d*t,e[1]=a*i+b*m+c*q+d*u,e[2]=a*j+b*n+c*r+d*v,e[3]=a*k+b*o+c*s+d*w,a=g[4],b=g[5],c=g[6],d=g[7],e[4]=a*h+b*l+c*p+d*t,e[5]=a*i+b*m+c*q+d*u,e[6]=a*j+b*n+c*r+d*v,e[7]=a*k+b*o+c*s+d*w,a=g[8],b=g[9],c=g[10],d=g[11],e[8]=a*h+b*l+c*p+d*t,e[9]=a*i+b*m+c*q+d*u,e[10]=a*j+b*n+c*r+d*v,e[11]=a*k+b*o+c*s+d*w,a=g[12],b=g[13],c=g[14],d=g[15],e[12]=a*h+b*l+c*p+d*t,e[13]=a*i+b*m+c*q+d*u,e[14]=a*j+b*n+c*r+d*v,e[15]=a*k+b*o+c*s+d*w,e}function aH(b,a,f){var g,h,i,j,k,l,m,n,o,p,q,r,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],b[0]=g,b[1]=h,b[2]=i,b[3]=j,b[4]=k,b[5]=l,b[6]=m,b[7]=n,b[8]=o,b[9]=p,b[10]=q,b[11]=r,b[12]=g*c+k*d+o*e+a[12],b[13]=h*c+l*d+p*e+a[13],b[14]=i*c+m*d+q*e+a[14],b[15]=j*c+n*d+r*e+a[15]),b}function aI(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function aJ(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function aK(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function aL(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function aM(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}bd=new h(2),h!=Float32Array&&(bd[0]=0,bd[1]=0),be=new h(3),h!=Float32Array&&(be[0]=0,be[1]=0,be[2]=0);const n=Math.PI,aN=n/4,aO=n/180,aP=180/n;function aQ(a){return Math.pow(2,a)}function aR([b,a]){return aM(Number.isFinite(b)),aM(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*aO+n)/(2*n),512*(n+Math.log(Math.tan(aN+.5*(a*aO))))/(2*n)]}function aS([a,b]){return[(a/512*(2*n)-n)*aP,2*(Math.atan(Math.exp(b/512*(2*n)-n))-aN)*aP]}function aT(a){return 2*Math.atan(.5/a)*aP}function aU(a){return .5/Math.tan(.5*a*aO)}function aV(i,c,j=0){const[a,b,e]=i;if(aM(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=aC(c,[a,b,e,1]);return k}const f=aC(c,[a,b,0,1]),g=aC(c,[a,b,1,1]),d=f[2],h=g[2];return aL([],f,g,d===h?0:((j||0)-d)/(h-d))}const aW=Math.PI/180;function aX(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=aC(e,[c,0,1,1]),f=aC(e,[c,a.height,1,1]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=aL([],b,f,i),g=aS(j);return g[2]=d,g}class aY{constructor({width:f,height:c,latitude:l=0,longitude:m=0,zoom:p=0,pitch:n=0,bearing:q=0,altitude:a=null,fovy:b=null,position:o=null,nearZMultiplier:t=.02,farZMultiplier:u=1.01}={width:1,height:1}){f=f||1,c=c||1,null===b&&null===a?b=aT(a=1.5):null===b?b=aT(a):null===a&&(a=aU(b));const r=aQ(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){aM(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*aO),e=1.4222222222222223/d,a=12790407194604047e-21/d;if(b.unitsPerMeter=[a,a,a],b.metersPerUnit=[1/a,1/a,1/a],b.unitsPerDegree=[1.4222222222222223,e,a],b.degreesPerUnit=[.703125,1/e,1/a],j){const f=aO*Math.tan(c*aO)/d,k=1.4222222222222223*f/2,g=12790407194604047e-21*f,h=g/e*a;b.unitsPerDegree2=[0,k,g],b.unitsPerMeter2=[h,0,h]}return b}({longitude:m,latitude:l}),d=aR([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,k=(e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],e),i[0]=j[0]+k[0],i[1]=j[1]+k[1],i[2]=j[2]+k[2]}this.projectionMatrix=function({width:h,height:i,pitch:j,altitude:k,fovy:l,nearZMultiplier:m,farZMultiplier:n}){var a,f,g,c,b,d,e;const{fov:o,aspect:p,near:q,far:r}=function({width:f,height:g,fovy:a=aT(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=aT(d));const b=.5*a*aO,c=aU(a),e=h*aO;return{fov:2*b,aspect:f/g,focalDistance:c,near:i,far:(Math.sin(e)*(Math.sin(b)*c/Math.sin(Math.min(Math.max(Math.PI/2-e-b,.01),Math.PI-.01)))+c)*j}}({width:h,height:i,altitude:k,fovy:l,pitch:j,nearZMultiplier:m,farZMultiplier:n}),s=(a=[],f=o,g=p,c=q,b=r,e=1/Math.tan(f/2),a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(d=1/(c-b),a[10]=(b+c)*d,a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a);return s}({width:f,height:c,pitch:n,fovy:b,nearZMultiplier:t,farZMultiplier:u}),this.viewMatrix=function({height:F,pitch:G,bearing:H,altitude:I,scale:l,center:E=null}){var a,b,m,f,g,n,o,p,q,r,s,t,u,c,d,v,h,i,w,x,y,z,A,B,C,D,j,k;const e=aB();return aH(e,e,[0,0,-I]),a=e,b=e,m=-G*aO,f=Math.sin(m),g=Math.cos(m),n=b[4],o=b[5],p=b[6],q=b[7],r=b[8],s=b[9],t=b[10],u=b[11],b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=n*g+r*f,a[5]=o*g+s*f,a[6]=p*g+t*f,a[7]=q*g+u*f,a[8]=r*g-n*f,a[9]=s*g-o*f,a[10]=t*g-p*f,a[11]=u*g-q*f,c=e,d=e,v=H*aO,h=Math.sin(v),i=Math.cos(v),w=d[0],x=d[1],y=d[2],z=d[3],A=d[4],B=d[5],C=d[6],D=d[7],d!==c&&(c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15]),c[0]=w*i+A*h,c[1]=x*i+B*h,c[2]=y*i+C*h,c[3]=z*i+D*h,c[4]=A*i-w*h,c[5]=B*i-x*h,c[6]=C*i-y*h,c[7]=D*i-z*h,aI(e,e,[l/=F,l,l]),E&&aH(e,e,(j=[],k=E,j[0]=-k[0],j[1]=-k[1],j[2]=-k[2],j)),e}({height:c,scale:r,center:d,pitch:n,bearing:q,altitude:a}),this.width=f,this.height=c,this.scale=r,this.latitude=l,this.longitude=m,this.zoom=p,this.pitch=n,this.bearing=q,this.altitude=a,this.fovy=b,this.center=d,this.meterOffset=o||[0,0,0],this.distanceScales=s,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,a;const{width:I,height:J,projectionMatrix:K,viewMatrix:L}=this,G=aB();aG(G,G,K),aG(G,G,L),this.viewProjectionMatrix=G;const d=aB();aI(d,d,[I/2,-J/2,1]),aH(d,d,[1,-1,0]),aG(d,d,G);const H=(b=aB(),e=(c=d)[0],f=c[1],g=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=c[8],n=c[9],o=c[10],p=c[11],q=c[12],r=c[13],s=c[14],t=c[15],u=e*j-f*i,v=e*k-g*i,w=e*l-h*i,x=f*k-g*j,y=f*l-h*j,z=g*l-h*k,A=m*r-n*q,B=m*s-o*q,C=m*t-p*q,D=n*s-o*r,E=n*t-p*r,F=o*t-p*s,a=u*F-v*E+w*D+x*C-y*B+z*A,a?(a=1/a,b[0]=(j*F-k*E+l*D)*a,b[1]=(g*E-f*F-h*D)*a,b[2]=(r*z-s*y+t*x)*a,b[3]=(o*y-n*z-p*x)*a,b[4]=(k*C-i*F-l*B)*a,b[5]=(e*F-g*C+h*B)*a,b[6]=(s*w-q*z-t*v)*a,b[7]=(m*z-o*w+p*v)*a,b[8]=(i*E-j*C+l*A)*a,b[9]=(f*C-e*E-h*A)*a,b[10]=(q*y-r*w+t*u)*a,b[11]=(n*w-m*y-p*u)*a,b[12]=(j*B-i*D-k*A)*a,b[13]=(e*D-f*B+g*A)*a,b[14]=(r*v-q*x-s*u)*a,b[15]=(m*x-n*v+o*u)*a,b):null);if(!H)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=H}equals(a){return a instanceof aY&&a.width===this.width&&a.height===this.height&&aJ(a.projectionMatrix,this.projectionMatrix)&&aJ(a.viewMatrix,this.viewMatrix)}project(a,{topLeft:f=!0}={}){const g=this.projectPosition(a),b=function(d,e){const[a,b,c=0]=d;return aM(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),aC(e,[a,b,c,1])}(g,this.pixelProjectionMatrix),[c,d]=b,e=f?d:this.height-d;return 2===a.length?[c,e]:[c,e,b[2]]}unproject(f,{topLeft:g=!0,targetZ:a}={}){const[h,d,e]=f,i=g?d:this.height-d,j=a&&a*this.distanceScales.unitsPerMeter[2],k=aV([h,i,e],this.pixelUnprojectionMatrix,j),[b,c,l]=this.unprojectPosition(k);return Number.isFinite(e)?[b,c,l]:Number.isFinite(a)?[b,c,a]:[b,c]}projectPosition(a){const[b,c]=aR(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=aS(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return aR(a)}unprojectFlat(a){return aS(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=aV(d,this.pixelUnprojectionMatrix),f=aR(c),g=aK([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=aK([],this.center,g);return aS(h)}getLocationAtPoint({lngLat:a,pos:b}){return this.getMapCenterByLngLatPosition({lngLat:a,pos:b})}fitBounds(c,d={}){const{width:a,height:b}=this,{longitude:e,latitude:f,zoom:g}=function({width:m,height:n,bounds:o,minExtent:f=0,maxZoom:p=24,padding:a=0,offset:g=[0,0]}){const[[q,r],[s,t]]=o;if(Number.isFinite(a)){const b=a;a={top:b,bottom:b,left:b,right:b}}else aM(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=aR([q,aE(t,-85.051129,85.051129)]),d=aR([s,aE(r,-85.051129,85.051129)]),h=[Math.max(Math.abs(d[0]-c[0]),f),Math.max(Math.abs(d[1]-c[1]),f)],e=[m-a.left-a.right-2*Math.abs(g[0]),n-a.top-a.bottom-2*Math.abs(g[1])];aM(e[0]>0&&e[1]>0);const i=e[0]/h[0],j=e[1]/h[1],u=(a.right-a.left)/2/i,v=(a.bottom-a.top)/2/j,w=[(d[0]+c[0])/2+u,(d[1]+c[1])/2+v],k=aS(w),l=Math.min(p,aF(Math.abs(Math.min(i,j))));return aM(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new aY({width:a,height:b,longitude:e,latitude:f,zoom:g})}getBounds(b){const a=this.getBoundingRegion(b),c=Math.min(...a.map(a=>a[0])),d=Math.max(...a.map(a=>a[0])),e=Math.min(...a.map(a=>a[1])),f=Math.max(...a.map(a=>a[1]));return[[c,e],[d,f]]}getBoundingRegion(a={}){return function(a,d=0){const{width:e,height:h,unproject:b}=a,c={targetZ:d},i=b([0,h],c),j=b([e,h],c);let f,g;const k=a.fovy?.5*a.fovy*aW:Math.atan(.5/a.altitude),l=(90-a.pitch)*aW;return k>l-.01?(f=aX(a,0,d),g=aX(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const aZ=["longitude","latitude","zoom"],a$={curve:1.414,speed:1.2};function a_(d,h,i){var f,j,k,o,p,q;i=Object.assign({},a$,i);const g=i.curve,l=d.zoom,w=[d.longitude,d.latitude],x=aQ(l),y=h.zoom,z=[h.longitude,h.latitude],A=aQ(y-l),r=aR(w),B=aR(z),s=(f=[],j=B,k=r,f[0]=j[0]-k[0],f[1]=j[1]-k[1],f),a=Math.max(d.width,d.height),e=a/A,t=(p=(o=s)[0],q=o[1],Math.hypot(p,q)*x),c=Math.max(t,.01),b=g*g,m=(e*e-a*a+b*b*c*c)/(2*a*b*c),n=(e*e-a*a-b*b*c*c)/(2*e*b*c),u=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(n*n+1)-n);return{startZoom:l,startCenterXY:r,uDelta:s,w0:a,u1:t,S:(v-u)/g,rho:g,rho2:b,r0:u,r1:v}}var N=function(){if("undefined"!=typeof Map)return Map;function a(a,c){var b=-1;return a.some(function(a,d){return a[0]===c&&(b=d,!0)}),b}return function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(c){var d=a(this.__entries__,c),b=this.__entries__[d];return b&&b[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(d){var b=this.__entries__,c=a(b,d);~c&&b.splice(c,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(e,a){void 0===a&&(a=null);for(var b=0,c=this.__entries__;b0},a.prototype.connect_=function(){a0&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),a3?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){a0&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(b){var a=b.propertyName,c=void 0===a?"":a;a2.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null,a}(),a5=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),bi="undefined"!=typeof WeakMap?new WeakMap:new N,O=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=a4.getInstance(),d=new bh(b,c,this);bi.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=bi.get(this))[a].apply(b,arguments)}});var bj=void 0!==o.ResizeObserver?o.ResizeObserver:O;function bk(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function bl(d,c){for(var b=0;b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function bq(a,c){if(a){if("string"==typeof a)return br(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return br(a,c)}}function br(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b1&& void 0!==arguments[1]?arguments[1]:"component";b.debug&&a.checkPropTypes(Q,b,"prop",c)}var i=function(){function a(b){var c=this;if(bk(this,a),g(this,"props",R),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return bm(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var d=this._map.getContainer(),c=b.container;for(c.classList.add("mapboxgl-map");d.childNodes.length>0;)c.appendChild(d.childNodes[0]);this._map._container=c,a.savedMap=null,b.mapStyle&&this._map.setStyle(bt(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var d=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=d,b.gl}}var c={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:bt(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(c.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},c,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var d=this;bv(a=Object.assign({},R,a),"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||R.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var b=a.container;Object.defineProperty(b,"offsetWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"clientWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"offsetHeight",{configurable:!0,get:function(){return d.height}}),Object.defineProperty(b,"clientHeight",{configurable:!0,get:function(){return d.height}});var c=this._map.getCanvas();c&&(c.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(b,a){if(this._map){bv(a=Object.assign({},this.props,a),"Mapbox");var c=this._updateMapViewport(b,a),d=this._updateMapSize(b,a);this._updateMapStyle(b,a),!a.asyncRender&&(c||d)&&this.redraw(),this.props=a}}},{key:"_updateMapStyle",value:function(b,a){b.mapStyle!==a.mapStyle&&this._map.setStyle(bt(a.mapStyle),{diff:!a.preventStyleDiffing})}},{key:"_updateMapSize",value:function(b,a){var c=b.width!==a.width||b.height!==a.height;return c&&(this.width=a.width,this.height=a.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(d,e){var b=this._getViewState(d),a=this._getViewState(e),c=a.latitude!==b.latitude||a.longitude!==b.longitude||a.zoom!==b.zoom||a.pitch!==b.pitch||a.bearing!==b.bearing||a.altitude!==b.altitude;return c&&(this._map.jumpTo(this._viewStateToMapboxProps(a)),a.altitude!==b.altitude&&(this._map.transform.altitude=a.altitude)),c}},{key:"_getViewState",value:function(b){var a=b.viewState||b,f=a.longitude,g=a.latitude,h=a.zoom,c=a.pitch,d=a.bearing,e=a.altitude;return{longitude:f,latitude:g,zoom:h,pitch:void 0===c?0:c,bearing:void 0===d?0:d,altitude:void 0===e?1.5:e}}},{key:"_checkStyleSheet",value:function(){var c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==P)try{var a=P.createElement("div");if(a.className="mapboxgl-map",a.style.display="none",P.body.appendChild(a),!("static"!==window.getComputedStyle(a).position)){var b=P.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("type","text/css"),b.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(c,"/mapbox-gl.css")),P.head.appendChild(b)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}}]),a}();g(i,"initialized",!1),g(i,"propTypes",Q),g(i,"defaultProps",R),g(i,"savedMap",null);var S=b(6158),A=b.n(S);function bw(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function bx(a,b){if(a===b)return!0;if(bw(a)&&bw(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function by(a,b,c){return Math.max(b,Math.min(c,a))}function bz(a,c,b){return bw(a)?a.map(function(a,d){return bz(a,c[d],b)}):b*c+(1-b)*a}function bA(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function bB(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bC(c){for(var a=1;a0,"`scale` must be a positive number");var f=this._state,b=f.startZoom,c=f.startZoomLngLat;Number.isFinite(b)||(b=this._viewportProps.zoom,c=this._unproject(i)||this._unproject(d)),bA(c,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var g=this._calculateNewZoom({scale:e,startZoom:b||0}),j=new aY(Object.assign({},this._viewportProps,{zoom:g})),k=j.getMapCenterByLngLatPosition({lngLat:c,pos:d}),h=aA(k,2),l=h[0],m=h[1];return this._getUpdatedMapState({zoom:g,longitude:l,latitude:m})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=by(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=by(g,f,e),Object.assign(a,function({width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k=0,bearing:c=0}){(b< -180||b>180)&&(b=aD(b+180,360)-180),(c< -180||c>180)&&(c=aD(c+180,360)-180);const f=aF(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=aS([0,g])[1];if(ai&&(a=i)}}return{width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k,bearing:c}}(a)),a}},{key:"_unproject",value:function(a){var b=new aY(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new aY(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var c=a.scale,d=a.startZoom,b=this._viewportProps,e=b.maxZoom,f=b.minZoom;return by(d+Math.log2(c),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(c){var f=c.deltaScaleX,a=c.deltaScaleY,g=c.startBearing,b=c.startPitch;a=by(a,-1,1);var e=this._viewportProps,h=e.minPitch,i=e.maxPitch,d=b;return a>0?d=b+a*(i-b):a<0&&(d=b-a*(h-b)),{pitch:d,bearing:g+180*f}}},{key:"_getRotationParams",value:function(c,d){var h=c[0]-d[0],e=c[1]-d[1],i=c[1],a=d[1],f=this._viewportProps,j=f.width,g=f.height,b=0;return e>0?Math.abs(g-a)>5&&(b=e/(a-g)*1.2):e<0&&a>5&&(b=1-i/a),{deltaScaleX:h/j,deltaScaleY:b=Math.min(1,Math.max(-1,b))}}}]),a}();function bF(a){return a[0].toLowerCase()+a.slice(1)}function bG(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bH(c){for(var a=1;a1&& void 0!==arguments[1]?arguments[1]:{},b=a.current&&a.current.getMap();return b&&b.queryRenderedFeatures(c,d)}}},[]);var p=(0,c.useCallback)(function(b){var a=b.target;a===o.current&&a.scrollTo(0,0)},[]),q=d&&c.createElement(bI,{value:bN(bN({},b),{},{viewport:b.viewport||bP(bN({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:bQ,onScroll:p},a.children)),r=a.className,s=a.width,t=a.height,u=a.style,v=a.visibilityConstraints,w=Object.assign({position:"relative"},u,{width:s,height:t}),x=a.visible&&function(c){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:B;for(var a in b){var d=a.slice(0,3),e=bF(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},bQ,{visibility:x?"inherit":"hidden"});return c.createElement("div",{key:"map-container",ref:h,style:w},c.createElement("div",{key:"map-mapbox",ref:n,style:y,className:r}),q,!l&&!a.disableTokenWarning&&c.createElement(bR,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bS(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(a.s();!(b=a.n()).done;){var c=b.value;if(!bx(d[c],e[c]))return!1}}catch(f){a.e(f)}finally{a.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){bA(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}}]),a}();function bT(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function bU(a,b){return(bU=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function bV(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),a&&bU(b,a)}function bW(a){return(bW="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function bX(b,a){if(a&&("object"===bW(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return bT(b)}function bY(a){return(bY=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var bZ={longitude:1,bearing:1};function b$(a){return Number.isFinite(a)||Array.isArray(a)}function b_(b,c,a){return b in bZ&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function b0(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=b1(a))||c&&a&&"number"==typeof a.length){e&&(a=e);var d=0,b=function(){};return{s:b,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b1(a,c){if(a){if("string"==typeof a)return b2(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b2(a,c)}}function b2(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b8(a,c){if(a){if("string"==typeof a)return b9(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b9(a,c)}}function b9(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,d),g(bT(a=e.call(this)),"propNames",b3),a.props=Object.assign({},b6,b),a}bm(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=b0(b4);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];bA(b$(g)&&b$(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=b_(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=b0(b5);try{for(d.s();!(l=d.n()).done;){var b=l.value,m=h[b]||0,o=i[b]||0;e[b]=m,f[b]=b_(b,m,o)}}catch(p){d.e(p)}finally{d.f()}return{start:e,end:f}}},{key:"interpolateProps",value:function(c,d,e){var f,g=function(h,i,j,r={}){var k,l,m,c,d,e;const a={},{startZoom:s,startCenterXY:t,uDelta:u,w0:v,u1:n,S:w,rho:o,rho2:x,r0:b}=a_(h,i,r);if(n<.01){for(const f of aZ){const y=h[f],z=i[f];a[f]=(k=y,l=z,(m=j)*l+(1-m)*k)}return a}const p=j*w,A=s+aF(1/(Math.cosh(b)/Math.cosh(b+o*p))),g=(c=[],d=u,e=v*((Math.cosh(b)*Math.tanh(b+o*p)-Math.sinh(b))/x)/n,c[0]=d[0]*e,c[1]=d[1]*e,c);aK(g,g,t);const q=aS(g);return a.longitude=q[0],a.latitude=q[1],a.zoom=A,a}(c,d,e,this.props),a=b0(b5);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=bz(c[b],d[b],e)}}catch(h){a.e(h)}finally{a.f()}return g}},{key:"getDuration",value:function(c,b){var a=b.transitionDuration;return"auto"===a&&(a=function(f,g,a={}){a=Object.assign({},a$,a);const{screenSpeed:c,speed:h,maxDuration:d}=a,{S:i,rho:j}=a_(f,g,a),e=1e3*i;let b;return b=Number.isFinite(c)?e/(c/j):e/h,Number.isFinite(d)&&b>d?0:b}(c,b,this.props)),a}}])}(C);var ca=["longitude","latitude","zoom","bearing","pitch"],D=function(b){bV(a,b);var c,d,e=(c=a,d=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(c);if(d){var e=bY(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||ca,b.around&&(c.around=b.around),c}return bm(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new aY(g).unproject(this.around);Object.assign(e,c,{around:new aY(c).project(h),aroundLngLat:h})}var i,b=b7(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];bA(b$(f)&&b$(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=b_(a,f,j)}}catch(k){b.e(k)}finally{b.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(e,a,f){var g,b={},c=b7(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=bz(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var h=aA(new aY(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:bz(e.around,a.around,f)}),2),j=h[0],k=h[1];b.longitude=j,b.latitude=k}return b}}]),a}(C),r=function(){},E={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},V={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new D,transitionInterruption:E.BREAK,onTransitionStart:r,onTransitionInterrupt:r,onTransitionEnd:r},F=function(){function a(){var c=this,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};bk(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){c._animationFrame=requestAnimationFrame(c._onTransitionFrame),c._updateViewport()}),this.props=null,this.onViewportChange=b.onViewportChange||r,this.onStateChange=b.onStateChange||r,this.time=b.getTime||Date.now}return bm(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(c){var a=this.props;if(this.props=c,!a||this._shouldIgnoreViewportChange(a,c))return!1;if(this._isTransitionEnabled(c)){var d=Object.assign({},a),b=Object.assign({},c);if(this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this.state.interruption===E.SNAP_TO_END?Object.assign(d,this.state.endProps):Object.assign(d,this.state.propsInTransition),this.state.interruption===E.UPDATE)){var f,g,h,e=this.time(),i=(e-this.state.startTime)/this.state.duration;b.transitionDuration=this.state.duration-(e-this.state.startTime),b.transitionEasing=(h=(f=this.state.easing)(g=i),function(a){return 1/(1-h)*(f(a*(1-g)+g)-h)}),b.transitionInterpolator=d.transitionInterpolator}return b.onTransitionStart(),this._triggerTransition(d,b),!0}return this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(b,a){return!b||(this._isTransitionInProgress()?this.state.interruption===E.IGNORE||this._isUpdateDueToCurrentTransition(a):!this._isTransitionEnabled(a)||a.transitionInterpolator.arePropsEqual(b,a))}},{key:"_triggerTransition",value:function(b,a){bA(this._isTransitionEnabled(a)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=a.transitionInterpolator,d=c.getDuration?c.getDuration(b,a):a.transitionDuration;if(0!==d){var e=a.transitionInterpolator.initializeProps(b,a),f={inTransition:!0,isZooming:b.zoom!==a.zoom,isPanning:b.longitude!==a.longitude||b.latitude!==a.latitude,isRotating:b.bearing!==a.bearing||b.pitch!==a.pitch};this.state={duration:d,easing:a.transitionEasing,interpolator:a.transitionInterpolator,interruption:a.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var d=this.time(),a=this.state,e=a.startTime,f=a.duration,g=a.easing,h=a.interpolator,i=a.startProps,j=a.endProps,c=!1,b=(d-e)/f;b>=1&&(b=1,c=!0),b=g(b);var k=h.interpolateProps(i,j,b),l=new bE(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),a}();g(F,"defaultProps",V);var W=b(840),k=b.n(W);const cb={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(b,c){for(let a=0;ab.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(k().PointerEventInput),k().MouseInput.prototype.handler=function(a){let b=cb[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const cc=k().Manager;var e=k();const cd=e?[[e.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[e.Rotate,{enable:!1}],[e.Pinch,{enable:!1}],[e.Swipe,{enable:!1}],[e.Pan,{threshold:0,enable:!1}],[e.Press,{enable:!1}],[e.Tap,{event:"doubletap",taps:2,enable:!1}],[e.Tap,{event:"anytap",enable:!1}],[e.Tap,{enable:!1}]]:null,ce={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},cf={doubletap:["tap"]},cg={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},s={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},ch={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},ci={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},X="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",G="undefined"!=typeof window?window:b.g;void 0!==b.g&&b.g;let Y=!1;try{const l={get passive(){return Y=!0,!0}};G.addEventListener("test",l,l),G.removeEventListener("test",l,l)}catch(cj){}const ck=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:cl}=s,cm="wheel";class cn{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=cl.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent,!!Y&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cm&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(ck&&b.deltaMode===G.WheelEvent.DOM_DELTA_PIXEL&&(a/=G.devicePixelRatio),b.deltaMode===G.WheelEvent.DOM_DELTA_LINE&&(a*=40));const c={x:b.clientX,y:b.clientY};0!==a&&a%4.000244140625==0&&(a=Math.floor(a/4.000244140625)),b.shiftKey&&a&&(a*=.25),this._onWheel(b,-a,c)}_onWheel(a,b,c){this.callback({type:cm,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:co}=s,cp="pointermove",cq="pointerover",cr="pointerout",cs="pointerleave";class ct{constructor(b,c,a={}){this.element=b,this.callback=c,this.pressed=!1,this.options=Object.assign({enable:!0},a),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=co.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cp&&(this.enableMoveEvent=b),a===cq&&(this.enableOverEvent=b),a===cr&&(this.enableOutEvent=b),a===cs&&(this.enableLeaveEvent=b)}handleEvent(a){this.handleOverEvent(a),this.handleOutEvent(a),this.handleLeaveEvent(a),this.handleMoveEvent(a)}handleOverEvent(a){this.enableOverEvent&&"mouseover"===a.type&&this.callback({type:cq,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:cr,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:cs,srcEvent:a,pointerType:"mouse",target:a.target})}handleMoveEvent(a){if(this.enableMoveEvent)switch(a.type){case"mousedown":a.button>=0&&(this.pressed=!0);break;case"mousemove":0===a.which&&(this.pressed=!1),this.pressed||this.callback({type:cp,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1;break;default:}}}const{KEY_EVENTS:cu}=s,cv="keydown",cw="keyup";class cx{constructor(a,c,b={}){this.element=a,this.callback=c,this.options=Object.assign({enable:!0},b),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=cu.concat(b.events||[]),this.handleEvent=this.handleEvent.bind(this),a.tabIndex=b.tabIndex||0,a.style.outline="none",this.events.forEach(b=>a.addEventListener(b,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cv&&(this.enableDownEvent=b),a===cw&&(this.enableUpEvent=b)}handleEvent(a){const b=a.target||a.srcElement;("INPUT"!==b.tagName||"text"!==b.type)&&"TEXTAREA"!==b.tagName&&(this.enableDownEvent&&"keydown"===a.type&&this.callback({type:cv,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:cw,srcEvent:a,key:a.key,target:a.target}))}}const cy="contextmenu";class cz{constructor(a,b,c={}){this.element=a,this.callback=b,this.options=Object.assign({enable:!0},c),this.handleEvent=this.handleEvent.bind(this),a.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(a,b){a===cy&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:cy,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const cA={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cB={srcElement:"root",priority:0};class cC{constructor(a){this.eventManager=a,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(f,g,a,h=!1,i=!1){const{handlers:j,handlersByElement:e}=this;a&&("object"!=typeof a||a.addEventListener)&&(a={srcElement:a}),a=a?Object.assign({},cB,a):cB;let b=e.get(a.srcElement);b||(b=[],e.set(a.srcElement,b));const c={type:f,handler:g,srcElement:a.srcElement,priority:a.priority};h&&(c.once=!0),i&&(c.passive=!0),j.push(c),this._active=this._active||!c.passive;let d=b.length-1;for(;d>=0&&!(b[d].priority>=c.priority);)d--;b.splice(d+1,0,c)}remove(f,g){const{handlers:b,handlersByElement:e}=this;for(let c=b.length-1;c>=0;c--){const a=b[c];if(a.type===f&&a.handler===g){b.splice(c,1);const d=e.get(a.srcElement);d.splice(d.indexOf(a),1),0===d.length&&e.delete(a.srcElement)}}this._active=b.some(a=>!a.passive)}handleEvent(c){if(this.isEmpty())return;const b=this._normalizeEvent(c);let a=c.srcEvent.target;for(;a&&a!==b.rootElement;){if(this._emit(b,a),b.handled)return;a=a.parentNode}this._emit(b,"root")}_emit(e,f){const a=this.handlersByElement.get(f);if(a){let g=!1;const h=()=>{e.handled=!0},i=()=>{e.handled=!0,g=!0},c=[];for(let b=0;b{const b=this.manager.get(a);b&&ce[a].forEach(a=>{b.recognizeWith(a)})}),b.recognizerOptions){const e=this.manager.get(d);if(e){const f=b.recognizerOptions[d];delete f.enable,e.set(f)}}for(const[h,c]of(this.wheelInput=new cn(a,this._onOtherEvent,{enable:!1}),this.moveInput=new ct(a,this._onOtherEvent,{enable:!1}),this.keyInput=new cx(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new cz(a,this._onOtherEvent,{enable:!1}),this.events))c.isEmpty()||(this._toggleRecognizer(c.recognizerName,!0),this.manager.on(h,c.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(a,b,c){this._addEventHandler(a,b,c,!1)}once(a,b,c){this._addEventHandler(a,b,c,!0)}watch(a,b,c){this._addEventHandler(a,b,c,!1,!0)}off(a,b){this._removeEventHandler(a,b)}_toggleRecognizer(a,b){const{manager:d}=this;if(!d)return;const c=d.get(a);if(c&&c.options.enable!==b){c.set({enable:b});const e=cf[a];e&&!this.options.recognizers&&e.forEach(e=>{const f=d.get(e);b?(f.requireFailure(a),c.dropRequireFailure(e)):f.dropRequireFailure(a)})}this.wheelInput.enableEventType(a,b),this.moveInput.enableEventType(a,b),this.keyInput.enableEventType(a,b),this.contextmenuInput.enableEventType(a,b)}_addEventHandler(b,e,d,f,g){if("string"!=typeof b){for(const h in d=e,b)this._addEventHandler(h,b[h],d,f,g);return}const{manager:i,events:j}=this,c=ci[b]||b;let a=j.get(c);!a&&(a=new cC(this),j.set(c,a),a.recognizerName=ch[c]||c,i&&i.on(c,a.handleEvent)),a.add(b,e,d,f,g),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(a,h){if("string"!=typeof a){for(const c in a)this._removeEventHandler(c,a[c]);return}const{events:d}=this,i=ci[a]||a,b=d.get(i);if(b&&(b.remove(a,h),b.isEmpty())){const{recognizerName:e}=b;let f=!1;for(const g of d.values())if(g.recognizerName===e&&!g.isEmpty()){f=!0;break}f||this._toggleRecognizer(e,!1)}}_onBasicInput(a){const{srcEvent:c}=a,b=cg[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function cE(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function cF(c){for(var a=1;a0),e=d&&!this.state.isHovering,h=!d&&this.state.isHovering;(c||e)&&(a.features=b,c&&c(a)),e&&cO.call(this,"onMouseEnter",a),h&&cO.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function cS(b){var c=this.props,d=c.onClick,f=c.onNativeClick,g=c.onDblClick,h=c.doubleClickZoom,a=[],e=g||h;switch(b.type){case"anyclick":a.push(f),e||a.push(d);break;case"click":e&&a.push(d);break;default:}(a=a.filter(Boolean)).length&&((b=cM.call(this,b)).features=cN.call(this,b.point),a.forEach(function(a){return a(b)}))}var m=(0,c.forwardRef)(function(b,h){var i,t,f=(0,c.useContext)(bJ),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new cD(null,{touchAction:b.touchAction,recognizerOptions:b.eventRecognizerOptions})},[]),g=(0,c.useRef)(null),e=(0,c.useRef)(null),a=(0,c.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;a.props=b,a.map=e.current&&e.current.getMap(),a.setState=function(c){a.state=cL(cL({},a.state),c),g.current.style.cursor=b.getCursor(a.state)};var j=!0,k=function(b,c,d){if(j){i=[b,c,d];return}var e=a.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(b,"position",{get:function(){return[0,0,bL(a.map,b)]}}),f&&f({viewState:b,interactionState:c,oldViewState:d}),g&&g(b,c,d)};(0,c.useImperativeHandle)(h,function(){var a;return{getMap:(a=e).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var d=(0,c.useMemo)(function(){return cL(cL({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||bP(a),a.viewport=d.viewport;var w=function(b){var c=b.isDragging,d=void 0!==c&&c;if(d!==a.state.isDragging&&a.setState({isDragging:d}),j){t=b;return}var e=a.props.onInteractionStateChange;e&&e(b)},l=function(){a.width&&a.height&&u.setOptions(cL(cL(cL({},a.props),a.props.viewState),{},{isInteractive:Boolean(a.props.onViewStateChange||a.props.onViewportChange),onViewportChange:k,onStateChange:w,eventManager:v,width:a.width,height:a.height}))},m=function(b){var c=b.width,d=b.height;a.width=c,a.height=d,l(),a.props.onResize({width:c,height:d})};(0,c.useEffect)(function(){return v.setElement(g.current),v.on({pointerdown:cP.bind(a),pointermove:cR.bind(a),pointerup:cQ.bind(a),pointerleave:cO.bind(a,"onMouseOut"),click:cS.bind(a),anyclick:cS.bind(a),dblclick:cO.bind(a,"onDblClick"),wheel:cO.bind(a,"onWheel"),contextmenu:cO.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),bK(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return ax(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ay(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}t&&w(t)}),l();var n=b.width,o=b.height,p=b.style,r=b.getCursor,s=(0,c.useMemo)(function(){return cL(cL({position:"relative"},p),{},{width:n,height:o,cursor:r(a.state)})},[p,n,o,r,a.state]);return i&&a._child||(a._child=c.createElement(bI,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,aw({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var cT=m;function cU(b,a){if(b===a)return!0;if(!b||!a)return!1;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!==a.length)return!1;for(var c=0;c prop: ".concat(e))}}(d,a,f.current):d=function(a,c,d){if(a.style&&a.style._loaded){var b=function(c){for(var a=1;a=0||(d[a]=c[a]);return d}(a,d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(a,b)&&(e[b]=a[b])}return e}(d,["layout","paint","filter","minzoom","maxzoom","beforeId"]);if(p!==a.beforeId&&b.moveLayer(c,p),e!==a.layout){var q=a.layout||{};for(var g in e)cU(e[g],q[g])||b.setLayoutProperty(c,g,e[g]);for(var r in q)e.hasOwnProperty(r)||b.setLayoutProperty(c,r,void 0)}if(f!==a.paint){var s=a.paint||{};for(var h in f)cU(f[h],s[h])||b.setPaintProperty(c,h,f[h]);for(var t in s)f.hasOwnProperty(t)||b.setPaintProperty(c,t,void 0)}for(var i in cU(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)cU(j[i],a[i])||b.setLayerProperty(c,i,j[i])}(c,d,a,b)}catch(e){console.warn(e)}}(a,d,b,e.current):function(a,d,b){if(a.style&&a.style._loaded){var c=cY(cY({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ab;var f={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},d={captureScroll:a.bool,captureDrag:a.bool,captureClick:a.bool,captureDoubleClick:a.bool,capturePointerMove:a.bool};function c$(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(bJ),e=(0,c.useRef)(null),f=(0,c.useRef)({props:d,state:{},context:a,containerRef:e}),b=f.current;return b.props=d,b.context=a,(0,c.useEffect)(function(){return function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(c){var b=a.props;b.captureScroll&&c.stopPropagation(),b.onScroll&&b.onScroll(c,a)},panstart:function(c){var b=a.props;b.captureDrag&&c.stopPropagation(),b.onDragStart&&b.onDragStart(c,a)},anyclick:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onNativeClick&&b.onNativeClick(c,a)},click:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onClick&&b.onClick(c,a)},dblclick:function(c){var b=a.props;b.captureDoubleClick&&c.stopPropagation(),b.onDoubleClick&&b.onDoubleClick(c,a)},pointermove:function(c){var b=a.props;b.capturePointerMove&&c.stopPropagation(),b.onPointerMove&&b.onPointerMove(c,a)}};return c.watch(d,b),function(){c.off(d)}}}(b)},[a.eventManager]),b}function c_(b){var a=b.instance,c=c$(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){bV(a,b);var d,e,f=(d=a,e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(d);if(e){var c=bY(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var b;bk(this,a);for(var e=arguments.length,h=new Array(e),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var c="x"===d?a.offsetWidth:a.offsetHeight;return c6(b/100*c)/c*100};function c8(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}var ae=Object.assign({},ac,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),af=Object.assign({},ad,{className:""});function t(b){var d,j,e,k,f,l,m,a,h=(d=b,e=(j=aA((0,c.useState)(null),2))[0],k=j[1],f=aA((0,c.useState)(null),2),l=f[0],m=f[1],a=c$(c1(c1({},d),{},{onDragStart:c4})),a.callbacks=d,a.state.dragPos=e,a.state.setDragPos=k,a.state.dragOffset=l,a.state.setDragOffset=m,(0,c.useEffect)(function(){return function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return function(b,a){var h=a.props,c=a.callbacks,d=a.state,i=a.context;b.stopPropagation();var e=c2(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=c3(e,f,h,i),c.onDrag(g)}}(b,a)},panend:function(b){return function(c,a){var h=a.props,d=a.callbacks,b=a.state,i=a.context;c.stopPropagation();var e=b.dragPos,f=b.dragOffset;if(b.setDragPos(null),b.setDragOffset(null),d.onDragEnd&&e&&f){var g=Object.assign({},c);g.lngLat=c3(e,f,h,i),d.onDragEnd(g)}}(b,a)},pancancel:function(d){var c,b;return c=d,b=a.state,void(c.stopPropagation(),b.setDragPos(null),b.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}}(a)},[a.context.eventManager,Boolean(e)]),a),o=h.state,p=h.containerRef,q=b.children,r=b.className,s=b.draggable,A=b.style,t=o.dragPos,u=function(b){var a=b.props,e=b.state,f=b.context,g=a.longitude,h=a.latitude,j=a.offsetLeft,k=a.offsetTop,c=e.dragPos,d=e.dragOffset,l=f.viewport,m=f.map;if(c&&d)return[c[0]+d[0],c[1]+d[1]];var n=bL(m,{longitude:g,latitude:h}),i=aA(l.project([g,h,n]),2),o=i[0],p=i[1];return[o+=j,p+=k]}(h),n=aA(u,2),v=n[0],w=n[1],x="translate(".concat(c6(v),"px, ").concat(c6(w),"px)"),y=s?t?"grabbing":"grab":"auto",z=(0,c.useMemo)(function(){var a=function(c){for(var a=1;a0){var t=b,u=e;for(b=0;b<=1;b+=.5)k=(i=n-b*h)+h,e=Math.max(0,d-i)+Math.max(0,k-p+d),e0){var w=a,x=f;for(a=0;a<=1;a+=v)l=(j=m-a*g)+g,f=Math.max(0,d-j)+Math.max(0,l-o+d),f1||h< -1||f<0||f>p.width||g<0||g>p.height?i.display="none":i.zIndex=Math.floor((1-h)/2*1e5)),i),S=(0,c.useCallback)(function(b){t.props.onClose();var a=t.context.eventManager;a&&a.once("click",function(a){return a.stopPropagation()},b.target)},[]);return c.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(L," ").concat(N),style:R,ref:u},c.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:O}}),c.createElement("div",{key:"content",ref:j,className:"mapboxgl-popup-content"},P&&c.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:S},"\xd7"),Q))}function da(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}u.propTypes=ag,u.defaultProps=ah,c.memo(u);var ai=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string)])}),aj=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=c$(a),d=b.context,i=b.containerRef,j=(0,c.useRef)(null),e=aA((0,c.useState)(!1),2),f=e[0],m=e[1];(0,c.useEffect)(function(){var h,e,c,f,g,b;return d.map&&(h=(e={customAttribution:a.customAttribution},c=d.map,f=i.current,g=j.current,(b=new(A()).AttributionControl(e))._map=c,b._container=f,b._innerContainer=g,b._updateAttributions(),b._updateEditLink(),c.on("styledata",b._updateData),c.on("sourcedata",b._updateData),b)),function(){var a;return h&&void((a=h)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[d.map]);var h=void 0===a.compact?d.viewport.width<=640:a.compact;(0,c.useEffect)(function(){!h&&f&&m(!1)},[h]);var k=(0,c.useCallback)(function(){return m(function(a){return!a})},[]),l=(0,c.useMemo)(function(){return function(c){for(var a=1;ac)return 1}return 0}(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),f=b.viewport.bearing,d={transform:"rotate(".concat(-f,"deg)")},2===e?c.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:d}):c.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:d})))))}function di(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}y.propTypes=ao,y.defaultProps=ap,c.memo(y);var aq=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ar=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=c$(a),f=d.context,h=d.containerRef,e=aA((0,c.useState)(null),2),b=e[0],j=e[1];(0,c.useEffect)(function(){if(f.map){var a=new(A()).ScaleControl;a._map=f.map,a._container=h.current,j(a)}},[f.map]),b&&(b.options=a,b._onMove());var i=(0,c.useMemo)(function(){return function(c){for(var a=1;a\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=an(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=ao(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=as(j,k),a.distance=ar(j,k),al(b,a),a.offsetDirection=aq(a.deltaX,a.deltaY);var d=ap(a.deltaTime,a.deltaX,a.deltaY);a.overallVelocityX=d.x,a.overallVelocityY=d.y,a.overallVelocity=T(d.x)>T(d.y)?d.x:d.y,a.scale=c?au(c.pointers,e):1,a.rotation=c?at(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,am(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function al(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function am(h,a){var d,e,f,g,b=h.lastInterval||a,i=a.timeStamp-b.timeStamp;if(8!=a.eventType&&(i>25||l===b.velocity)){var j=a.deltaX-b.deltaX,k=a.deltaY-b.deltaY,c=ap(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=aq(j,k),h.lastInterval=a}else d=b.velocity,e=b.velocityX,f=b.velocityY,g=b.direction;a.velocity=d,a.velocityX=e,a.velocityY=f,a.direction=g}function an(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ar(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function as(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function at(a,b){return as(b[1],b[0],ai)+as(a[1],a[0],ai)}function au(a,b){return ar(b[0],b[1],ai)/ar(a[0],a[1],ai)}f.prototype={handler:function(){},init:function(){this.evEl&&H(this.element,this.evEl,this.domHandler),this.evTarget&&H(this.target,this.evTarget,this.domHandler),this.evWin&&H(ae(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&I(this.element,this.evEl,this.domHandler),this.evTarget&&I(this.target,this.evTarget,this.domHandler),this.evWin&&I(ae(this.element),this.evWin,this.domHandler)}};var av={mousedown:1,mousemove:2,mouseup:4};function u(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,f.apply(this,arguments)}e(u,f,{handler:function(a){var b=av[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:L,srcEvent:a}))}});var aw={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},ax={2:K,3:"pen",4:L,5:"kinect"},M="pointerdown",N="pointermove pointerup pointercancel";function v(){this.evEl=M,this.evWin=N,f.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}g.MSPointerEvent&&!g.PointerEvent&&(M="MSPointerDown",N="MSPointerMove MSPointerUp MSPointerCancel"),e(v,f,{handler:function(a){var b=this.store,e=!1,d=aw[a.type.toLowerCase().replace("ms","")],f=ax[a.pointerType]||a.pointerType,c=aa(b,a.pointerId,"pointerId");1&d&&(0===a.button||f==K)?c<0&&(b.push(a),c=b.length-1):12&d&&(e=!0),!(c<0)&&(b[c]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),e&&b.splice(c,1))}});var ay={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function w(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,f.apply(this,arguments)}function az(b,d){var a=ab(b.touches),c=ab(b.changedTouches);return 12&d&&(a=ac(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ay[c.type];if(1===a&&(this.started=!0),this.started){var b=az.call(this,c,a);12&a&&b[0].length-b[1].length==0&&(this.started=!1),this.callback(this.manager,a,{pointers:b[0],changedPointers:b[1],pointerType:K,srcEvent:c})}}});var aA={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function x(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},f.apply(this,arguments)}function aB(h,g){var b=ab(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ab(h.changedTouches),f=[],i=this.target;if(d=b.filter(function(a){return Z(a.target,i)}),1===g)for(a=0;a -1&&d.splice(a,1)},2500)}}function aE(b){for(var d=b.srcEvent.clientX,e=b.srcEvent.clientY,a=0;a -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(d){var c=this,a=this.state;function b(a){c.manager.emit(a,d)}a<8&&b(c.options.event+aM(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+aM(a))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ac.threshold&&b&c.direction},attrTest:function(a){return h.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=aN(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),e(p,h,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),e(q,i,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[aG]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=V(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=U(),this.manager.emit(this.options.event,this._input)))}}),e(r,h,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),e(s,h,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return o.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&T(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=aN(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),e(j,i,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[aH]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var a=1;ac.length)&&(a=c.length);for(var b=0,d=new Array(a);bc?c:a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),bc=new h(4),h!=Float32Array&&(bc[0]=0,bc[1]=0,bc[2]=0,bc[3]=0);const aF=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function aG(e,f,g){var h=f[0],i=f[1],j=f[2],k=f[3],l=f[4],m=f[5],n=f[6],o=f[7],p=f[8],q=f[9],r=f[10],s=f[11],t=f[12],u=f[13],v=f[14],w=f[15],a=g[0],b=g[1],c=g[2],d=g[3];return e[0]=a*h+b*l+c*p+d*t,e[1]=a*i+b*m+c*q+d*u,e[2]=a*j+b*n+c*r+d*v,e[3]=a*k+b*o+c*s+d*w,a=g[4],b=g[5],c=g[6],d=g[7],e[4]=a*h+b*l+c*p+d*t,e[5]=a*i+b*m+c*q+d*u,e[6]=a*j+b*n+c*r+d*v,e[7]=a*k+b*o+c*s+d*w,a=g[8],b=g[9],c=g[10],d=g[11],e[8]=a*h+b*l+c*p+d*t,e[9]=a*i+b*m+c*q+d*u,e[10]=a*j+b*n+c*r+d*v,e[11]=a*k+b*o+c*s+d*w,a=g[12],b=g[13],c=g[14],d=g[15],e[12]=a*h+b*l+c*p+d*t,e[13]=a*i+b*m+c*q+d*u,e[14]=a*j+b*n+c*r+d*v,e[15]=a*k+b*o+c*s+d*w,e}function aH(b,a,f){var g,h,i,j,k,l,m,n,o,p,q,r,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],b[0]=g,b[1]=h,b[2]=i,b[3]=j,b[4]=k,b[5]=l,b[6]=m,b[7]=n,b[8]=o,b[9]=p,b[10]=q,b[11]=r,b[12]=g*c+k*d+o*e+a[12],b[13]=h*c+l*d+p*e+a[13],b[14]=i*c+m*d+q*e+a[14],b[15]=j*c+n*d+r*e+a[15]),b}function aI(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function aJ(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function aK(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function aL(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function aM(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}bd=new h(2),h!=Float32Array&&(bd[0]=0,bd[1]=0),be=new h(3),h!=Float32Array&&(be[0]=0,be[1]=0,be[2]=0);const n=Math.PI,aN=n/4,aO=n/180,aP=180/n;function aQ(a){return Math.pow(2,a)}function aR([b,a]){return aM(Number.isFinite(b)),aM(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*aO+n)/(2*n),512*(n+Math.log(Math.tan(aN+.5*(a*aO))))/(2*n)]}function aS([a,b]){return[(a/512*(2*n)-n)*aP,2*(Math.atan(Math.exp(b/512*(2*n)-n))-aN)*aP]}function aT(a){return 2*Math.atan(.5/a)*aP}function aU(a){return .5/Math.tan(.5*a*aO)}function aV(i,c,j=0){const[a,b,e]=i;if(aM(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=aC(c,[a,b,e,1]);return k}const f=aC(c,[a,b,0,1]),g=aC(c,[a,b,1,1]),d=f[2],h=g[2];return aL([],f,g,d===h?0:((j||0)-d)/(h-d))}const aW=Math.PI/180;function aX(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=aC(e,[c,0,1,1]),f=aC(e,[c,a.height,1,1]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=aL([],b,f,i),g=aS(j);return g[2]=d,g}class aY{constructor({width:f,height:c,latitude:l=0,longitude:m=0,zoom:p=0,pitch:n=0,bearing:q=0,altitude:a=null,fovy:b=null,position:o=null,nearZMultiplier:t=.02,farZMultiplier:u=1.01}={width:1,height:1}){f=f||1,c=c||1,null===b&&null===a?b=aT(a=1.5):null===b?b=aT(a):null===a&&(a=aU(b));const r=aQ(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){aM(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*aO),e=1.4222222222222223/d,a=12790407194604047e-21/d;if(b.unitsPerMeter=[a,a,a],b.metersPerUnit=[1/a,1/a,1/a],b.unitsPerDegree=[1.4222222222222223,e,a],b.degreesPerUnit=[.703125,1/e,1/a],j){const f=aO*Math.tan(c*aO)/d,k=1.4222222222222223*f/2,g=12790407194604047e-21*f,h=g/e*a;b.unitsPerDegree2=[0,k,g],b.unitsPerMeter2=[h,0,h]}return b}({longitude:m,latitude:l}),d=aR([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,k=(e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],e),i[0]=j[0]+k[0],i[1]=j[1]+k[1],i[2]=j[2]+k[2]}this.projectionMatrix=function({width:h,height:i,pitch:j,altitude:k,fovy:l,nearZMultiplier:m,farZMultiplier:n}){var a,f,g,c,b,d,e;const{fov:o,aspect:p,near:q,far:r}=function({width:f,height:g,fovy:a=aT(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=aT(d));const b=.5*a*aO,c=aU(a),e=h*aO;return{fov:2*b,aspect:f/g,focalDistance:c,near:i,far:(Math.sin(e)*(Math.sin(b)*c/Math.sin(Math.min(Math.max(Math.PI/2-e-b,.01),Math.PI-.01)))+c)*j}}({width:h,height:i,altitude:k,fovy:l,pitch:j,nearZMultiplier:m,farZMultiplier:n}),s=(a=[],f=o,g=p,c=q,b=r,e=1/Math.tan(f/2),a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(d=1/(c-b),a[10]=(b+c)*d,a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a);return s}({width:f,height:c,pitch:n,fovy:b,nearZMultiplier:t,farZMultiplier:u}),this.viewMatrix=function({height:F,pitch:G,bearing:H,altitude:I,scale:l,center:E=null}){var a,b,m,f,g,n,o,p,q,r,s,t,u,c,d,v,h,i,w,x,y,z,A,B,C,D,j,k;const e=aB();return aH(e,e,[0,0,-I]),a=e,b=e,m=-G*aO,f=Math.sin(m),g=Math.cos(m),n=b[4],o=b[5],p=b[6],q=b[7],r=b[8],s=b[9],t=b[10],u=b[11],b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=n*g+r*f,a[5]=o*g+s*f,a[6]=p*g+t*f,a[7]=q*g+u*f,a[8]=r*g-n*f,a[9]=s*g-o*f,a[10]=t*g-p*f,a[11]=u*g-q*f,c=e,d=e,v=H*aO,h=Math.sin(v),i=Math.cos(v),w=d[0],x=d[1],y=d[2],z=d[3],A=d[4],B=d[5],C=d[6],D=d[7],d!==c&&(c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15]),c[0]=w*i+A*h,c[1]=x*i+B*h,c[2]=y*i+C*h,c[3]=z*i+D*h,c[4]=A*i-w*h,c[5]=B*i-x*h,c[6]=C*i-y*h,c[7]=D*i-z*h,aI(e,e,[l/=F,l,l]),E&&aH(e,e,(j=[],k=E,j[0]=-k[0],j[1]=-k[1],j[2]=-k[2],j)),e}({height:c,scale:r,center:d,pitch:n,bearing:q,altitude:a}),this.width=f,this.height=c,this.scale=r,this.latitude=l,this.longitude=m,this.zoom=p,this.pitch=n,this.bearing=q,this.altitude=a,this.fovy=b,this.center=d,this.meterOffset=o||[0,0,0],this.distanceScales=s,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,a;const{width:I,height:J,projectionMatrix:K,viewMatrix:L}=this,G=aB();aG(G,G,K),aG(G,G,L),this.viewProjectionMatrix=G;const d=aB();aI(d,d,[I/2,-J/2,1]),aH(d,d,[1,-1,0]),aG(d,d,G);const H=(b=aB(),e=(c=d)[0],f=c[1],g=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=c[8],n=c[9],o=c[10],p=c[11],q=c[12],r=c[13],s=c[14],t=c[15],u=e*j-f*i,v=e*k-g*i,w=e*l-h*i,x=f*k-g*j,y=f*l-h*j,z=g*l-h*k,A=m*r-n*q,B=m*s-o*q,C=m*t-p*q,D=n*s-o*r,E=n*t-p*r,F=o*t-p*s,a=u*F-v*E+w*D+x*C-y*B+z*A,a?(a=1/a,b[0]=(j*F-k*E+l*D)*a,b[1]=(g*E-f*F-h*D)*a,b[2]=(r*z-s*y+t*x)*a,b[3]=(o*y-n*z-p*x)*a,b[4]=(k*C-i*F-l*B)*a,b[5]=(e*F-g*C+h*B)*a,b[6]=(s*w-q*z-t*v)*a,b[7]=(m*z-o*w+p*v)*a,b[8]=(i*E-j*C+l*A)*a,b[9]=(f*C-e*E-h*A)*a,b[10]=(q*y-r*w+t*u)*a,b[11]=(n*w-m*y-p*u)*a,b[12]=(j*B-i*D-k*A)*a,b[13]=(e*D-f*B+g*A)*a,b[14]=(r*v-q*x-s*u)*a,b[15]=(m*x-n*v+o*u)*a,b):null);if(!H)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=H}equals(a){return a instanceof aY&&a.width===this.width&&a.height===this.height&&aJ(a.projectionMatrix,this.projectionMatrix)&&aJ(a.viewMatrix,this.viewMatrix)}project(a,{topLeft:f=!0}={}){const g=this.projectPosition(a),b=function(d,e){const[a,b,c=0]=d;return aM(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),aC(e,[a,b,c,1])}(g,this.pixelProjectionMatrix),[c,d]=b,e=f?d:this.height-d;return 2===a.length?[c,e]:[c,e,b[2]]}unproject(f,{topLeft:g=!0,targetZ:a}={}){const[h,d,e]=f,i=g?d:this.height-d,j=a&&a*this.distanceScales.unitsPerMeter[2],k=aV([h,i,e],this.pixelUnprojectionMatrix,j),[b,c,l]=this.unprojectPosition(k);return Number.isFinite(e)?[b,c,l]:Number.isFinite(a)?[b,c,a]:[b,c]}projectPosition(a){const[b,c]=aR(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=aS(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return aR(a)}unprojectFlat(a){return aS(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=aV(d,this.pixelUnprojectionMatrix),f=aR(c),g=aK([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=aK([],this.center,g);return aS(h)}getLocationAtPoint({lngLat:a,pos:b}){return this.getMapCenterByLngLatPosition({lngLat:a,pos:b})}fitBounds(c,d={}){const{width:a,height:b}=this,{longitude:e,latitude:f,zoom:g}=function({width:m,height:n,bounds:o,minExtent:f=0,maxZoom:p=24,padding:a=0,offset:g=[0,0]}){const[[q,r],[s,t]]=o;if(Number.isFinite(a)){const b=a;a={top:b,bottom:b,left:b,right:b}}else aM(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=aR([q,aE(t,-85.051129,85.051129)]),d=aR([s,aE(r,-85.051129,85.051129)]),h=[Math.max(Math.abs(d[0]-c[0]),f),Math.max(Math.abs(d[1]-c[1]),f)],e=[m-a.left-a.right-2*Math.abs(g[0]),n-a.top-a.bottom-2*Math.abs(g[1])];aM(e[0]>0&&e[1]>0);const i=e[0]/h[0],j=e[1]/h[1],u=(a.right-a.left)/2/i,v=(a.bottom-a.top)/2/j,w=[(d[0]+c[0])/2+u,(d[1]+c[1])/2+v],k=aS(w),l=Math.min(p,aF(Math.abs(Math.min(i,j))));return aM(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new aY({width:a,height:b,longitude:e,latitude:f,zoom:g})}getBounds(b){const a=this.getBoundingRegion(b),c=Math.min(...a.map(a=>a[0])),d=Math.max(...a.map(a=>a[0])),e=Math.min(...a.map(a=>a[1])),f=Math.max(...a.map(a=>a[1]));return[[c,e],[d,f]]}getBoundingRegion(a={}){return function(a,d=0){const{width:e,height:h,unproject:b}=a,c={targetZ:d},i=b([0,h],c),j=b([e,h],c);let f,g;const k=a.fovy?.5*a.fovy*aW:Math.atan(.5/a.altitude),l=(90-a.pitch)*aW;return k>l-.01?(f=aX(a,0,d),g=aX(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const aZ=["longitude","latitude","zoom"],a$={curve:1.414,speed:1.2};function a_(d,h,i){var f,j,k,o,p,q;i=Object.assign({},a$,i);const g=i.curve,l=d.zoom,w=[d.longitude,d.latitude],x=aQ(l),y=h.zoom,z=[h.longitude,h.latitude],A=aQ(y-l),r=aR(w),B=aR(z),s=(f=[],j=B,k=r,f[0]=j[0]-k[0],f[1]=j[1]-k[1],f),a=Math.max(d.width,d.height),e=a/A,t=(p=(o=s)[0],q=o[1],Math.hypot(p,q)*x),c=Math.max(t,.01),b=g*g,m=(e*e-a*a+b*b*c*c)/(2*a*b*c),n=(e*e-a*a-b*b*c*c)/(2*e*b*c),u=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(n*n+1)-n);return{startZoom:l,startCenterXY:r,uDelta:s,w0:a,u1:t,S:(v-u)/g,rho:g,rho2:b,r0:u,r1:v}}var N=function(){if("undefined"!=typeof Map)return Map;function a(a,c){var b=-1;return a.some(function(a,d){return a[0]===c&&(b=d,!0)}),b}return function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(c){var d=a(this.__entries__,c),b=this.__entries__[d];return b&&b[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(d){var b=this.__entries__,c=a(b,d);~c&&b.splice(c,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(e,a){void 0===a&&(a=null);for(var b=0,c=this.__entries__;b0},a.prototype.connect_=function(){a0&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),a3?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){a0&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(b){var a=b.propertyName,c=void 0===a?"":a;a2.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null,a}(),a5=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),bi="undefined"!=typeof WeakMap?new WeakMap:new N,O=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=a4.getInstance(),d=new bh(b,c,this);bi.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=bi.get(this))[a].apply(b,arguments)}});var bj=void 0!==o.ResizeObserver?o.ResizeObserver:O;function bk(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function bl(d,c){for(var b=0;b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function bq(a,c){if(a){if("string"==typeof a)return br(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return br(a,c)}}function br(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b1&& void 0!==arguments[1]?arguments[1]:"component";b.debug&&a.checkPropTypes(Q,b,"prop",c)}var i=function(){function a(b){var c=this;if(bk(this,a),g(this,"props",R),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return bm(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var d=this._map.getContainer(),c=b.container;for(c.classList.add("mapboxgl-map");d.childNodes.length>0;)c.appendChild(d.childNodes[0]);this._map._container=c,a.savedMap=null,b.mapStyle&&this._map.setStyle(bt(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var d=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=d,b.gl}}var c={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:bt(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(c.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},c,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var d=this;bv(a=Object.assign({},R,a),"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||R.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var b=a.container;Object.defineProperty(b,"offsetWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"clientWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"offsetHeight",{configurable:!0,get:function(){return d.height}}),Object.defineProperty(b,"clientHeight",{configurable:!0,get:function(){return d.height}});var c=this._map.getCanvas();c&&(c.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(b,a){if(this._map){bv(a=Object.assign({},this.props,a),"Mapbox");var c=this._updateMapViewport(b,a),d=this._updateMapSize(b,a);this._updateMapStyle(b,a),!a.asyncRender&&(c||d)&&this.redraw(),this.props=a}}},{key:"_updateMapStyle",value:function(b,a){b.mapStyle!==a.mapStyle&&this._map.setStyle(bt(a.mapStyle),{diff:!a.preventStyleDiffing})}},{key:"_updateMapSize",value:function(b,a){var c=b.width!==a.width||b.height!==a.height;return c&&(this.width=a.width,this.height=a.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(d,e){var b=this._getViewState(d),a=this._getViewState(e),c=a.latitude!==b.latitude||a.longitude!==b.longitude||a.zoom!==b.zoom||a.pitch!==b.pitch||a.bearing!==b.bearing||a.altitude!==b.altitude;return c&&(this._map.jumpTo(this._viewStateToMapboxProps(a)),a.altitude!==b.altitude&&(this._map.transform.altitude=a.altitude)),c}},{key:"_getViewState",value:function(b){var a=b.viewState||b,f=a.longitude,g=a.latitude,h=a.zoom,c=a.pitch,d=a.bearing,e=a.altitude;return{longitude:f,latitude:g,zoom:h,pitch:void 0===c?0:c,bearing:void 0===d?0:d,altitude:void 0===e?1.5:e}}},{key:"_checkStyleSheet",value:function(){var c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==P)try{var a=P.createElement("div");if(a.className="mapboxgl-map",a.style.display="none",P.body.appendChild(a),!("static"!==window.getComputedStyle(a).position)){var b=P.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("type","text/css"),b.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(c,"/mapbox-gl.css")),P.head.appendChild(b)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}}]),a}();g(i,"initialized",!1),g(i,"propTypes",Q),g(i,"defaultProps",R),g(i,"savedMap",null);var S=b(6158),A=b.n(S);function bw(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function bx(a,b){if(a===b)return!0;if(bw(a)&&bw(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function by(a,b,c){return Math.max(b,Math.min(c,a))}function bz(a,c,b){return bw(a)?a.map(function(a,d){return bz(a,c[d],b)}):b*c+(1-b)*a}function bA(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function bB(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bC(c){for(var a=1;a0,"`scale` must be a positive number");var f=this._state,b=f.startZoom,c=f.startZoomLngLat;Number.isFinite(b)||(b=this._viewportProps.zoom,c=this._unproject(i)||this._unproject(d)),bA(c,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var g=this._calculateNewZoom({scale:e,startZoom:b||0}),j=new aY(Object.assign({},this._viewportProps,{zoom:g})),k=j.getMapCenterByLngLatPosition({lngLat:c,pos:d}),h=aA(k,2),l=h[0],m=h[1];return this._getUpdatedMapState({zoom:g,longitude:l,latitude:m})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=by(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=by(g,f,e),Object.assign(a,function({width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k=0,bearing:c=0}){(b< -180||b>180)&&(b=aD(b+180,360)-180),(c< -180||c>180)&&(c=aD(c+180,360)-180);const f=aF(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=aS([0,g])[1];if(ai&&(a=i)}}return{width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k,bearing:c}}(a)),a}},{key:"_unproject",value:function(a){var b=new aY(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new aY(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var c=a.scale,d=a.startZoom,b=this._viewportProps,e=b.maxZoom,f=b.minZoom;return by(d+Math.log2(c),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(c){var f=c.deltaScaleX,a=c.deltaScaleY,g=c.startBearing,b=c.startPitch;a=by(a,-1,1);var e=this._viewportProps,h=e.minPitch,i=e.maxPitch,d=b;return a>0?d=b+a*(i-b):a<0&&(d=b-a*(h-b)),{pitch:d,bearing:g+180*f}}},{key:"_getRotationParams",value:function(c,d){var h=c[0]-d[0],e=c[1]-d[1],i=c[1],a=d[1],f=this._viewportProps,j=f.width,g=f.height,b=0;return e>0?Math.abs(g-a)>5&&(b=e/(a-g)*1.2):e<0&&a>5&&(b=1-i/a),{deltaScaleX:h/j,deltaScaleY:b=Math.min(1,Math.max(-1,b))}}}]),a}();function bF(a){return a[0].toLowerCase()+a.slice(1)}function bG(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bH(c){for(var a=1;a1&& void 0!==arguments[1]?arguments[1]:{},b=a.current&&a.current.getMap();return b&&b.queryRenderedFeatures(c,d)}}},[]);var p=(0,c.useCallback)(function(b){var a=b.target;a===o.current&&a.scrollTo(0,0)},[]),q=d&&c.createElement(bI,{value:bN(bN({},b),{},{viewport:b.viewport||bP(bN({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:bQ,onScroll:p},a.children)),r=a.className,s=a.width,t=a.height,u=a.style,v=a.visibilityConstraints,w=Object.assign({position:"relative"},u,{width:s,height:t}),x=a.visible&&function(c){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:B;for(var a in b){var d=a.slice(0,3),e=bF(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},bQ,{visibility:x?"inherit":"hidden"});return c.createElement("div",{key:"map-container",ref:h,style:w},c.createElement("div",{key:"map-mapbox",ref:n,style:y,className:r}),q,!l&&!a.disableTokenWarning&&c.createElement(bR,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bS(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(a.s();!(b=a.n()).done;){var c=b.value;if(!bx(d[c],e[c]))return!1}}catch(f){a.e(f)}finally{a.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){bA(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}}]),a}();function bT(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function bU(a,b){return(bU=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function bV(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),a&&bU(b,a)}function bW(a){return(bW="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function bX(b,a){if(a&&("object"===bW(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return bT(b)}function bY(a){return(bY=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var bZ={longitude:1,bearing:1};function b$(a){return Number.isFinite(a)||Array.isArray(a)}function b_(b,c,a){return b in bZ&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function b0(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=b1(a))||c&&a&&"number"==typeof a.length){e&&(a=e);var d=0,b=function(){};return{s:b,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b1(a,c){if(a){if("string"==typeof a)return b2(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b2(a,c)}}function b2(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b8(a,c){if(a){if("string"==typeof a)return b9(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b9(a,c)}}function b9(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,d),g(bT(a=e.call(this)),"propNames",b3),a.props=Object.assign({},b6,b),a}bm(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=b0(b4);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];bA(b$(g)&&b$(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=b_(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=b0(b5);try{for(d.s();!(l=d.n()).done;){var b=l.value,m=h[b]||0,o=i[b]||0;e[b]=m,f[b]=b_(b,m,o)}}catch(p){d.e(p)}finally{d.f()}return{start:e,end:f}}},{key:"interpolateProps",value:function(c,d,e){var f,g=function(h,i,j,r={}){var k,l,m,c,d,e;const a={},{startZoom:s,startCenterXY:t,uDelta:u,w0:v,u1:n,S:w,rho:o,rho2:x,r0:b}=a_(h,i,r);if(n<.01){for(const f of aZ){const y=h[f],z=i[f];a[f]=(k=y,l=z,(m=j)*l+(1-m)*k)}return a}const p=j*w,A=s+aF(1/(Math.cosh(b)/Math.cosh(b+o*p))),g=(c=[],d=u,e=v*((Math.cosh(b)*Math.tanh(b+o*p)-Math.sinh(b))/x)/n,c[0]=d[0]*e,c[1]=d[1]*e,c);aK(g,g,t);const q=aS(g);return a.longitude=q[0],a.latitude=q[1],a.zoom=A,a}(c,d,e,this.props),a=b0(b5);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=bz(c[b],d[b],e)}}catch(h){a.e(h)}finally{a.f()}return g}},{key:"getDuration",value:function(c,b){var a=b.transitionDuration;return"auto"===a&&(a=function(f,g,a={}){a=Object.assign({},a$,a);const{screenSpeed:c,speed:h,maxDuration:d}=a,{S:i,rho:j}=a_(f,g,a),e=1e3*i;let b;return b=Number.isFinite(c)?e/(c/j):e/h,Number.isFinite(d)&&b>d?0:b}(c,b,this.props)),a}}])}(C);var ca=["longitude","latitude","zoom","bearing","pitch"],D=function(b){bV(a,b);var c,d,e=(c=a,d=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(c);if(d){var e=bY(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||ca,b.around&&(c.around=b.around),c}return bm(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new aY(g).unproject(this.around);Object.assign(e,c,{around:new aY(c).project(h),aroundLngLat:h})}var i,b=b7(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];bA(b$(f)&&b$(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=b_(a,f,j)}}catch(k){b.e(k)}finally{b.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(e,a,f){var g,b={},c=b7(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=bz(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var h=aA(new aY(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:bz(e.around,a.around,f)}),2),j=h[0],k=h[1];b.longitude=j,b.latitude=k}return b}}]),a}(C),r=function(){},E={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},V={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new D,transitionInterruption:E.BREAK,onTransitionStart:r,onTransitionInterrupt:r,onTransitionEnd:r},F=function(){function a(){var c=this,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};bk(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){c._animationFrame=requestAnimationFrame(c._onTransitionFrame),c._updateViewport()}),this.props=null,this.onViewportChange=b.onViewportChange||r,this.onStateChange=b.onStateChange||r,this.time=b.getTime||Date.now}return bm(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(c){var a=this.props;if(this.props=c,!a||this._shouldIgnoreViewportChange(a,c))return!1;if(this._isTransitionEnabled(c)){var d=Object.assign({},a),b=Object.assign({},c);if(this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this.state.interruption===E.SNAP_TO_END?Object.assign(d,this.state.endProps):Object.assign(d,this.state.propsInTransition),this.state.interruption===E.UPDATE)){var f,g,h,e=this.time(),i=(e-this.state.startTime)/this.state.duration;b.transitionDuration=this.state.duration-(e-this.state.startTime),b.transitionEasing=(h=(f=this.state.easing)(g=i),function(a){return 1/(1-h)*(f(a*(1-g)+g)-h)}),b.transitionInterpolator=d.transitionInterpolator}return b.onTransitionStart(),this._triggerTransition(d,b),!0}return this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(b,a){return!b||(this._isTransitionInProgress()?this.state.interruption===E.IGNORE||this._isUpdateDueToCurrentTransition(a):!this._isTransitionEnabled(a)||a.transitionInterpolator.arePropsEqual(b,a))}},{key:"_triggerTransition",value:function(b,a){bA(this._isTransitionEnabled(a)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=a.transitionInterpolator,d=c.getDuration?c.getDuration(b,a):a.transitionDuration;if(0!==d){var e=a.transitionInterpolator.initializeProps(b,a),f={inTransition:!0,isZooming:b.zoom!==a.zoom,isPanning:b.longitude!==a.longitude||b.latitude!==a.latitude,isRotating:b.bearing!==a.bearing||b.pitch!==a.pitch};this.state={duration:d,easing:a.transitionEasing,interpolator:a.transitionInterpolator,interruption:a.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var d=this.time(),a=this.state,e=a.startTime,f=a.duration,g=a.easing,h=a.interpolator,i=a.startProps,j=a.endProps,c=!1,b=(d-e)/f;b>=1&&(b=1,c=!0),b=g(b);var k=h.interpolateProps(i,j,b),l=new bE(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),a}();g(F,"defaultProps",V);var W=b(840),k=b.n(W);const cb={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(b,c){for(let a=0;ab.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(k().PointerEventInput),k().MouseInput.prototype.handler=function(a){let b=cb[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const cc=k().Manager;var e=k();const cd=e?[[e.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[e.Rotate,{enable:!1}],[e.Pinch,{enable:!1}],[e.Swipe,{enable:!1}],[e.Pan,{threshold:0,enable:!1}],[e.Press,{enable:!1}],[e.Tap,{event:"doubletap",taps:2,enable:!1}],[e.Tap,{event:"anytap",enable:!1}],[e.Tap,{enable:!1}]]:null,ce={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},cf={doubletap:["tap"]},cg={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},s={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},ch={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},ci={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},X="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",G="undefined"!=typeof window?window:b.g;void 0!==b.g&&b.g;let Y=!1;try{const l={get passive(){return Y=!0,!0}};G.addEventListener("test",l,l),G.removeEventListener("test",l,l)}catch(cj){}const ck=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:cl}=s,cm="wheel";class cn{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=cl.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent,!!Y&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cm&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(ck&&b.deltaMode===G.WheelEvent.DOM_DELTA_PIXEL&&(a/=G.devicePixelRatio),b.deltaMode===G.WheelEvent.DOM_DELTA_LINE&&(a*=40));const c={x:b.clientX,y:b.clientY};0!==a&&a%4.000244140625==0&&(a=Math.floor(a/4.000244140625)),b.shiftKey&&a&&(a*=.25),this._onWheel(b,-a,c)}_onWheel(a,b,c){this.callback({type:cm,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:co}=s,cp="pointermove",cq="pointerover",cr="pointerout",cs="pointerleave";class ct{constructor(b,c,a={}){this.element=b,this.callback=c,this.pressed=!1,this.options=Object.assign({enable:!0},a),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=co.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cp&&(this.enableMoveEvent=b),a===cq&&(this.enableOverEvent=b),a===cr&&(this.enableOutEvent=b),a===cs&&(this.enableLeaveEvent=b)}handleEvent(a){this.handleOverEvent(a),this.handleOutEvent(a),this.handleLeaveEvent(a),this.handleMoveEvent(a)}handleOverEvent(a){this.enableOverEvent&&"mouseover"===a.type&&this.callback({type:cq,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:cr,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:cs,srcEvent:a,pointerType:"mouse",target:a.target})}handleMoveEvent(a){if(this.enableMoveEvent)switch(a.type){case"mousedown":a.button>=0&&(this.pressed=!0);break;case"mousemove":0===a.which&&(this.pressed=!1),this.pressed||this.callback({type:cp,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:cu}=s,cv="keydown",cw="keyup";class cx{constructor(a,c,b={}){this.element=a,this.callback=c,this.options=Object.assign({enable:!0},b),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=cu.concat(b.events||[]),this.handleEvent=this.handleEvent.bind(this),a.tabIndex=b.tabIndex||0,a.style.outline="none",this.events.forEach(b=>a.addEventListener(b,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cv&&(this.enableDownEvent=b),a===cw&&(this.enableUpEvent=b)}handleEvent(a){const b=a.target||a.srcElement;("INPUT"!==b.tagName||"text"!==b.type)&&"TEXTAREA"!==b.tagName&&(this.enableDownEvent&&"keydown"===a.type&&this.callback({type:cv,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:cw,srcEvent:a,key:a.key,target:a.target}))}}const cy="contextmenu";class cz{constructor(a,b,c={}){this.element=a,this.callback=b,this.options=Object.assign({enable:!0},c),this.handleEvent=this.handleEvent.bind(this),a.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(a,b){a===cy&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:cy,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const cA={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cB={srcElement:"root",priority:0};class cC{constructor(a){this.eventManager=a,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(f,g,a,h=!1,i=!1){const{handlers:j,handlersByElement:e}=this;a&&("object"!=typeof a||a.addEventListener)&&(a={srcElement:a}),a=a?Object.assign({},cB,a):cB;let b=e.get(a.srcElement);b||(b=[],e.set(a.srcElement,b));const c={type:f,handler:g,srcElement:a.srcElement,priority:a.priority};h&&(c.once=!0),i&&(c.passive=!0),j.push(c),this._active=this._active||!c.passive;let d=b.length-1;for(;d>=0&&!(b[d].priority>=c.priority);)d--;b.splice(d+1,0,c)}remove(f,g){const{handlers:b,handlersByElement:e}=this;for(let c=b.length-1;c>=0;c--){const a=b[c];if(a.type===f&&a.handler===g){b.splice(c,1);const d=e.get(a.srcElement);d.splice(d.indexOf(a),1),0===d.length&&e.delete(a.srcElement)}}this._active=b.some(a=>!a.passive)}handleEvent(c){if(this.isEmpty())return;const b=this._normalizeEvent(c);let a=c.srcEvent.target;for(;a&&a!==b.rootElement;){if(this._emit(b,a),b.handled)return;a=a.parentNode}this._emit(b,"root")}_emit(e,f){const a=this.handlersByElement.get(f);if(a){let g=!1;const h=()=>{e.handled=!0},i=()=>{e.handled=!0,g=!0},c=[];for(let b=0;b{const b=this.manager.get(a);b&&ce[a].forEach(a=>{b.recognizeWith(a)})}),b.recognizerOptions){const e=this.manager.get(d);if(e){const f=b.recognizerOptions[d];delete f.enable,e.set(f)}}for(const[h,c]of(this.wheelInput=new cn(a,this._onOtherEvent,{enable:!1}),this.moveInput=new ct(a,this._onOtherEvent,{enable:!1}),this.keyInput=new cx(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new cz(a,this._onOtherEvent,{enable:!1}),this.events))c.isEmpty()||(this._toggleRecognizer(c.recognizerName,!0),this.manager.on(h,c.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(a,b,c){this._addEventHandler(a,b,c,!1)}once(a,b,c){this._addEventHandler(a,b,c,!0)}watch(a,b,c){this._addEventHandler(a,b,c,!1,!0)}off(a,b){this._removeEventHandler(a,b)}_toggleRecognizer(a,b){const{manager:d}=this;if(!d)return;const c=d.get(a);if(c&&c.options.enable!==b){c.set({enable:b});const e=cf[a];e&&!this.options.recognizers&&e.forEach(e=>{const f=d.get(e);b?(f.requireFailure(a),c.dropRequireFailure(e)):f.dropRequireFailure(a)})}this.wheelInput.enableEventType(a,b),this.moveInput.enableEventType(a,b),this.keyInput.enableEventType(a,b),this.contextmenuInput.enableEventType(a,b)}_addEventHandler(b,e,d,f,g){if("string"!=typeof b){for(const h in d=e,b)this._addEventHandler(h,b[h],d,f,g);return}const{manager:i,events:j}=this,c=ci[b]||b;let a=j.get(c);!a&&(a=new cC(this),j.set(c,a),a.recognizerName=ch[c]||c,i&&i.on(c,a.handleEvent)),a.add(b,e,d,f,g),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(a,h){if("string"!=typeof a){for(const c in a)this._removeEventHandler(c,a[c]);return}const{events:d}=this,i=ci[a]||a,b=d.get(i);if(b&&(b.remove(a,h),b.isEmpty())){const{recognizerName:e}=b;let f=!1;for(const g of d.values())if(g.recognizerName===e&&!g.isEmpty()){f=!0;break}f||this._toggleRecognizer(e,!1)}}_onBasicInput(a){const{srcEvent:c}=a,b=cg[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function cE(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function cF(c){for(var a=1;a0),e=d&&!this.state.isHovering,h=!d&&this.state.isHovering;(c||e)&&(a.features=b,c&&c(a)),e&&cO.call(this,"onMouseEnter",a),h&&cO.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function cS(b){var c=this.props,d=c.onClick,f=c.onNativeClick,g=c.onDblClick,h=c.doubleClickZoom,a=[],e=g||h;switch(b.type){case"anyclick":a.push(f),e||a.push(d);break;case"click":e&&a.push(d)}(a=a.filter(Boolean)).length&&((b=cM.call(this,b)).features=cN.call(this,b.point),a.forEach(function(a){return a(b)}))}var m=(0,c.forwardRef)(function(b,h){var i,t,f=(0,c.useContext)(bJ),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new cD(null,{touchAction:b.touchAction,recognizerOptions:b.eventRecognizerOptions})},[]),g=(0,c.useRef)(null),e=(0,c.useRef)(null),a=(0,c.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;a.props=b,a.map=e.current&&e.current.getMap(),a.setState=function(c){a.state=cL(cL({},a.state),c),g.current.style.cursor=b.getCursor(a.state)};var j=!0,k=function(b,c,d){if(j){i=[b,c,d];return}var e=a.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(b,"position",{get:function(){return[0,0,bL(a.map,b)]}}),f&&f({viewState:b,interactionState:c,oldViewState:d}),g&&g(b,c,d)};(0,c.useImperativeHandle)(h,function(){var a;return{getMap:(a=e).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var d=(0,c.useMemo)(function(){return cL(cL({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||bP(a),a.viewport=d.viewport;var w=function(b){var c=b.isDragging,d=void 0!==c&&c;if(d!==a.state.isDragging&&a.setState({isDragging:d}),j){t=b;return}var e=a.props.onInteractionStateChange;e&&e(b)},l=function(){a.width&&a.height&&u.setOptions(cL(cL(cL({},a.props),a.props.viewState),{},{isInteractive:Boolean(a.props.onViewStateChange||a.props.onViewportChange),onViewportChange:k,onStateChange:w,eventManager:v,width:a.width,height:a.height}))},m=function(b){var c=b.width,d=b.height;a.width=c,a.height=d,l(),a.props.onResize({width:c,height:d})};(0,c.useEffect)(function(){return v.setElement(g.current),v.on({pointerdown:cP.bind(a),pointermove:cR.bind(a),pointerup:cQ.bind(a),pointerleave:cO.bind(a,"onMouseOut"),click:cS.bind(a),anyclick:cS.bind(a),dblclick:cO.bind(a,"onDblClick"),wheel:cO.bind(a,"onWheel"),contextmenu:cO.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),bK(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return ax(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ay(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}t&&w(t)}),l();var n=b.width,o=b.height,p=b.style,r=b.getCursor,s=(0,c.useMemo)(function(){return cL(cL({position:"relative"},p),{},{width:n,height:o,cursor:r(a.state)})},[p,n,o,r,a.state]);return i&&a._child||(a._child=c.createElement(bI,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,aw({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var cT=m;function cU(b,a){if(b===a)return!0;if(!b||!a)return!1;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!==a.length)return!1;for(var c=0;c prop: ".concat(e))}}(d,a,f.current):d=function(a,c,d){if(a.style&&a.style._loaded){var b=function(c){for(var a=1;a=0||(d[a]=c[a]);return d}(a,d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(a,b)&&(e[b]=a[b])}return e}(d,["layout","paint","filter","minzoom","maxzoom","beforeId"]);if(p!==a.beforeId&&b.moveLayer(c,p),e!==a.layout){var q=a.layout||{};for(var g in e)cU(e[g],q[g])||b.setLayoutProperty(c,g,e[g]);for(var r in q)e.hasOwnProperty(r)||b.setLayoutProperty(c,r,void 0)}if(f!==a.paint){var s=a.paint||{};for(var h in f)cU(f[h],s[h])||b.setPaintProperty(c,h,f[h]);for(var t in s)f.hasOwnProperty(t)||b.setPaintProperty(c,t,void 0)}for(var i in cU(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)cU(j[i],a[i])||b.setLayerProperty(c,i,j[i])}(c,d,a,b)}catch(e){console.warn(e)}}(a,d,b,e.current):function(a,d,b){if(a.style&&a.style._loaded){var c=cY(cY({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ab;var f={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},d={captureScroll:a.bool,captureDrag:a.bool,captureClick:a.bool,captureDoubleClick:a.bool,capturePointerMove:a.bool};function c$(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(bJ),e=(0,c.useRef)(null),f=(0,c.useRef)({props:d,state:{},context:a,containerRef:e}),b=f.current;return b.props=d,b.context=a,(0,c.useEffect)(function(){return function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(c){var b=a.props;b.captureScroll&&c.stopPropagation(),b.onScroll&&b.onScroll(c,a)},panstart:function(c){var b=a.props;b.captureDrag&&c.stopPropagation(),b.onDragStart&&b.onDragStart(c,a)},anyclick:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onNativeClick&&b.onNativeClick(c,a)},click:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onClick&&b.onClick(c,a)},dblclick:function(c){var b=a.props;b.captureDoubleClick&&c.stopPropagation(),b.onDoubleClick&&b.onDoubleClick(c,a)},pointermove:function(c){var b=a.props;b.capturePointerMove&&c.stopPropagation(),b.onPointerMove&&b.onPointerMove(c,a)}};return c.watch(d,b),function(){c.off(d)}}}(b)},[a.eventManager]),b}function c_(b){var a=b.instance,c=c$(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){bV(a,b);var d,e,f=(d=a,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(d);if(e){var c=bY(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var b;bk(this,a);for(var e=arguments.length,h=new Array(e),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var c="x"===d?a.offsetWidth:a.offsetHeight;return c6(b/100*c)/c*100};function c8(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}var ae=Object.assign({},ac,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),af=Object.assign({},ad,{className:""});function t(b){var d,j,e,k,f,l,m,a,h=(d=b,e=(j=aA((0,c.useState)(null),2))[0],k=j[1],f=aA((0,c.useState)(null),2),l=f[0],m=f[1],a=c$(c1(c1({},d),{},{onDragStart:c4})),a.callbacks=d,a.state.dragPos=e,a.state.setDragPos=k,a.state.dragOffset=l,a.state.setDragOffset=m,(0,c.useEffect)(function(){return function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return function(b,a){var h=a.props,c=a.callbacks,d=a.state,i=a.context;b.stopPropagation();var e=c2(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=c3(e,f,h,i),c.onDrag(g)}}(b,a)},panend:function(b){return function(c,a){var h=a.props,d=a.callbacks,b=a.state,i=a.context;c.stopPropagation();var e=b.dragPos,f=b.dragOffset;if(b.setDragPos(null),b.setDragOffset(null),d.onDragEnd&&e&&f){var g=Object.assign({},c);g.lngLat=c3(e,f,h,i),d.onDragEnd(g)}}(b,a)},pancancel:function(d){var c,b;return c=d,b=a.state,void(c.stopPropagation(),b.setDragPos(null),b.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}}(a)},[a.context.eventManager,Boolean(e)]),a),o=h.state,p=h.containerRef,q=b.children,r=b.className,s=b.draggable,A=b.style,t=o.dragPos,u=function(b){var a=b.props,e=b.state,f=b.context,g=a.longitude,h=a.latitude,j=a.offsetLeft,k=a.offsetTop,c=e.dragPos,d=e.dragOffset,l=f.viewport,m=f.map;if(c&&d)return[c[0]+d[0],c[1]+d[1]];var n=bL(m,{longitude:g,latitude:h}),i=aA(l.project([g,h,n]),2),o=i[0],p=i[1];return[o+=j,p+=k]}(h),n=aA(u,2),v=n[0],w=n[1],x="translate(".concat(c6(v),"px, ").concat(c6(w),"px)"),y=s?t?"grabbing":"grab":"auto",z=(0,c.useMemo)(function(){var a=function(c){for(var a=1;a0){var t=b,u=e;for(b=0;b<=1;b+=.5)k=(i=n-b*h)+h,e=Math.max(0,d-i)+Math.max(0,k-p+d),e0){var w=a,x=f;for(a=0;a<=1;a+=v)l=(j=m-a*g)+g,f=Math.max(0,d-j)+Math.max(0,l-o+d),f1||h< -1||f<0||f>p.width||g<0||g>p.height?i.display="none":i.zIndex=Math.floor((1-h)/2*1e5)),i),S=(0,c.useCallback)(function(b){t.props.onClose();var a=t.context.eventManager;a&&a.once("click",function(a){return a.stopPropagation()},b.target)},[]);return c.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(L," ").concat(N),style:R,ref:u},c.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:O}}),c.createElement("div",{key:"content",ref:j,className:"mapboxgl-popup-content"},P&&c.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:S},"\xd7"),Q))}function da(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}u.propTypes=ag,u.defaultProps=ah,c.memo(u);var ai=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string)])}),aj=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=c$(a),d=b.context,i=b.containerRef,j=(0,c.useRef)(null),e=aA((0,c.useState)(!1),2),f=e[0],m=e[1];(0,c.useEffect)(function(){var h,e,c,f,g,b;return d.map&&(h=(e={customAttribution:a.customAttribution},c=d.map,f=i.current,g=j.current,(b=new(A()).AttributionControl(e))._map=c,b._container=f,b._innerContainer=g,b._updateAttributions(),b._updateEditLink(),c.on("styledata",b._updateData),c.on("sourcedata",b._updateData),b)),function(){var a;return h&&void((a=h)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[d.map]);var h=void 0===a.compact?d.viewport.width<=640:a.compact;(0,c.useEffect)(function(){!h&&f&&m(!1)},[h]);var k=(0,c.useCallback)(function(){return m(function(a){return!a})},[]),l=(0,c.useMemo)(function(){return function(c){for(var a=1;ac)return 1}return 0}(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),f=b.viewport.bearing,d={transform:"rotate(".concat(-f,"deg)")},2===e?c.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:d}):c.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:d})))))}function di(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}y.propTypes=ao,y.defaultProps=ap,c.memo(y);var aq=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ar=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=c$(a),f=d.context,h=d.containerRef,e=aA((0,c.useState)(null),2),b=e[0],j=e[1];(0,c.useEffect)(function(){if(f.map){var a=new(A()).ScaleControl;a._map=f.map,a._container=h.current,j(a)}},[f.map]),b&&(b.options=a,b._onMove());var i=(0,c.useMemo)(function(){return function(c){for(var a=1;a 0) { @@ -4893,7 +4889,6 @@ break; } error1("Encountered two children with the same key, `%s`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted \u2014 the behavior is unsupported and could change in a future version.", key); - break; } return knownKeys; } @@ -4921,7 +4916,6 @@ var _existing3 = useFiber(child, element.props); return _existing3.ref = coerceRef(returnFiber, child, element), _existing3.return = returnFiber, _existing3._debugSource = element._source, _existing3._debugOwner = element._owner, _existing3; } - break; } deleteRemainingChildren(returnFiber, child); break; @@ -5061,7 +5055,6 @@ default: var container = 8 === nodeType ? rootContainerInstance.parentNode : rootContainerInstance; namespace = getChildNamespace(container.namespaceURI || null, type = container.tagName); - break; } return { namespace: namespace, @@ -5131,7 +5124,6 @@ break; case 5: returnFiber.type, parentProps = returnFiber.memoizedProps, parentInstance = returnFiber.stateNode, instance4 = instance, !0 !== parentProps[SUPPRESS_HYDRATION_WARNING$1] && (1 === instance4.nodeType ? warnForDeletedHydratableElement(parentInstance, instance4) : 8 === instance4.nodeType || warnForDeletedHydratableText(parentInstance, instance4)); - break; } var parentContainer, instance3, parentProps, parentInstance, instance4, childToDelete = createFiberFromHostInstanceForDeletion(); childToDelete.stateNode = instance, childToDelete.return = returnFiber, childToDelete.flags = Deletion, null !== returnFiber.lastEffect ? (returnFiber.lastEffect.nextEffect = childToDelete, returnFiber.lastEffect = childToDelete) : returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; @@ -5147,7 +5139,6 @@ break; case 6: warnForInsertedHydratedText(parentContainer, fiber.pendingProps); - break; } break; case 5: @@ -5164,7 +5155,6 @@ break; case 13: parentProps[SUPPRESS_HYDRATION_WARNING$1]; - break; } break; default: @@ -6600,6 +6590,18 @@ break; } else error1('%s is not a supported value for revealOrder on . Did you mean "together", "forwards" or "backwards"?', revealOrder); + if (void 0 !== revealOrder && 'forwards' !== revealOrder && 'backwards' !== revealOrder && 'together' !== revealOrder && !didWarnAboutRevealOrder[revealOrder]) if (didWarnAboutRevealOrder[revealOrder] = !0, 'string' == typeof revealOrder) switch(revealOrder.toLowerCase()){ + case 'together': + case 'forwards': + case 'backwards': + error1('"%s" is not a valid value for revealOrder on . Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase()); + break; + case 'forward': + case 'backward': + error1('"%s" is not a valid value for revealOrder on . React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase()); + break; + default: + error1('"%s" is not a supported revealOrder on . Did you mean "together", "forwards" or "backwards"?', revealOrder); } }(revealOrder1), tailMode = tailMode1, revealOrder2 = revealOrder1, void 0 === tailMode || didWarnAboutTailOptions[tailMode] || ('collapsed' !== tailMode && 'hidden' !== tailMode ? (didWarnAboutTailOptions[tailMode] = !0, error1('"%s" is not a supported value for tail on . Did you mean "collapsed" or "hidden"?', tailMode)) : 'forwards' !== revealOrder2 && 'backwards' !== revealOrder2 && (didWarnAboutTailOptions[tailMode] = !0, error1(' is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?', tailMode))), function(children, revealOrder) { if (('forwards' === revealOrder || 'backwards' === revealOrder) && null != children && !1 !== children) { @@ -6916,9 +6918,7 @@ case 19: return updateSuspenseListComponent(current13, workInProgress16, renderLanes12); case 20: - break; case 21: - break; case 22: break; case 23: @@ -6943,7 +6943,6 @@ case 'collapsed': for(var _tailNode = renderState.tail, _lastTailNode = null; null !== _tailNode;)null !== _tailNode.alternate && (_lastTailNode = _tailNode), _tailNode = _tailNode.sibling; null === _lastTailNode ? hasRenderedATailFallback || null === renderState.tail ? renderState.tail = null : renderState.tail.sibling = null : _lastTailNode.sibling = null; - break; } } function completeWork(current, workInProgress, renderLanes) { @@ -7012,18 +7011,14 @@ break; case 'textarea': initWrapperState$2(domElement, rawProps), listenToNonDelegatedEvent('invalid', domElement); - break; } assertValidProps(tag, rawProps), extraAttributeNames = new Set(); for(var attributes = domElement.attributes, _i = 0; _i < attributes.length; _i++){ var name = attributes[_i].name.toLowerCase(); switch(name){ case 'data-reactroot': - break; case 'value': - break; case 'checked': - break; case 'selected': break; default: @@ -7085,7 +7080,6 @@ break; default: 'function' == typeof rawProps.onClick && trapClickOnNonInteractiveElement(domElement); - break; } return updatePayload; }(instance, type9, props7, hostContext2.namespace)), fiber.updateQueue = updatePayload1, null !== updatePayload1 && markUpdate(workInProgress); @@ -7174,7 +7168,6 @@ break; default: 'function' == typeof props13.onClick && trapClickOnNonInteractiveElement(domElement3); - break; } }(instance7, type10 = type11, props8 = newProps, rootContainerInstance), shouldAutoFocusHostComponent(type10, props8) && markUpdate(workInProgress); } @@ -7201,7 +7194,6 @@ returnFiber.type; var parentProps, textInstance2, text3, parentProps3 = returnFiber.memoizedProps; returnFiber.stateNode, parentProps = parentProps3, textInstance2 = textInstance1, text3 = textContent, !0 !== parentProps[SUPPRESS_HYDRATION_WARNING$1] && warnForUnmatchedText(textInstance2, text3); - break; } } return shouldUpdate; @@ -7265,9 +7257,7 @@ } return null; case 20: - break; case 21: - break; case 22: break; case 23: @@ -7327,8 +7317,6 @@ popHostContainer(interruptedWork); break; case 13: - popSuspenseContext(interruptedWork); - break; case 19: popSuspenseContext(interruptedWork); break; @@ -7338,7 +7326,6 @@ case 23: case 24: popRenderLanes(interruptedWork); - break; } } function createCapturedValue(value, source) { @@ -7403,7 +7390,6 @@ break; default: lastProps = lastRawProps, nextProps = nextRawProps, 'function' != typeof lastProps.onClick && 'function' == typeof nextProps.onClick && trapClickOnNonInteractiveElement(domElement); - break; } assertValidProps(tag, nextProps); var styleUpdates1 = null; @@ -7541,7 +7527,6 @@ enqueueCapturedUpdate(workInProgress, _update2); return; } - break; } workInProgress = workInProgress.return; }while (null !== workInProgress) @@ -7633,11 +7618,8 @@ var _instance = null; if (null !== finishedWork1.child) switch(finishedWork1.child.tag){ case 5: - _instance = finishedWork1.child.stateNode; - break; case 1: _instance = finishedWork1.child.stateNode; - break; } commitUpdateQueue(finishedWork1, _updateQueue, _instance); } @@ -7699,8 +7681,6 @@ var instanceToUse, instance = finishedWork.stateNode; switch(finishedWork.tag){ case 5: - instanceToUse = instance; - break; default: instanceToUse = instance; } @@ -7788,8 +7768,6 @@ parent1 = parentStateNode, isContainer = !1; break; case 3: - parent1 = parentStateNode.containerInfo, isContainer = !0; - break; case 4: parent1 = parentStateNode.containerInfo, isContainer = !0; break; @@ -7932,7 +7910,6 @@ break; case 'select': element = domElement8, props = nextRawProps, wasMultiple = (node = element)._wrapperState.wasMultiple, node._wrapperState.wasMultiple = !!props.multiple, value = props.value, null != value ? updateOptions(node, !!props.multiple, value, !1) : !!props.multiple !== wasMultiple && (null != props.defaultValue ? updateOptions(node, !!props.multiple, props.defaultValue, !0) : updateOptions(node, !!props.multiple, props.multiple ? [] : '', !1)); - break; } }(domElement6, updatePayload6, type, oldProps, newProps)); } @@ -7957,7 +7934,6 @@ case 17: return; case 20: - break; case 21: break; case 23: @@ -8129,8 +8105,6 @@ case 1: throw Error("Root did not complete. This is a bug in React."); case 2: - commitRoot(root4); - break; case 3: if (markRootSuspended$1(root4, lanes5), (62914560 & (lanes3 = lanes5)) === lanes3 && !(actingUpdatesScopeDepth > 0)) { var msUntilTimeout = globalMostRecentFallbackTime + 500 - now(); @@ -8526,7 +8500,6 @@ break; case Deletion: commitDeletion(root, nextEffect); - break; } resetCurrentFiber(), nextEffect = nextEffect.nextEffect; } @@ -8725,7 +8698,6 @@ break; case 1: didWarnAboutUpdateInRender || (error1("Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state."), didWarnAboutUpdateInRender = !0); - break; } } didWarnAboutUpdateInRenderForAnotherComponent = new Set(); @@ -8897,7 +8869,6 @@ break; case 11: candidateType = type.render; - break; } if (null === resolveFamily) throw new Error('Expected resolveFamily to be set during hot reload.'); var needsRender = !1, needsRemount = !1; @@ -8917,7 +8888,6 @@ break; case 11: candidateType = type.render; - break; } var didMatch = !1; null !== candidateType && types.has(candidateType) && (didMatch = !0), didMatch ? findHostInstancesForFiberShallowly(fiber, hostInstances) : null !== child && findHostInstancesForMatchingFibersRecursively(child, types, hostInstances), null !== sibling && findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances); @@ -9010,7 +8980,6 @@ break; case 11: workInProgress.type = resolveForwardRefForHotReloading(current.type); - break; } return workInProgress; } @@ -9144,7 +9113,6 @@ break; case 0: this._debugRootType = 'createLegacyRoot()'; - break; } } function registerMutableSourceForHydration(root, mutableSource) { @@ -9175,7 +9143,6 @@ return node.stateNode.context; case 1: if (isContextProvider(node.type)) return node.stateNode.__reactInternalMemoizedMergedChildContext; - break; } node = node.return; }while (null !== node) From 07e8c6955dcda32cb644c8ea3a4786a41c5de86f Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 6 Apr 2022 16:19:32 +0800 Subject: [PATCH 04/27] fix const switch --- .../switchStatements_es2015.2.minified.js | 11 ++- ...StringInSwitchAndCaseES6_es5.2.minified.js | 7 +- ...ateStringInSwitchAndCase_es5.2.minified.js | 7 +- .../src/compress/optimize/switches.rs | 27 ++++--- .../switch/const/analysis-snapshot.rust-debug | 80 +++++++++++++++++++ .../fixture/simple/switch/const/input.js | 4 + .../fixture/simple/switch/const/output.js | 3 + 7 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/input.js create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js diff --git a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js index 6bed8df910c0..3940cd423548 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js @@ -31,5 +31,14 @@ var M; } class C { } -new C(), new C(), new Date(12), new Object(), (x)=>'' +switch(new C()){ + case new class extends C { + }(): + case { + id: 12, + name: '' + }: + case new C(): +} +new Date(12), new Object(), (x)=>'' ; diff --git a/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es5.2.minified.js index 94b1286af1d2..1d69cccfe3d2 100644 --- a/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es5.2.minified.js @@ -1 +1,6 @@ -"abc".concat(0, "abc"), "abc".concat(0, "abc"), "def".concat(1, "def"); +switch("abc".concat(0, "abc")){ + case "abc": + case "123": + case "abc".concat(0, "abc"): + "def".concat(1, "def"); +} diff --git a/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es5.2.minified.js index 94b1286af1d2..1d69cccfe3d2 100644 --- a/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es5.2.minified.js @@ -1 +1,6 @@ -"abc".concat(0, "abc"), "abc".concat(0, "abc"), "def".concat(1, "def"); +switch("abc".concat(0, "abc")){ + case "abc": + case "123": + case "abc".concat(0, "abc"): + "def".concat(1, "def"); +} diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 670bd8742248..c1286acbf78e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -6,7 +6,7 @@ use swc_ecma_utils::{ident::IdentLike, prepend, ExprExt, StmtExt, Type, Value::K use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use super::Optimizer; -use crate::{mode::Mode, util::ExprOptExt}; +use crate::{compress::util::is_pure_undefined, mode::Mode}; /// Methods related to option `switches`. impl Optimizer<'_, M> @@ -29,23 +29,28 @@ where _ => return, }; - let discriminant = &mut stmt.discriminant; - if let Expr::Update(..) = &**discriminant { - return; + fn tail_expr(e: &Expr) -> &Expr { + match e { + Expr::Seq(s) => s.exprs.last().unwrap(), + _ => e, + } } - if stmt - .cases - .iter() - .any(|case| matches!(case.test.as_deref(), Some(Expr::Update(..)))) - { - return; + let discriminant = &mut stmt.discriminant; + + let tail = tail_expr(discriminant); + + match tail { + Expr::Lit(_) => (), + Expr::Ident(id) if self.data.vars.get(&id.to_id()).unwrap().declared => (), + e if is_pure_undefined(e) => (), + _ => return, } let matching_case = stmt.cases.iter_mut().position(|case| { case.test .as_ref() - .map(|test| discriminant.value_mut().eq_ignore_span(test)) + .map(|test| tail.eq_ignore_span(tail_expr(test))) .unwrap_or(false) }); diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..4a11de102c7c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('a' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/input.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/input.js new file mode 100644 index 000000000000..6c41b54aa361 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/input.js @@ -0,0 +1,4 @@ +switch (a()) { + case a(): + console.log(123); +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js new file mode 100644 index 000000000000..33348a3896d1 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js @@ -0,0 +1,3 @@ +if (a() === a()) { + console.log(123); +} From 9dd72d5d8978ad54a87a527b8dd3ef9ae2b8abc8 Mon Sep 17 00:00:00 2001 From: austaras Date: Sun, 17 Apr 2022 00:27:47 +0800 Subject: [PATCH 05/27] 2 case --- .../src/compress/optimize/switches.rs | 136 +++++++++++++++--- .../src/compress/util/mod.rs | 26 ++++ crates/swc_ecma_minifier/src/option/terser.rs | 2 - .../fixture/simple/switch/const/output.js | 4 +- .../tests/fixture/issues/2257/full/output.js | 35 ++--- .../pages/index-cb36c1bf7f830e3c/output.js | 34 ++--- .../785-e1932cc99ac3bb67/output.js | 3 +- .../tests/projects/output/angular-1.2.5.js | 8 +- .../tests/projects/output/react-dom-17.0.2.js | 28 +--- .../reduce_vars/issue_1670_6/output.js | 11 +- .../compress/switch/issue_1679/output.js | 10 +- .../compress/switch/issue_1705_1/output.js | 7 +- .../compress/switch/keep_default/output.js | 8 +- 13 files changed, 180 insertions(+), 132 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index c1286acbf78e..53147d2b6799 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -6,7 +6,10 @@ use swc_ecma_utils::{ident::IdentLike, prepend, ExprExt, StmtExt, Type, Value::K use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use super::Optimizer; -use crate::{compress::util::is_pure_undefined, mode::Mode}; +use crate::{ + compress::util::{abort_stmts, is_pure_undefined}, + mode::Mode, +}; /// Methods related to option `switches`. impl Optimizer<'_, M> @@ -16,7 +19,7 @@ where /// Handle switches in the case where we can know which branch will be /// taken. pub(super) fn optimize_const_switches(&mut self, s: &mut Stmt) { - if !self.options.switches || self.ctx.stmt_labelled { + if !self.options.switches || !self.options.dead_code || self.ctx.stmt_labelled { return; } @@ -29,6 +32,7 @@ where _ => return, }; + // TODO: evaluate fn tail_expr(e: &Expr) -> &Expr { match e { Expr::Seq(s) => s.exprs.last().unwrap(), @@ -42,7 +46,6 @@ where match tail { Expr::Lit(_) => (), - Expr::Ident(id) if self.data.vars.get(&id.to_id()).unwrap().declared => (), e if is_pure_undefined(e) => (), _ => return, } @@ -58,12 +61,13 @@ where let mut var_ids = vec![]; let mut stmts = vec![]; - let should_preserve_switch = stmt.cases.iter().skip(case_idx).any(|case| { + let should_preserve_switch = stmt.cases[..=case_idx].iter().any(|case| { let mut v = BreakFinder { - found_unlabelled_break_for_stmt: false, + top_level: true, + nested_unlabelled_break: false, }; case.visit_with(&mut v); - v.found_unlabelled_break_for_stmt + v.nested_unlabelled_break }); if should_preserve_switch { // Prevent infinite loop. @@ -84,10 +88,13 @@ where expr: discriminant.take(), })); - if let Some(expr) = stmt.cases[case_idx].test.take() { + for test in stmt.cases[..case_idx] + .iter_mut() + .filter_map(|case| case.test.as_mut()) + { preserved.push(Stmt::Expr(ExprStmt { - span: stmt.cases[case_idx].span, - expr, + span: DUMMY_SP, + expr: test.take(), })); } } @@ -195,7 +202,7 @@ where /// /// - drop the empty cases at the end. pub(super) fn optimize_switch_cases(&mut self, cases: &mut Vec) { - if !self.options.switches { + if !self.options.switches || !self.options.dead_code { return; } @@ -343,17 +350,20 @@ where if let Stmt::Switch(sw) = s { match &mut *sw.cases { [] => { + report_change!("switches: Removing empty switch"); *s = Stmt::Expr(ExprStmt { span: sw.span, expr: sw.discriminant.take(), }) } [case] => { + report_change!("switches: Turn one case switch into if"); let mut v = BreakFinder { - found_unlabelled_break_for_stmt: false, + top_level: true, + nested_unlabelled_break: false, }; case.visit_with(&mut v); - if v.found_unlabelled_break_for_stmt { + if v.nested_unlabelled_break { return; } @@ -390,6 +400,73 @@ where }) } } + [first, second] if first.test.is_none() || second.test.is_none() => { + report_change!("switches: Turn two cases switch into if else"); + let abort = abort_stmts(&first.cons); + + if abort { + if let Stmt::Break(BreakStmt { label: None, .. }) = + first.cons.last().unwrap() + { + first.cons.pop(); + } + // they cannot both be default as that's syntax error + let (def, case) = if first.test.is_none() { + (first, second) + } else { + (second, first) + }; + *s = Stmt::If(IfStmt { + span: sw.span, + test: Expr::Bin(BinExpr { + span: DUMMY_SP, + op: op!("==="), + left: sw.discriminant.take(), + right: case.test.take().unwrap(), + }) + .into(), + cons: Stmt::Block(BlockStmt { + span: DUMMY_SP, + stmts: case.cons.take(), + }) + .into(), + alt: Some( + Stmt::Block(BlockStmt { + span: DUMMY_SP, + stmts: def.cons.take(), + }) + .into(), + ), + }) + } else { + let (def, case) = if first.test.is_none() { + (first, second) + } else { + (second, first) + }; + let mut stmts = vec![Stmt::If(IfStmt { + span: DUMMY_SP, + test: Expr::Bin(BinExpr { + span: DUMMY_SP, + op: op!("==="), + left: sw.discriminant.take(), + right: case.test.take().unwrap(), + }) + .into(), + cons: Stmt::Block(BlockStmt { + span: DUMMY_SP, + stmts: case.cons.take(), + }) + .into(), + alt: None, + })]; + stmts.extend(def.cons.take()); + *s = Stmt::Block(BlockStmt { + span: sw.span, + stmts, + }) + } + } _ => (), } } @@ -398,18 +475,39 @@ where #[derive(Default)] struct BreakFinder { - found_unlabelled_break_for_stmt: bool, + top_level: bool, + nested_unlabelled_break: bool, +} + +impl BreakFinder { + fn visit_nested + ?Sized>(&mut self, s: &S) { + if self.top_level { + self.top_level = false; + s.visit_children_with(self); + self.top_level = true; + } else { + s.visit_children_with(self); + } + } } impl Visit for BreakFinder { noop_visit_type!(); fn visit_break_stmt(&mut self, s: &BreakStmt) { - if s.label.is_none() { - self.found_unlabelled_break_for_stmt = true; + if !self.top_level && s.label.is_none() { + self.nested_unlabelled_break = true; } } + fn visit_stmts(&mut self, stmts: &[Stmt]) { + self.visit_nested(stmts) + } + + fn visit_if_stmt(&mut self, i: &IfStmt) { + self.visit_nested(i) + } + /// We don't care about breaks in a loop fn visit_for_stmt(&mut self, _: &ForStmt) {} @@ -431,11 +529,3 @@ impl Visit for BreakFinder { fn visit_class(&mut self, _: &Class) {} } - -fn ends_with_break(stmts: &[Stmt]) -> bool { - if let Some(last) = stmts.last() { - last.is_break_stmt() - } else { - false - } -} diff --git a/crates/swc_ecma_minifier/src/compress/util/mod.rs b/crates/swc_ecma_minifier/src/compress/util/mod.rs index 87d41ed32449..686c50b25c9b 100644 --- a/crates/swc_ecma_minifier/src/compress/util/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/util/mod.rs @@ -793,3 +793,29 @@ impl Visit for SuperFinder { self.found = true; } } + +/// stmts contain top level return/break/continue/throw +pub(crate) fn abort(stmt: &Stmt) -> bool { + match stmt { + Stmt::Break(_) | Stmt::Continue(_) | Stmt::Throw(_) | Stmt::Return(_) => return true, + Stmt::Block(block) if abort_stmts(&block.stmts) => return true, + Stmt::If(IfStmt { + cons, + alt: Some(alt), + .. + }) if abort(cons) && abort(alt) => return true, + _ => (), + } + + false +} + +pub(crate) fn abort_stmts(stmts: &[Stmt]) -> bool { + for s in stmts { + if abort(s) { + return true; + } + } + + false +} diff --git a/crates/swc_ecma_minifier/src/option/terser.rs b/crates/swc_ecma_minifier/src/option/terser.rs index 9ee96f6c2106..300815df8158 100644 --- a/crates/swc_ecma_minifier/src/option/terser.rs +++ b/crates/swc_ecma_minifier/src/option/terser.rs @@ -370,8 +370,6 @@ impl TerserCompressorOptions { }) .unwrap_or(if self.defaults { 3 } else { 0 }), side_effects: self.side_effects.unwrap_or(self.defaults), - // TODO: Use self.defaults - switches: self.switches.unwrap_or(false), switches: self.switches.unwrap_or(self.defaults), top_retain: self.top_retain.map(From::from).unwrap_or_default(), top_level: self.toplevel.map(From::from), diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js index 33348a3896d1..7591ac66bc52 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js @@ -1,3 +1 @@ -if (a() === a()) { - console.log(123); -} +if (a() === a()) console.log(123); 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 758e2290ec60..0bb0aa1909cb 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 @@ -13090,18 +13090,14 @@ a: { for(l2 = f.key, k2 = d; null !== k2;){ if (k2.key === l2) { - switch(k2.tag){ - case 7: - if (f.type === ua) { - c6(a15, k2.sibling), (d = e5(k2, f.props.children)).return = a15, a15 = d; - break a; - } - break; - default: - if (k2.elementType === f.type) { - c6(a15, k2.sibling), (d = e5(k2, f.props)).ref = Qg(a15, k2, f), d.return = a15, a15 = d; - break a; - } + if (7 === k2.tag) { + if (f.type === ua) { + c6(a15, k2.sibling), (d = e5(k2, f.props.children)).return = a15, a15 = d; + break a; + } + } else if (k2.elementType === f.type) { + c6(a15, k2.sibling), (d = e5(k2, f.props)).ref = Qg(a15, k2, f), d.return = a15, a15 = d; + break a; } c6(a15, k2); break; @@ -15177,12 +15173,7 @@ var Q = Z.ref; if (null !== Q) { var L = Z.stateNode; - switch(Z.tag){ - case 5: - default: - q = L; - } - "function" == typeof Q ? Q(q) : Q.current = q; + Z.tag, q = L, "function" == typeof Q ? Q(q) : Q.current = q; } } Z = Z.nextEffect; @@ -15410,13 +15401,7 @@ }, null !== (d = void 0 === d ? null : d) && (b.callback = d), Ag(e, b), Jg(e, g, f), g; } function mk(a) { - if (!(a = a.current).child) return null; - switch(a.child.tag){ - case 5: - return a.child.stateNode; - default: - return a.child.stateNode; - } + return (a = a.current).child ? (a.child.tag, a.child.stateNode) : null; } function nk(a, b) { if (null !== (a = a.memoizedState) && null !== a.dehydrated) { 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 b61f2c40282b..6a4ff95abb38 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 @@ -2094,25 +2094,21 @@ for(var n in source)target[n] = source[n]; } function parseDCC(source, start, domBuilder, errorHandler) { - var next = source.charAt(start + 2); - switch(next){ - case '-': - if ('-' !== source.charAt(start + 3)) return -1; - var end = source.indexOf('-->', start + 4); - if (end > start) return domBuilder.comment(source, start + 4, end - start - 4), end + 3; - return errorHandler.error("Unclosed comment"), -1; - default: - if ('CDATA[' == source.substr(start + 3, 6)) { - var end = source.indexOf(']]>', start + 9); - return domBuilder.startCDATA(), domBuilder.characters(source, start + 9, end - start - 9), domBuilder.endCDATA(), end + 3; - } - var matchs = split(source, start), len = matchs.length; - if (len > 1 && /!doctype/i.test(matchs[0][0])) { - var name = matchs[1][0], pubid = !1, sysid = !1; - len > 3 && (/^public$/i.test(matchs[2][0]) ? (pubid = matchs[3][0], sysid = len > 4 && matchs[4][0]) : /^system$/i.test(matchs[2][0]) && (sysid = matchs[3][0])); - var lastMatch = matchs[len - 1]; - return domBuilder.startDTD(name, pubid, sysid), domBuilder.endDTD(), lastMatch.index + lastMatch[0].length; - } + if ('-' === source.charAt(start + 2)) { + if ('-' !== source.charAt(start + 3)) return -1; + var end = source.indexOf('-->', start + 4); + return end > start ? (domBuilder.comment(source, start + 4, end - start - 4), end + 3) : (errorHandler.error("Unclosed comment"), -1); + } + if ('CDATA[' == source.substr(start + 3, 6)) { + var end = source.indexOf(']]>', start + 9); + return domBuilder.startCDATA(), domBuilder.characters(source, start + 9, end - start - 9), domBuilder.endCDATA(), end + 3; + } + var matchs = split(source, start), len = matchs.length; + if (len > 1 && /!doctype/i.test(matchs[0][0])) { + var name = matchs[1][0], pubid = !1, sysid = !1; + len > 3 && (/^public$/i.test(matchs[2][0]) ? (pubid = matchs[3][0], sysid = len > 4 && matchs[4][0]) : /^system$/i.test(matchs[2][0]) && (sysid = matchs[3][0])); + var lastMatch = matchs[len - 1]; + return domBuilder.startDTD(name, pubid, sysid), domBuilder.endDTD(), lastMatch.index + lastMatch[0].length; } return -1; } diff --git a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js index fbb6f5a1f74a..f1a5e6b1d0f9 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js @@ -1,2 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[785],{840:function(a,b,c){var d;!function(g,B,Q,l){"use strict";var m,R=["","webkit","Moz","MS","ms","o"],C=B.createElement("div"),S=Math.round,T=Math.abs,U=Date.now;function V(a,b,c){return setTimeout(G(a,c),b)}function W(a,c,b){return!!Array.isArray(a)&&(D(a,b[c],b),!0)}function D(a,c,d){var b;if(a){if(a.forEach)a.forEach(c,d);else if(l!==a.length)for(b=0;b\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=an(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=ao(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=as(j,k),a.distance=ar(j,k),al(b,a),a.offsetDirection=aq(a.deltaX,a.deltaY);var d=ap(a.deltaTime,a.deltaX,a.deltaY);a.overallVelocityX=d.x,a.overallVelocityY=d.y,a.overallVelocity=T(d.x)>T(d.y)?d.x:d.y,a.scale=c?au(c.pointers,e):1,a.rotation=c?at(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,am(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function al(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function am(h,a){var d,e,f,g,b=h.lastInterval||a,i=a.timeStamp-b.timeStamp;if(8!=a.eventType&&(i>25||l===b.velocity)){var j=a.deltaX-b.deltaX,k=a.deltaY-b.deltaY,c=ap(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=aq(j,k),h.lastInterval=a}else d=b.velocity,e=b.velocityX,f=b.velocityY,g=b.direction;a.velocity=d,a.velocityX=e,a.velocityY=f,a.direction=g}function an(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ar(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function as(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function at(a,b){return as(b[1],b[0],ai)+as(a[1],a[0],ai)}function au(a,b){return ar(b[0],b[1],ai)/ar(a[0],a[1],ai)}f.prototype={handler:function(){},init:function(){this.evEl&&H(this.element,this.evEl,this.domHandler),this.evTarget&&H(this.target,this.evTarget,this.domHandler),this.evWin&&H(ae(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&I(this.element,this.evEl,this.domHandler),this.evTarget&&I(this.target,this.evTarget,this.domHandler),this.evWin&&I(ae(this.element),this.evWin,this.domHandler)}};var av={mousedown:1,mousemove:2,mouseup:4};function u(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,f.apply(this,arguments)}e(u,f,{handler:function(a){var b=av[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:L,srcEvent:a}))}});var aw={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},ax={2:K,3:"pen",4:L,5:"kinect"},M="pointerdown",N="pointermove pointerup pointercancel";function v(){this.evEl=M,this.evWin=N,f.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}g.MSPointerEvent&&!g.PointerEvent&&(M="MSPointerDown",N="MSPointerMove MSPointerUp MSPointerCancel"),e(v,f,{handler:function(a){var b=this.store,e=!1,d=aw[a.type.toLowerCase().replace("ms","")],f=ax[a.pointerType]||a.pointerType,c=aa(b,a.pointerId,"pointerId");1&d&&(0===a.button||f==K)?c<0&&(b.push(a),c=b.length-1):12&d&&(e=!0),!(c<0)&&(b[c]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),e&&b.splice(c,1))}});var ay={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function w(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,f.apply(this,arguments)}function az(b,d){var a=ab(b.touches),c=ab(b.changedTouches);return 12&d&&(a=ac(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ay[c.type];if(1===a&&(this.started=!0),this.started){var b=az.call(this,c,a);12&a&&b[0].length-b[1].length==0&&(this.started=!1),this.callback(this.manager,a,{pointers:b[0],changedPointers:b[1],pointerType:K,srcEvent:c})}}});var aA={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function x(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},f.apply(this,arguments)}function aB(h,g){var b=ab(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ab(h.changedTouches),f=[],i=this.target;if(d=b.filter(function(a){return Z(a.target,i)}),1===g)for(a=0;a -1&&d.splice(a,1)},2500)}}function aE(b){for(var d=b.srcEvent.clientX,e=b.srcEvent.clientY,a=0;a -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(d){var c=this,a=this.state;function b(a){c.manager.emit(a,d)}a<8&&b(c.options.event+aM(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+aM(a))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ac.threshold&&b&c.direction},attrTest:function(a){return h.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=aN(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),e(p,h,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),e(q,i,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[aG]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=V(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=U(),this.manager.emit(this.options.event,this._input)))}}),e(r,h,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),e(s,h,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return o.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&T(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=aN(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),e(j,i,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[aH]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var a=1;ac.length)&&(a=c.length);for(var b=0,d=new Array(a);bc?c:a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),bc=new h(4),h!=Float32Array&&(bc[0]=0,bc[1]=0,bc[2]=0,bc[3]=0);const aF=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function aG(e,f,g){var h=f[0],i=f[1],j=f[2],k=f[3],l=f[4],m=f[5],n=f[6],o=f[7],p=f[8],q=f[9],r=f[10],s=f[11],t=f[12],u=f[13],v=f[14],w=f[15],a=g[0],b=g[1],c=g[2],d=g[3];return e[0]=a*h+b*l+c*p+d*t,e[1]=a*i+b*m+c*q+d*u,e[2]=a*j+b*n+c*r+d*v,e[3]=a*k+b*o+c*s+d*w,a=g[4],b=g[5],c=g[6],d=g[7],e[4]=a*h+b*l+c*p+d*t,e[5]=a*i+b*m+c*q+d*u,e[6]=a*j+b*n+c*r+d*v,e[7]=a*k+b*o+c*s+d*w,a=g[8],b=g[9],c=g[10],d=g[11],e[8]=a*h+b*l+c*p+d*t,e[9]=a*i+b*m+c*q+d*u,e[10]=a*j+b*n+c*r+d*v,e[11]=a*k+b*o+c*s+d*w,a=g[12],b=g[13],c=g[14],d=g[15],e[12]=a*h+b*l+c*p+d*t,e[13]=a*i+b*m+c*q+d*u,e[14]=a*j+b*n+c*r+d*v,e[15]=a*k+b*o+c*s+d*w,e}function aH(b,a,f){var g,h,i,j,k,l,m,n,o,p,q,r,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],b[0]=g,b[1]=h,b[2]=i,b[3]=j,b[4]=k,b[5]=l,b[6]=m,b[7]=n,b[8]=o,b[9]=p,b[10]=q,b[11]=r,b[12]=g*c+k*d+o*e+a[12],b[13]=h*c+l*d+p*e+a[13],b[14]=i*c+m*d+q*e+a[14],b[15]=j*c+n*d+r*e+a[15]),b}function aI(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function aJ(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function aK(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function aL(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function aM(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}bd=new h(2),h!=Float32Array&&(bd[0]=0,bd[1]=0),be=new h(3),h!=Float32Array&&(be[0]=0,be[1]=0,be[2]=0);const n=Math.PI,aN=n/4,aO=n/180,aP=180/n;function aQ(a){return Math.pow(2,a)}function aR([b,a]){return aM(Number.isFinite(b)),aM(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*aO+n)/(2*n),512*(n+Math.log(Math.tan(aN+.5*(a*aO))))/(2*n)]}function aS([a,b]){return[(a/512*(2*n)-n)*aP,2*(Math.atan(Math.exp(b/512*(2*n)-n))-aN)*aP]}function aT(a){return 2*Math.atan(.5/a)*aP}function aU(a){return .5/Math.tan(.5*a*aO)}function aV(i,c,j=0){const[a,b,e]=i;if(aM(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=aC(c,[a,b,e,1]);return k}const f=aC(c,[a,b,0,1]),g=aC(c,[a,b,1,1]),d=f[2],h=g[2];return aL([],f,g,d===h?0:((j||0)-d)/(h-d))}const aW=Math.PI/180;function aX(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=aC(e,[c,0,1,1]),f=aC(e,[c,a.height,1,1]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=aL([],b,f,i),g=aS(j);return g[2]=d,g}class aY{constructor({width:f,height:c,latitude:l=0,longitude:m=0,zoom:p=0,pitch:n=0,bearing:q=0,altitude:a=null,fovy:b=null,position:o=null,nearZMultiplier:t=.02,farZMultiplier:u=1.01}={width:1,height:1}){f=f||1,c=c||1,null===b&&null===a?b=aT(a=1.5):null===b?b=aT(a):null===a&&(a=aU(b));const r=aQ(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){aM(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*aO),e=1.4222222222222223/d,a=12790407194604047e-21/d;if(b.unitsPerMeter=[a,a,a],b.metersPerUnit=[1/a,1/a,1/a],b.unitsPerDegree=[1.4222222222222223,e,a],b.degreesPerUnit=[.703125,1/e,1/a],j){const f=aO*Math.tan(c*aO)/d,k=1.4222222222222223*f/2,g=12790407194604047e-21*f,h=g/e*a;b.unitsPerDegree2=[0,k,g],b.unitsPerMeter2=[h,0,h]}return b}({longitude:m,latitude:l}),d=aR([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,k=(e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],e),i[0]=j[0]+k[0],i[1]=j[1]+k[1],i[2]=j[2]+k[2]}this.projectionMatrix=function({width:h,height:i,pitch:j,altitude:k,fovy:l,nearZMultiplier:m,farZMultiplier:n}){var a,f,g,c,b,d,e;const{fov:o,aspect:p,near:q,far:r}=function({width:f,height:g,fovy:a=aT(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=aT(d));const b=.5*a*aO,c=aU(a),e=h*aO;return{fov:2*b,aspect:f/g,focalDistance:c,near:i,far:(Math.sin(e)*(Math.sin(b)*c/Math.sin(Math.min(Math.max(Math.PI/2-e-b,.01),Math.PI-.01)))+c)*j}}({width:h,height:i,altitude:k,fovy:l,pitch:j,nearZMultiplier:m,farZMultiplier:n}),s=(a=[],f=o,g=p,c=q,b=r,e=1/Math.tan(f/2),a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(d=1/(c-b),a[10]=(b+c)*d,a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a);return s}({width:f,height:c,pitch:n,fovy:b,nearZMultiplier:t,farZMultiplier:u}),this.viewMatrix=function({height:F,pitch:G,bearing:H,altitude:I,scale:l,center:E=null}){var a,b,m,f,g,n,o,p,q,r,s,t,u,c,d,v,h,i,w,x,y,z,A,B,C,D,j,k;const e=aB();return aH(e,e,[0,0,-I]),a=e,b=e,m=-G*aO,f=Math.sin(m),g=Math.cos(m),n=b[4],o=b[5],p=b[6],q=b[7],r=b[8],s=b[9],t=b[10],u=b[11],b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=n*g+r*f,a[5]=o*g+s*f,a[6]=p*g+t*f,a[7]=q*g+u*f,a[8]=r*g-n*f,a[9]=s*g-o*f,a[10]=t*g-p*f,a[11]=u*g-q*f,c=e,d=e,v=H*aO,h=Math.sin(v),i=Math.cos(v),w=d[0],x=d[1],y=d[2],z=d[3],A=d[4],B=d[5],C=d[6],D=d[7],d!==c&&(c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15]),c[0]=w*i+A*h,c[1]=x*i+B*h,c[2]=y*i+C*h,c[3]=z*i+D*h,c[4]=A*i-w*h,c[5]=B*i-x*h,c[6]=C*i-y*h,c[7]=D*i-z*h,aI(e,e,[l/=F,l,l]),E&&aH(e,e,(j=[],k=E,j[0]=-k[0],j[1]=-k[1],j[2]=-k[2],j)),e}({height:c,scale:r,center:d,pitch:n,bearing:q,altitude:a}),this.width=f,this.height=c,this.scale=r,this.latitude=l,this.longitude=m,this.zoom=p,this.pitch=n,this.bearing=q,this.altitude=a,this.fovy=b,this.center=d,this.meterOffset=o||[0,0,0],this.distanceScales=s,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,a;const{width:I,height:J,projectionMatrix:K,viewMatrix:L}=this,G=aB();aG(G,G,K),aG(G,G,L),this.viewProjectionMatrix=G;const d=aB();aI(d,d,[I/2,-J/2,1]),aH(d,d,[1,-1,0]),aG(d,d,G);const H=(b=aB(),e=(c=d)[0],f=c[1],g=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=c[8],n=c[9],o=c[10],p=c[11],q=c[12],r=c[13],s=c[14],t=c[15],u=e*j-f*i,v=e*k-g*i,w=e*l-h*i,x=f*k-g*j,y=f*l-h*j,z=g*l-h*k,A=m*r-n*q,B=m*s-o*q,C=m*t-p*q,D=n*s-o*r,E=n*t-p*r,F=o*t-p*s,a=u*F-v*E+w*D+x*C-y*B+z*A,a?(a=1/a,b[0]=(j*F-k*E+l*D)*a,b[1]=(g*E-f*F-h*D)*a,b[2]=(r*z-s*y+t*x)*a,b[3]=(o*y-n*z-p*x)*a,b[4]=(k*C-i*F-l*B)*a,b[5]=(e*F-g*C+h*B)*a,b[6]=(s*w-q*z-t*v)*a,b[7]=(m*z-o*w+p*v)*a,b[8]=(i*E-j*C+l*A)*a,b[9]=(f*C-e*E-h*A)*a,b[10]=(q*y-r*w+t*u)*a,b[11]=(n*w-m*y-p*u)*a,b[12]=(j*B-i*D-k*A)*a,b[13]=(e*D-f*B+g*A)*a,b[14]=(r*v-q*x-s*u)*a,b[15]=(m*x-n*v+o*u)*a,b):null);if(!H)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=H}equals(a){return a instanceof aY&&a.width===this.width&&a.height===this.height&&aJ(a.projectionMatrix,this.projectionMatrix)&&aJ(a.viewMatrix,this.viewMatrix)}project(a,{topLeft:f=!0}={}){const g=this.projectPosition(a),b=function(d,e){const[a,b,c=0]=d;return aM(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),aC(e,[a,b,c,1])}(g,this.pixelProjectionMatrix),[c,d]=b,e=f?d:this.height-d;return 2===a.length?[c,e]:[c,e,b[2]]}unproject(f,{topLeft:g=!0,targetZ:a}={}){const[h,d,e]=f,i=g?d:this.height-d,j=a&&a*this.distanceScales.unitsPerMeter[2],k=aV([h,i,e],this.pixelUnprojectionMatrix,j),[b,c,l]=this.unprojectPosition(k);return Number.isFinite(e)?[b,c,l]:Number.isFinite(a)?[b,c,a]:[b,c]}projectPosition(a){const[b,c]=aR(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=aS(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return aR(a)}unprojectFlat(a){return aS(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=aV(d,this.pixelUnprojectionMatrix),f=aR(c),g=aK([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=aK([],this.center,g);return aS(h)}getLocationAtPoint({lngLat:a,pos:b}){return this.getMapCenterByLngLatPosition({lngLat:a,pos:b})}fitBounds(c,d={}){const{width:a,height:b}=this,{longitude:e,latitude:f,zoom:g}=function({width:m,height:n,bounds:o,minExtent:f=0,maxZoom:p=24,padding:a=0,offset:g=[0,0]}){const[[q,r],[s,t]]=o;if(Number.isFinite(a)){const b=a;a={top:b,bottom:b,left:b,right:b}}else aM(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=aR([q,aE(t,-85.051129,85.051129)]),d=aR([s,aE(r,-85.051129,85.051129)]),h=[Math.max(Math.abs(d[0]-c[0]),f),Math.max(Math.abs(d[1]-c[1]),f)],e=[m-a.left-a.right-2*Math.abs(g[0]),n-a.top-a.bottom-2*Math.abs(g[1])];aM(e[0]>0&&e[1]>0);const i=e[0]/h[0],j=e[1]/h[1],u=(a.right-a.left)/2/i,v=(a.bottom-a.top)/2/j,w=[(d[0]+c[0])/2+u,(d[1]+c[1])/2+v],k=aS(w),l=Math.min(p,aF(Math.abs(Math.min(i,j))));return aM(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new aY({width:a,height:b,longitude:e,latitude:f,zoom:g})}getBounds(b){const a=this.getBoundingRegion(b),c=Math.min(...a.map(a=>a[0])),d=Math.max(...a.map(a=>a[0])),e=Math.min(...a.map(a=>a[1])),f=Math.max(...a.map(a=>a[1]));return[[c,e],[d,f]]}getBoundingRegion(a={}){return function(a,d=0){const{width:e,height:h,unproject:b}=a,c={targetZ:d},i=b([0,h],c),j=b([e,h],c);let f,g;const k=a.fovy?.5*a.fovy*aW:Math.atan(.5/a.altitude),l=(90-a.pitch)*aW;return k>l-.01?(f=aX(a,0,d),g=aX(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const aZ=["longitude","latitude","zoom"],a$={curve:1.414,speed:1.2};function a_(d,h,i){var f,j,k,o,p,q;i=Object.assign({},a$,i);const g=i.curve,l=d.zoom,w=[d.longitude,d.latitude],x=aQ(l),y=h.zoom,z=[h.longitude,h.latitude],A=aQ(y-l),r=aR(w),B=aR(z),s=(f=[],j=B,k=r,f[0]=j[0]-k[0],f[1]=j[1]-k[1],f),a=Math.max(d.width,d.height),e=a/A,t=(p=(o=s)[0],q=o[1],Math.hypot(p,q)*x),c=Math.max(t,.01),b=g*g,m=(e*e-a*a+b*b*c*c)/(2*a*b*c),n=(e*e-a*a-b*b*c*c)/(2*e*b*c),u=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(n*n+1)-n);return{startZoom:l,startCenterXY:r,uDelta:s,w0:a,u1:t,S:(v-u)/g,rho:g,rho2:b,r0:u,r1:v}}var N=function(){if("undefined"!=typeof Map)return Map;function a(a,c){var b=-1;return a.some(function(a,d){return a[0]===c&&(b=d,!0)}),b}return function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(c){var d=a(this.__entries__,c),b=this.__entries__[d];return b&&b[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(d){var b=this.__entries__,c=a(b,d);~c&&b.splice(c,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(e,a){void 0===a&&(a=null);for(var b=0,c=this.__entries__;b0},a.prototype.connect_=function(){a0&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),a3?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){a0&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(b){var a=b.propertyName,c=void 0===a?"":a;a2.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null,a}(),a5=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),bi="undefined"!=typeof WeakMap?new WeakMap:new N,O=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=a4.getInstance(),d=new bh(b,c,this);bi.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=bi.get(this))[a].apply(b,arguments)}});var bj=void 0!==o.ResizeObserver?o.ResizeObserver:O;function bk(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function bl(d,c){for(var b=0;b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function bq(a,c){if(a){if("string"==typeof a)return br(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return br(a,c)}}function br(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b1&& void 0!==arguments[1]?arguments[1]:"component";b.debug&&a.checkPropTypes(Q,b,"prop",c)}var i=function(){function a(b){var c=this;if(bk(this,a),g(this,"props",R),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return bm(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var d=this._map.getContainer(),c=b.container;for(c.classList.add("mapboxgl-map");d.childNodes.length>0;)c.appendChild(d.childNodes[0]);this._map._container=c,a.savedMap=null,b.mapStyle&&this._map.setStyle(bt(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var d=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=d,b.gl}}var c={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:bt(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(c.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},c,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var d=this;bv(a=Object.assign({},R,a),"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||R.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var b=a.container;Object.defineProperty(b,"offsetWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"clientWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"offsetHeight",{configurable:!0,get:function(){return d.height}}),Object.defineProperty(b,"clientHeight",{configurable:!0,get:function(){return d.height}});var c=this._map.getCanvas();c&&(c.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(b,a){if(this._map){bv(a=Object.assign({},this.props,a),"Mapbox");var c=this._updateMapViewport(b,a),d=this._updateMapSize(b,a);this._updateMapStyle(b,a),!a.asyncRender&&(c||d)&&this.redraw(),this.props=a}}},{key:"_updateMapStyle",value:function(b,a){b.mapStyle!==a.mapStyle&&this._map.setStyle(bt(a.mapStyle),{diff:!a.preventStyleDiffing})}},{key:"_updateMapSize",value:function(b,a){var c=b.width!==a.width||b.height!==a.height;return c&&(this.width=a.width,this.height=a.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(d,e){var b=this._getViewState(d),a=this._getViewState(e),c=a.latitude!==b.latitude||a.longitude!==b.longitude||a.zoom!==b.zoom||a.pitch!==b.pitch||a.bearing!==b.bearing||a.altitude!==b.altitude;return c&&(this._map.jumpTo(this._viewStateToMapboxProps(a)),a.altitude!==b.altitude&&(this._map.transform.altitude=a.altitude)),c}},{key:"_getViewState",value:function(b){var a=b.viewState||b,f=a.longitude,g=a.latitude,h=a.zoom,c=a.pitch,d=a.bearing,e=a.altitude;return{longitude:f,latitude:g,zoom:h,pitch:void 0===c?0:c,bearing:void 0===d?0:d,altitude:void 0===e?1.5:e}}},{key:"_checkStyleSheet",value:function(){var c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==P)try{var a=P.createElement("div");if(a.className="mapboxgl-map",a.style.display="none",P.body.appendChild(a),!("static"!==window.getComputedStyle(a).position)){var b=P.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("type","text/css"),b.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(c,"/mapbox-gl.css")),P.head.appendChild(b)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}}]),a}();g(i,"initialized",!1),g(i,"propTypes",Q),g(i,"defaultProps",R),g(i,"savedMap",null);var S=b(6158),A=b.n(S);function bw(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function bx(a,b){if(a===b)return!0;if(bw(a)&&bw(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function by(a,b,c){return Math.max(b,Math.min(c,a))}function bz(a,c,b){return bw(a)?a.map(function(a,d){return bz(a,c[d],b)}):b*c+(1-b)*a}function bA(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function bB(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bC(c){for(var a=1;a0,"`scale` must be a positive number");var f=this._state,b=f.startZoom,c=f.startZoomLngLat;Number.isFinite(b)||(b=this._viewportProps.zoom,c=this._unproject(i)||this._unproject(d)),bA(c,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var g=this._calculateNewZoom({scale:e,startZoom:b||0}),j=new aY(Object.assign({},this._viewportProps,{zoom:g})),k=j.getMapCenterByLngLatPosition({lngLat:c,pos:d}),h=aA(k,2),l=h[0],m=h[1];return this._getUpdatedMapState({zoom:g,longitude:l,latitude:m})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=by(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=by(g,f,e),Object.assign(a,function({width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k=0,bearing:c=0}){(b< -180||b>180)&&(b=aD(b+180,360)-180),(c< -180||c>180)&&(c=aD(c+180,360)-180);const f=aF(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=aS([0,g])[1];if(ai&&(a=i)}}return{width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k,bearing:c}}(a)),a}},{key:"_unproject",value:function(a){var b=new aY(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new aY(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var c=a.scale,d=a.startZoom,b=this._viewportProps,e=b.maxZoom,f=b.minZoom;return by(d+Math.log2(c),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(c){var f=c.deltaScaleX,a=c.deltaScaleY,g=c.startBearing,b=c.startPitch;a=by(a,-1,1);var e=this._viewportProps,h=e.minPitch,i=e.maxPitch,d=b;return a>0?d=b+a*(i-b):a<0&&(d=b-a*(h-b)),{pitch:d,bearing:g+180*f}}},{key:"_getRotationParams",value:function(c,d){var h=c[0]-d[0],e=c[1]-d[1],i=c[1],a=d[1],f=this._viewportProps,j=f.width,g=f.height,b=0;return e>0?Math.abs(g-a)>5&&(b=e/(a-g)*1.2):e<0&&a>5&&(b=1-i/a),{deltaScaleX:h/j,deltaScaleY:b=Math.min(1,Math.max(-1,b))}}}]),a}();function bF(a){return a[0].toLowerCase()+a.slice(1)}function bG(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bH(c){for(var a=1;a1&& void 0!==arguments[1]?arguments[1]:{},b=a.current&&a.current.getMap();return b&&b.queryRenderedFeatures(c,d)}}},[]);var p=(0,c.useCallback)(function(b){var a=b.target;a===o.current&&a.scrollTo(0,0)},[]),q=d&&c.createElement(bI,{value:bN(bN({},b),{},{viewport:b.viewport||bP(bN({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:bQ,onScroll:p},a.children)),r=a.className,s=a.width,t=a.height,u=a.style,v=a.visibilityConstraints,w=Object.assign({position:"relative"},u,{width:s,height:t}),x=a.visible&&function(c){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:B;for(var a in b){var d=a.slice(0,3),e=bF(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},bQ,{visibility:x?"inherit":"hidden"});return c.createElement("div",{key:"map-container",ref:h,style:w},c.createElement("div",{key:"map-mapbox",ref:n,style:y,className:r}),q,!l&&!a.disableTokenWarning&&c.createElement(bR,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bS(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(a.s();!(b=a.n()).done;){var c=b.value;if(!bx(d[c],e[c]))return!1}}catch(f){a.e(f)}finally{a.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){bA(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}}]),a}();function bT(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function bU(a,b){return(bU=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function bV(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),a&&bU(b,a)}function bW(a){return(bW="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function bX(b,a){if(a&&("object"===bW(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return bT(b)}function bY(a){return(bY=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var bZ={longitude:1,bearing:1};function b$(a){return Number.isFinite(a)||Array.isArray(a)}function b_(b,c,a){return b in bZ&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function b0(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=b1(a))||c&&a&&"number"==typeof a.length){e&&(a=e);var d=0,b=function(){};return{s:b,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b1(a,c){if(a){if("string"==typeof a)return b2(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b2(a,c)}}function b2(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b8(a,c){if(a){if("string"==typeof a)return b9(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b9(a,c)}}function b9(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,d),g(bT(a=e.call(this)),"propNames",b3),a.props=Object.assign({},b6,b),a}bm(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=b0(b4);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];bA(b$(g)&&b$(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=b_(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=b0(b5);try{for(d.s();!(l=d.n()).done;){var b=l.value,m=h[b]||0,o=i[b]||0;e[b]=m,f[b]=b_(b,m,o)}}catch(p){d.e(p)}finally{d.f()}return{start:e,end:f}}},{key:"interpolateProps",value:function(c,d,e){var f,g=function(h,i,j,r={}){var k,l,m,c,d,e;const a={},{startZoom:s,startCenterXY:t,uDelta:u,w0:v,u1:n,S:w,rho:o,rho2:x,r0:b}=a_(h,i,r);if(n<.01){for(const f of aZ){const y=h[f],z=i[f];a[f]=(k=y,l=z,(m=j)*l+(1-m)*k)}return a}const p=j*w,A=s+aF(1/(Math.cosh(b)/Math.cosh(b+o*p))),g=(c=[],d=u,e=v*((Math.cosh(b)*Math.tanh(b+o*p)-Math.sinh(b))/x)/n,c[0]=d[0]*e,c[1]=d[1]*e,c);aK(g,g,t);const q=aS(g);return a.longitude=q[0],a.latitude=q[1],a.zoom=A,a}(c,d,e,this.props),a=b0(b5);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=bz(c[b],d[b],e)}}catch(h){a.e(h)}finally{a.f()}return g}},{key:"getDuration",value:function(c,b){var a=b.transitionDuration;return"auto"===a&&(a=function(f,g,a={}){a=Object.assign({},a$,a);const{screenSpeed:c,speed:h,maxDuration:d}=a,{S:i,rho:j}=a_(f,g,a),e=1e3*i;let b;return b=Number.isFinite(c)?e/(c/j):e/h,Number.isFinite(d)&&b>d?0:b}(c,b,this.props)),a}}])}(C);var ca=["longitude","latitude","zoom","bearing","pitch"],D=function(b){bV(a,b);var c,d,e=(c=a,d=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(c);if(d){var e=bY(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||ca,b.around&&(c.around=b.around),c}return bm(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new aY(g).unproject(this.around);Object.assign(e,c,{around:new aY(c).project(h),aroundLngLat:h})}var i,b=b7(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];bA(b$(f)&&b$(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=b_(a,f,j)}}catch(k){b.e(k)}finally{b.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(e,a,f){var g,b={},c=b7(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=bz(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var h=aA(new aY(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:bz(e.around,a.around,f)}),2),j=h[0],k=h[1];b.longitude=j,b.latitude=k}return b}}]),a}(C),r=function(){},E={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},V={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new D,transitionInterruption:E.BREAK,onTransitionStart:r,onTransitionInterrupt:r,onTransitionEnd:r},F=function(){function a(){var c=this,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};bk(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){c._animationFrame=requestAnimationFrame(c._onTransitionFrame),c._updateViewport()}),this.props=null,this.onViewportChange=b.onViewportChange||r,this.onStateChange=b.onStateChange||r,this.time=b.getTime||Date.now}return bm(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(c){var a=this.props;if(this.props=c,!a||this._shouldIgnoreViewportChange(a,c))return!1;if(this._isTransitionEnabled(c)){var d=Object.assign({},a),b=Object.assign({},c);if(this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this.state.interruption===E.SNAP_TO_END?Object.assign(d,this.state.endProps):Object.assign(d,this.state.propsInTransition),this.state.interruption===E.UPDATE)){var f,g,h,e=this.time(),i=(e-this.state.startTime)/this.state.duration;b.transitionDuration=this.state.duration-(e-this.state.startTime),b.transitionEasing=(h=(f=this.state.easing)(g=i),function(a){return 1/(1-h)*(f(a*(1-g)+g)-h)}),b.transitionInterpolator=d.transitionInterpolator}return b.onTransitionStart(),this._triggerTransition(d,b),!0}return this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(b,a){return!b||(this._isTransitionInProgress()?this.state.interruption===E.IGNORE||this._isUpdateDueToCurrentTransition(a):!this._isTransitionEnabled(a)||a.transitionInterpolator.arePropsEqual(b,a))}},{key:"_triggerTransition",value:function(b,a){bA(this._isTransitionEnabled(a)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=a.transitionInterpolator,d=c.getDuration?c.getDuration(b,a):a.transitionDuration;if(0!==d){var e=a.transitionInterpolator.initializeProps(b,a),f={inTransition:!0,isZooming:b.zoom!==a.zoom,isPanning:b.longitude!==a.longitude||b.latitude!==a.latitude,isRotating:b.bearing!==a.bearing||b.pitch!==a.pitch};this.state={duration:d,easing:a.transitionEasing,interpolator:a.transitionInterpolator,interruption:a.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var d=this.time(),a=this.state,e=a.startTime,f=a.duration,g=a.easing,h=a.interpolator,i=a.startProps,j=a.endProps,c=!1,b=(d-e)/f;b>=1&&(b=1,c=!0),b=g(b);var k=h.interpolateProps(i,j,b),l=new bE(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),a}();g(F,"defaultProps",V);var W=b(840),k=b.n(W);const cb={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(b,c){for(let a=0;ab.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(k().PointerEventInput),k().MouseInput.prototype.handler=function(a){let b=cb[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const cc=k().Manager;var e=k();const cd=e?[[e.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[e.Rotate,{enable:!1}],[e.Pinch,{enable:!1}],[e.Swipe,{enable:!1}],[e.Pan,{threshold:0,enable:!1}],[e.Press,{enable:!1}],[e.Tap,{event:"doubletap",taps:2,enable:!1}],[e.Tap,{event:"anytap",enable:!1}],[e.Tap,{enable:!1}]]:null,ce={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},cf={doubletap:["tap"]},cg={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},s={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},ch={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},ci={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},X="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",G="undefined"!=typeof window?window:b.g;void 0!==b.g&&b.g;let Y=!1;try{const l={get passive(){return Y=!0,!0}};G.addEventListener("test",l,l),G.removeEventListener("test",l,l)}catch(cj){}const ck=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:cl}=s,cm="wheel";class cn{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=cl.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent,!!Y&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cm&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(ck&&b.deltaMode===G.WheelEvent.DOM_DELTA_PIXEL&&(a/=G.devicePixelRatio),b.deltaMode===G.WheelEvent.DOM_DELTA_LINE&&(a*=40));const c={x:b.clientX,y:b.clientY};0!==a&&a%4.000244140625==0&&(a=Math.floor(a/4.000244140625)),b.shiftKey&&a&&(a*=.25),this._onWheel(b,-a,c)}_onWheel(a,b,c){this.callback({type:cm,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:co}=s,cp="pointermove",cq="pointerover",cr="pointerout",cs="pointerleave";class ct{constructor(b,c,a={}){this.element=b,this.callback=c,this.pressed=!1,this.options=Object.assign({enable:!0},a),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=co.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cp&&(this.enableMoveEvent=b),a===cq&&(this.enableOverEvent=b),a===cr&&(this.enableOutEvent=b),a===cs&&(this.enableLeaveEvent=b)}handleEvent(a){this.handleOverEvent(a),this.handleOutEvent(a),this.handleLeaveEvent(a),this.handleMoveEvent(a)}handleOverEvent(a){this.enableOverEvent&&"mouseover"===a.type&&this.callback({type:cq,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:cr,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:cs,srcEvent:a,pointerType:"mouse",target:a.target})}handleMoveEvent(a){if(this.enableMoveEvent)switch(a.type){case"mousedown":a.button>=0&&(this.pressed=!0);break;case"mousemove":0===a.which&&(this.pressed=!1),this.pressed||this.callback({type:cp,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1;break;default:}}}const{KEY_EVENTS:cu}=s,cv="keydown",cw="keyup";class cx{constructor(a,c,b={}){this.element=a,this.callback=c,this.options=Object.assign({enable:!0},b),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=cu.concat(b.events||[]),this.handleEvent=this.handleEvent.bind(this),a.tabIndex=b.tabIndex||0,a.style.outline="none",this.events.forEach(b=>a.addEventListener(b,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cv&&(this.enableDownEvent=b),a===cw&&(this.enableUpEvent=b)}handleEvent(a){const b=a.target||a.srcElement;("INPUT"!==b.tagName||"text"!==b.type)&&"TEXTAREA"!==b.tagName&&(this.enableDownEvent&&"keydown"===a.type&&this.callback({type:cv,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:cw,srcEvent:a,key:a.key,target:a.target}))}}const cy="contextmenu";class cz{constructor(a,b,c={}){this.element=a,this.callback=b,this.options=Object.assign({enable:!0},c),this.handleEvent=this.handleEvent.bind(this),a.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(a,b){a===cy&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:cy,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const cA={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cB={srcElement:"root",priority:0};class cC{constructor(a){this.eventManager=a,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(f,g,a,h=!1,i=!1){const{handlers:j,handlersByElement:e}=this;a&&("object"!=typeof a||a.addEventListener)&&(a={srcElement:a}),a=a?Object.assign({},cB,a):cB;let b=e.get(a.srcElement);b||(b=[],e.set(a.srcElement,b));const c={type:f,handler:g,srcElement:a.srcElement,priority:a.priority};h&&(c.once=!0),i&&(c.passive=!0),j.push(c),this._active=this._active||!c.passive;let d=b.length-1;for(;d>=0&&!(b[d].priority>=c.priority);)d--;b.splice(d+1,0,c)}remove(f,g){const{handlers:b,handlersByElement:e}=this;for(let c=b.length-1;c>=0;c--){const a=b[c];if(a.type===f&&a.handler===g){b.splice(c,1);const d=e.get(a.srcElement);d.splice(d.indexOf(a),1),0===d.length&&e.delete(a.srcElement)}}this._active=b.some(a=>!a.passive)}handleEvent(c){if(this.isEmpty())return;const b=this._normalizeEvent(c);let a=c.srcEvent.target;for(;a&&a!==b.rootElement;){if(this._emit(b,a),b.handled)return;a=a.parentNode}this._emit(b,"root")}_emit(e,f){const a=this.handlersByElement.get(f);if(a){let g=!1;const h=()=>{e.handled=!0},i=()=>{e.handled=!0,g=!0},c=[];for(let b=0;b{const b=this.manager.get(a);b&&ce[a].forEach(a=>{b.recognizeWith(a)})}),b.recognizerOptions){const e=this.manager.get(d);if(e){const f=b.recognizerOptions[d];delete f.enable,e.set(f)}}for(const[h,c]of(this.wheelInput=new cn(a,this._onOtherEvent,{enable:!1}),this.moveInput=new ct(a,this._onOtherEvent,{enable:!1}),this.keyInput=new cx(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new cz(a,this._onOtherEvent,{enable:!1}),this.events))c.isEmpty()||(this._toggleRecognizer(c.recognizerName,!0),this.manager.on(h,c.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(a,b,c){this._addEventHandler(a,b,c,!1)}once(a,b,c){this._addEventHandler(a,b,c,!0)}watch(a,b,c){this._addEventHandler(a,b,c,!1,!0)}off(a,b){this._removeEventHandler(a,b)}_toggleRecognizer(a,b){const{manager:d}=this;if(!d)return;const c=d.get(a);if(c&&c.options.enable!==b){c.set({enable:b});const e=cf[a];e&&!this.options.recognizers&&e.forEach(e=>{const f=d.get(e);b?(f.requireFailure(a),c.dropRequireFailure(e)):f.dropRequireFailure(a)})}this.wheelInput.enableEventType(a,b),this.moveInput.enableEventType(a,b),this.keyInput.enableEventType(a,b),this.contextmenuInput.enableEventType(a,b)}_addEventHandler(b,e,d,f,g){if("string"!=typeof b){for(const h in d=e,b)this._addEventHandler(h,b[h],d,f,g);return}const{manager:i,events:j}=this,c=ci[b]||b;let a=j.get(c);!a&&(a=new cC(this),j.set(c,a),a.recognizerName=ch[c]||c,i&&i.on(c,a.handleEvent)),a.add(b,e,d,f,g),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(a,h){if("string"!=typeof a){for(const c in a)this._removeEventHandler(c,a[c]);return}const{events:d}=this,i=ci[a]||a,b=d.get(i);if(b&&(b.remove(a,h),b.isEmpty())){const{recognizerName:e}=b;let f=!1;for(const g of d.values())if(g.recognizerName===e&&!g.isEmpty()){f=!0;break}f||this._toggleRecognizer(e,!1)}}_onBasicInput(a){const{srcEvent:c}=a,b=cg[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function cE(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function cF(c){for(var a=1;a0),e=d&&!this.state.isHovering,h=!d&&this.state.isHovering;(c||e)&&(a.features=b,c&&c(a)),e&&cO.call(this,"onMouseEnter",a),h&&cO.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function cS(b){var c=this.props,d=c.onClick,f=c.onNativeClick,g=c.onDblClick,h=c.doubleClickZoom,a=[],e=g||h;switch(b.type){case"anyclick":a.push(f),e||a.push(d);break;case"click":e&&a.push(d);break;default:}(a=a.filter(Boolean)).length&&((b=cM.call(this,b)).features=cN.call(this,b.point),a.forEach(function(a){return a(b)}))}var m=(0,c.forwardRef)(function(b,h){var i,t,f=(0,c.useContext)(bJ),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new cD(null,{touchAction:b.touchAction,recognizerOptions:b.eventRecognizerOptions})},[]),g=(0,c.useRef)(null),e=(0,c.useRef)(null),a=(0,c.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;a.props=b,a.map=e.current&&e.current.getMap(),a.setState=function(c){a.state=cL(cL({},a.state),c),g.current.style.cursor=b.getCursor(a.state)};var j=!0,k=function(b,c,d){if(j){i=[b,c,d];return}var e=a.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(b,"position",{get:function(){return[0,0,bL(a.map,b)]}}),f&&f({viewState:b,interactionState:c,oldViewState:d}),g&&g(b,c,d)};(0,c.useImperativeHandle)(h,function(){var a;return{getMap:(a=e).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var d=(0,c.useMemo)(function(){return cL(cL({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||bP(a),a.viewport=d.viewport;var w=function(b){var c=b.isDragging,d=void 0!==c&&c;if(d!==a.state.isDragging&&a.setState({isDragging:d}),j){t=b;return}var e=a.props.onInteractionStateChange;e&&e(b)},l=function(){a.width&&a.height&&u.setOptions(cL(cL(cL({},a.props),a.props.viewState),{},{isInteractive:Boolean(a.props.onViewStateChange||a.props.onViewportChange),onViewportChange:k,onStateChange:w,eventManager:v,width:a.width,height:a.height}))},m=function(b){var c=b.width,d=b.height;a.width=c,a.height=d,l(),a.props.onResize({width:c,height:d})};(0,c.useEffect)(function(){return v.setElement(g.current),v.on({pointerdown:cP.bind(a),pointermove:cR.bind(a),pointerup:cQ.bind(a),pointerleave:cO.bind(a,"onMouseOut"),click:cS.bind(a),anyclick:cS.bind(a),dblclick:cO.bind(a,"onDblClick"),wheel:cO.bind(a,"onWheel"),contextmenu:cO.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),bK(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return ax(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ay(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}t&&w(t)}),l();var n=b.width,o=b.height,p=b.style,r=b.getCursor,s=(0,c.useMemo)(function(){return cL(cL({position:"relative"},p),{},{width:n,height:o,cursor:r(a.state)})},[p,n,o,r,a.state]);return i&&a._child||(a._child=c.createElement(bI,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,aw({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var cT=m;function cU(b,a){if(b===a)return!0;if(!b||!a)return!1;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!==a.length)return!1;for(var c=0;c prop: ".concat(e))}}(d,a,f.current):d=function(a,c,d){if(a.style&&a.style._loaded){var b=function(c){for(var a=1;a=0||(d[a]=c[a]);return d}(a,d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(a,b)&&(e[b]=a[b])}return e}(d,["layout","paint","filter","minzoom","maxzoom","beforeId"]);if(p!==a.beforeId&&b.moveLayer(c,p),e!==a.layout){var q=a.layout||{};for(var g in e)cU(e[g],q[g])||b.setLayoutProperty(c,g,e[g]);for(var r in q)e.hasOwnProperty(r)||b.setLayoutProperty(c,r,void 0)}if(f!==a.paint){var s=a.paint||{};for(var h in f)cU(f[h],s[h])||b.setPaintProperty(c,h,f[h]);for(var t in s)f.hasOwnProperty(t)||b.setPaintProperty(c,t,void 0)}for(var i in cU(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)cU(j[i],a[i])||b.setLayerProperty(c,i,j[i])}(c,d,a,b)}catch(e){console.warn(e)}}(a,d,b,e.current):function(a,d,b){if(a.style&&a.style._loaded){var c=cY(cY({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ab;var f={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},d={captureScroll:a.bool,captureDrag:a.bool,captureClick:a.bool,captureDoubleClick:a.bool,capturePointerMove:a.bool};function c$(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(bJ),e=(0,c.useRef)(null),f=(0,c.useRef)({props:d,state:{},context:a,containerRef:e}),b=f.current;return b.props=d,b.context=a,(0,c.useEffect)(function(){return function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(c){var b=a.props;b.captureScroll&&c.stopPropagation(),b.onScroll&&b.onScroll(c,a)},panstart:function(c){var b=a.props;b.captureDrag&&c.stopPropagation(),b.onDragStart&&b.onDragStart(c,a)},anyclick:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onNativeClick&&b.onNativeClick(c,a)},click:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onClick&&b.onClick(c,a)},dblclick:function(c){var b=a.props;b.captureDoubleClick&&c.stopPropagation(),b.onDoubleClick&&b.onDoubleClick(c,a)},pointermove:function(c){var b=a.props;b.capturePointerMove&&c.stopPropagation(),b.onPointerMove&&b.onPointerMove(c,a)}};return c.watch(d,b),function(){c.off(d)}}}(b)},[a.eventManager]),b}function c_(b){var a=b.instance,c=c$(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){bV(a,b);var d,e,f=(d=a,e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(d);if(e){var c=bY(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var b;bk(this,a);for(var e=arguments.length,h=new Array(e),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var c="x"===d?a.offsetWidth:a.offsetHeight;return c6(b/100*c)/c*100};function c8(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}var ae=Object.assign({},ac,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),af=Object.assign({},ad,{className:""});function t(b){var d,j,e,k,f,l,m,a,h=(d=b,e=(j=aA((0,c.useState)(null),2))[0],k=j[1],f=aA((0,c.useState)(null),2),l=f[0],m=f[1],a=c$(c1(c1({},d),{},{onDragStart:c4})),a.callbacks=d,a.state.dragPos=e,a.state.setDragPos=k,a.state.dragOffset=l,a.state.setDragOffset=m,(0,c.useEffect)(function(){return function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return function(b,a){var h=a.props,c=a.callbacks,d=a.state,i=a.context;b.stopPropagation();var e=c2(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=c3(e,f,h,i),c.onDrag(g)}}(b,a)},panend:function(b){return function(c,a){var h=a.props,d=a.callbacks,b=a.state,i=a.context;c.stopPropagation();var e=b.dragPos,f=b.dragOffset;if(b.setDragPos(null),b.setDragOffset(null),d.onDragEnd&&e&&f){var g=Object.assign({},c);g.lngLat=c3(e,f,h,i),d.onDragEnd(g)}}(b,a)},pancancel:function(d){var c,b;return c=d,b=a.state,void(c.stopPropagation(),b.setDragPos(null),b.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}}(a)},[a.context.eventManager,Boolean(e)]),a),o=h.state,p=h.containerRef,q=b.children,r=b.className,s=b.draggable,A=b.style,t=o.dragPos,u=function(b){var a=b.props,e=b.state,f=b.context,g=a.longitude,h=a.latitude,j=a.offsetLeft,k=a.offsetTop,c=e.dragPos,d=e.dragOffset,l=f.viewport,m=f.map;if(c&&d)return[c[0]+d[0],c[1]+d[1]];var n=bL(m,{longitude:g,latitude:h}),i=aA(l.project([g,h,n]),2),o=i[0],p=i[1];return[o+=j,p+=k]}(h),n=aA(u,2),v=n[0],w=n[1],x="translate(".concat(c6(v),"px, ").concat(c6(w),"px)"),y=s?t?"grabbing":"grab":"auto",z=(0,c.useMemo)(function(){var a=function(c){for(var a=1;a0){var t=b,u=e;for(b=0;b<=1;b+=.5)k=(i=n-b*h)+h,e=Math.max(0,d-i)+Math.max(0,k-p+d),e0){var w=a,x=f;for(a=0;a<=1;a+=v)l=(j=m-a*g)+g,f=Math.max(0,d-j)+Math.max(0,l-o+d),f1||h< -1||f<0||f>p.width||g<0||g>p.height?i.display="none":i.zIndex=Math.floor((1-h)/2*1e5)),i),S=(0,c.useCallback)(function(b){t.props.onClose();var a=t.context.eventManager;a&&a.once("click",function(a){return a.stopPropagation()},b.target)},[]);return c.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(L," ").concat(N),style:R,ref:u},c.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:O}}),c.createElement("div",{key:"content",ref:j,className:"mapboxgl-popup-content"},P&&c.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:S},"\xd7"),Q))}function da(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}u.propTypes=ag,u.defaultProps=ah,c.memo(u);var ai=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string)])}),aj=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=c$(a),d=b.context,i=b.containerRef,j=(0,c.useRef)(null),e=aA((0,c.useState)(!1),2),f=e[0],m=e[1];(0,c.useEffect)(function(){var h,e,c,f,g,b;return d.map&&(h=(e={customAttribution:a.customAttribution},c=d.map,f=i.current,g=j.current,(b=new(A()).AttributionControl(e))._map=c,b._container=f,b._innerContainer=g,b._updateAttributions(),b._updateEditLink(),c.on("styledata",b._updateData),c.on("sourcedata",b._updateData),b)),function(){var a;return h&&void((a=h)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[d.map]);var h=void 0===a.compact?d.viewport.width<=640:a.compact;(0,c.useEffect)(function(){!h&&f&&m(!1)},[h]);var k=(0,c.useCallback)(function(){return m(function(a){return!a})},[]),l=(0,c.useMemo)(function(){return function(c){for(var a=1;ac)return 1}return 0}(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),f=b.viewport.bearing,d={transform:"rotate(".concat(-f,"deg)")},2===e?c.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:d}):c.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:d})))))}function di(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}y.propTypes=ao,y.defaultProps=ap,c.memo(y);var aq=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ar=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=c$(a),f=d.context,h=d.containerRef,e=aA((0,c.useState)(null),2),b=e[0],j=e[1];(0,c.useEffect)(function(){if(f.map){var a=new(A()).ScaleControl;a._map=f.map,a._container=h.current,j(a)}},[f.map]),b&&(b.options=a,b._onMove());var i=(0,c.useMemo)(function(){return function(c){for(var a=1;a\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=an(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=ao(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=as(j,k),a.distance=ar(j,k),al(b,a),a.offsetDirection=aq(a.deltaX,a.deltaY);var d=ap(a.deltaTime,a.deltaX,a.deltaY);a.overallVelocityX=d.x,a.overallVelocityY=d.y,a.overallVelocity=T(d.x)>T(d.y)?d.x:d.y,a.scale=c?au(c.pointers,e):1,a.rotation=c?at(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,am(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function al(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function am(h,a){var d,e,f,g,b=h.lastInterval||a,i=a.timeStamp-b.timeStamp;if(8!=a.eventType&&(i>25||l===b.velocity)){var j=a.deltaX-b.deltaX,k=a.deltaY-b.deltaY,c=ap(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=aq(j,k),h.lastInterval=a}else d=b.velocity,e=b.velocityX,f=b.velocityY,g=b.direction;a.velocity=d,a.velocityX=e,a.velocityY=f,a.direction=g}function an(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ar(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function as(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function at(a,b){return as(b[1],b[0],ai)+as(a[1],a[0],ai)}function au(a,b){return ar(b[0],b[1],ai)/ar(a[0],a[1],ai)}f.prototype={handler:function(){},init:function(){this.evEl&&H(this.element,this.evEl,this.domHandler),this.evTarget&&H(this.target,this.evTarget,this.domHandler),this.evWin&&H(ae(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&I(this.element,this.evEl,this.domHandler),this.evTarget&&I(this.target,this.evTarget,this.domHandler),this.evWin&&I(ae(this.element),this.evWin,this.domHandler)}};var av={mousedown:1,mousemove:2,mouseup:4};function u(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,f.apply(this,arguments)}e(u,f,{handler:function(a){var b=av[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:L,srcEvent:a}))}});var aw={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},ax={2:K,3:"pen",4:L,5:"kinect"},M="pointerdown",N="pointermove pointerup pointercancel";function v(){this.evEl=M,this.evWin=N,f.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}g.MSPointerEvent&&!g.PointerEvent&&(M="MSPointerDown",N="MSPointerMove MSPointerUp MSPointerCancel"),e(v,f,{handler:function(a){var b=this.store,e=!1,d=aw[a.type.toLowerCase().replace("ms","")],f=ax[a.pointerType]||a.pointerType,c=aa(b,a.pointerId,"pointerId");1&d&&(0===a.button||f==K)?c<0&&(b.push(a),c=b.length-1):12&d&&(e=!0),!(c<0)&&(b[c]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),e&&b.splice(c,1))}});var ay={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function w(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,f.apply(this,arguments)}function az(b,d){var a=ab(b.touches),c=ab(b.changedTouches);return 12&d&&(a=ac(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ay[c.type];if(1===a&&(this.started=!0),this.started){var b=az.call(this,c,a);12&a&&b[0].length-b[1].length==0&&(this.started=!1),this.callback(this.manager,a,{pointers:b[0],changedPointers:b[1],pointerType:K,srcEvent:c})}}});var aA={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function x(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},f.apply(this,arguments)}function aB(h,g){var b=ab(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ab(h.changedTouches),f=[],i=this.target;if(d=b.filter(function(a){return Z(a.target,i)}),1===g)for(a=0;a -1&&d.splice(a,1)},2500)}}function aE(b){for(var d=b.srcEvent.clientX,e=b.srcEvent.clientY,a=0;a -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(d){var c=this,a=this.state;function b(a){c.manager.emit(a,d)}a<8&&b(c.options.event+aM(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+aM(a))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ac.threshold&&b&c.direction},attrTest:function(a){return h.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=aN(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),e(p,h,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),e(q,i,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[aG]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=V(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=U(),this.manager.emit(this.options.event,this._input)))}}),e(r,h,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),e(s,h,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return o.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&T(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=aN(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),e(j,i,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[aH]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var a=1;ac.length)&&(a=c.length);for(var b=0,d=new Array(a);bc?c:a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),bc=new h(4),h!=Float32Array&&(bc[0]=0,bc[1]=0,bc[2]=0,bc[3]=0);const aF=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function aG(e,f,g){var h=f[0],i=f[1],j=f[2],k=f[3],l=f[4],m=f[5],n=f[6],o=f[7],p=f[8],q=f[9],r=f[10],s=f[11],t=f[12],u=f[13],v=f[14],w=f[15],a=g[0],b=g[1],c=g[2],d=g[3];return e[0]=a*h+b*l+c*p+d*t,e[1]=a*i+b*m+c*q+d*u,e[2]=a*j+b*n+c*r+d*v,e[3]=a*k+b*o+c*s+d*w,a=g[4],b=g[5],c=g[6],d=g[7],e[4]=a*h+b*l+c*p+d*t,e[5]=a*i+b*m+c*q+d*u,e[6]=a*j+b*n+c*r+d*v,e[7]=a*k+b*o+c*s+d*w,a=g[8],b=g[9],c=g[10],d=g[11],e[8]=a*h+b*l+c*p+d*t,e[9]=a*i+b*m+c*q+d*u,e[10]=a*j+b*n+c*r+d*v,e[11]=a*k+b*o+c*s+d*w,a=g[12],b=g[13],c=g[14],d=g[15],e[12]=a*h+b*l+c*p+d*t,e[13]=a*i+b*m+c*q+d*u,e[14]=a*j+b*n+c*r+d*v,e[15]=a*k+b*o+c*s+d*w,e}function aH(b,a,f){var g,h,i,j,k,l,m,n,o,p,q,r,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],b[0]=g,b[1]=h,b[2]=i,b[3]=j,b[4]=k,b[5]=l,b[6]=m,b[7]=n,b[8]=o,b[9]=p,b[10]=q,b[11]=r,b[12]=g*c+k*d+o*e+a[12],b[13]=h*c+l*d+p*e+a[13],b[14]=i*c+m*d+q*e+a[14],b[15]=j*c+n*d+r*e+a[15]),b}function aI(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function aJ(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function aK(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function aL(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function aM(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}bd=new h(2),h!=Float32Array&&(bd[0]=0,bd[1]=0),be=new h(3),h!=Float32Array&&(be[0]=0,be[1]=0,be[2]=0);const n=Math.PI,aN=n/4,aO=n/180,aP=180/n;function aQ(a){return Math.pow(2,a)}function aR([b,a]){return aM(Number.isFinite(b)),aM(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*aO+n)/(2*n),512*(n+Math.log(Math.tan(aN+.5*(a*aO))))/(2*n)]}function aS([a,b]){return[(a/512*(2*n)-n)*aP,2*(Math.atan(Math.exp(b/512*(2*n)-n))-aN)*aP]}function aT(a){return 2*Math.atan(.5/a)*aP}function aU(a){return .5/Math.tan(.5*a*aO)}function aV(i,c,j=0){const[a,b,e]=i;if(aM(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=aC(c,[a,b,e,1]);return k}const f=aC(c,[a,b,0,1]),g=aC(c,[a,b,1,1]),d=f[2],h=g[2];return aL([],f,g,d===h?0:((j||0)-d)/(h-d))}const aW=Math.PI/180;function aX(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=aC(e,[c,0,1,1]),f=aC(e,[c,a.height,1,1]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=aL([],b,f,i),g=aS(j);return g[2]=d,g}class aY{constructor({width:f,height:c,latitude:l=0,longitude:m=0,zoom:p=0,pitch:n=0,bearing:q=0,altitude:a=null,fovy:b=null,position:o=null,nearZMultiplier:t=.02,farZMultiplier:u=1.01}={width:1,height:1}){f=f||1,c=c||1,null===b&&null===a?b=aT(a=1.5):null===b?b=aT(a):null===a&&(a=aU(b));const r=aQ(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){aM(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*aO),e=1.4222222222222223/d,a=12790407194604047e-21/d;if(b.unitsPerMeter=[a,a,a],b.metersPerUnit=[1/a,1/a,1/a],b.unitsPerDegree=[1.4222222222222223,e,a],b.degreesPerUnit=[.703125,1/e,1/a],j){const f=aO*Math.tan(c*aO)/d,k=1.4222222222222223*f/2,g=12790407194604047e-21*f,h=g/e*a;b.unitsPerDegree2=[0,k,g],b.unitsPerMeter2=[h,0,h]}return b}({longitude:m,latitude:l}),d=aR([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,k=(e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],e),i[0]=j[0]+k[0],i[1]=j[1]+k[1],i[2]=j[2]+k[2]}this.projectionMatrix=function({width:h,height:i,pitch:j,altitude:k,fovy:l,nearZMultiplier:m,farZMultiplier:n}){var a,f,g,c,b,d,e;const{fov:o,aspect:p,near:q,far:r}=function({width:f,height:g,fovy:a=aT(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=aT(d));const b=.5*a*aO,c=aU(a),e=h*aO;return{fov:2*b,aspect:f/g,focalDistance:c,near:i,far:(Math.sin(e)*(Math.sin(b)*c/Math.sin(Math.min(Math.max(Math.PI/2-e-b,.01),Math.PI-.01)))+c)*j}}({width:h,height:i,altitude:k,fovy:l,pitch:j,nearZMultiplier:m,farZMultiplier:n}),s=(a=[],f=o,g=p,c=q,b=r,e=1/Math.tan(f/2),a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(d=1/(c-b),a[10]=(b+c)*d,a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a);return s}({width:f,height:c,pitch:n,fovy:b,nearZMultiplier:t,farZMultiplier:u}),this.viewMatrix=function({height:F,pitch:G,bearing:H,altitude:I,scale:l,center:E=null}){var a,b,m,f,g,n,o,p,q,r,s,t,u,c,d,v,h,i,w,x,y,z,A,B,C,D,j,k;const e=aB();return aH(e,e,[0,0,-I]),a=e,b=e,m=-G*aO,f=Math.sin(m),g=Math.cos(m),n=b[4],o=b[5],p=b[6],q=b[7],r=b[8],s=b[9],t=b[10],u=b[11],b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=n*g+r*f,a[5]=o*g+s*f,a[6]=p*g+t*f,a[7]=q*g+u*f,a[8]=r*g-n*f,a[9]=s*g-o*f,a[10]=t*g-p*f,a[11]=u*g-q*f,c=e,d=e,v=H*aO,h=Math.sin(v),i=Math.cos(v),w=d[0],x=d[1],y=d[2],z=d[3],A=d[4],B=d[5],C=d[6],D=d[7],d!==c&&(c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15]),c[0]=w*i+A*h,c[1]=x*i+B*h,c[2]=y*i+C*h,c[3]=z*i+D*h,c[4]=A*i-w*h,c[5]=B*i-x*h,c[6]=C*i-y*h,c[7]=D*i-z*h,aI(e,e,[l/=F,l,l]),E&&aH(e,e,(j=[],k=E,j[0]=-k[0],j[1]=-k[1],j[2]=-k[2],j)),e}({height:c,scale:r,center:d,pitch:n,bearing:q,altitude:a}),this.width=f,this.height=c,this.scale=r,this.latitude=l,this.longitude=m,this.zoom=p,this.pitch=n,this.bearing=q,this.altitude=a,this.fovy=b,this.center=d,this.meterOffset=o||[0,0,0],this.distanceScales=s,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,a;const{width:I,height:J,projectionMatrix:K,viewMatrix:L}=this,G=aB();aG(G,G,K),aG(G,G,L),this.viewProjectionMatrix=G;const d=aB();aI(d,d,[I/2,-J/2,1]),aH(d,d,[1,-1,0]),aG(d,d,G);const H=(b=aB(),e=(c=d)[0],f=c[1],g=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=c[8],n=c[9],o=c[10],p=c[11],q=c[12],r=c[13],s=c[14],t=c[15],u=e*j-f*i,v=e*k-g*i,w=e*l-h*i,x=f*k-g*j,y=f*l-h*j,z=g*l-h*k,A=m*r-n*q,B=m*s-o*q,C=m*t-p*q,D=n*s-o*r,E=n*t-p*r,F=o*t-p*s,a=u*F-v*E+w*D+x*C-y*B+z*A,a?(a=1/a,b[0]=(j*F-k*E+l*D)*a,b[1]=(g*E-f*F-h*D)*a,b[2]=(r*z-s*y+t*x)*a,b[3]=(o*y-n*z-p*x)*a,b[4]=(k*C-i*F-l*B)*a,b[5]=(e*F-g*C+h*B)*a,b[6]=(s*w-q*z-t*v)*a,b[7]=(m*z-o*w+p*v)*a,b[8]=(i*E-j*C+l*A)*a,b[9]=(f*C-e*E-h*A)*a,b[10]=(q*y-r*w+t*u)*a,b[11]=(n*w-m*y-p*u)*a,b[12]=(j*B-i*D-k*A)*a,b[13]=(e*D-f*B+g*A)*a,b[14]=(r*v-q*x-s*u)*a,b[15]=(m*x-n*v+o*u)*a,b):null);if(!H)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=H}equals(a){return a instanceof aY&&a.width===this.width&&a.height===this.height&&aJ(a.projectionMatrix,this.projectionMatrix)&&aJ(a.viewMatrix,this.viewMatrix)}project(a,{topLeft:f=!0}={}){const g=this.projectPosition(a),b=function(d,e){const[a,b,c=0]=d;return aM(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),aC(e,[a,b,c,1])}(g,this.pixelProjectionMatrix),[c,d]=b,e=f?d:this.height-d;return 2===a.length?[c,e]:[c,e,b[2]]}unproject(f,{topLeft:g=!0,targetZ:a}={}){const[h,d,e]=f,i=g?d:this.height-d,j=a&&a*this.distanceScales.unitsPerMeter[2],k=aV([h,i,e],this.pixelUnprojectionMatrix,j),[b,c,l]=this.unprojectPosition(k);return Number.isFinite(e)?[b,c,l]:Number.isFinite(a)?[b,c,a]:[b,c]}projectPosition(a){const[b,c]=aR(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=aS(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return aR(a)}unprojectFlat(a){return aS(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=aV(d,this.pixelUnprojectionMatrix),f=aR(c),g=aK([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=aK([],this.center,g);return aS(h)}getLocationAtPoint({lngLat:a,pos:b}){return this.getMapCenterByLngLatPosition({lngLat:a,pos:b})}fitBounds(c,d={}){const{width:a,height:b}=this,{longitude:e,latitude:f,zoom:g}=function({width:m,height:n,bounds:o,minExtent:f=0,maxZoom:p=24,padding:a=0,offset:g=[0,0]}){const[[q,r],[s,t]]=o;if(Number.isFinite(a)){const b=a;a={top:b,bottom:b,left:b,right:b}}else aM(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=aR([q,aE(t,-85.051129,85.051129)]),d=aR([s,aE(r,-85.051129,85.051129)]),h=[Math.max(Math.abs(d[0]-c[0]),f),Math.max(Math.abs(d[1]-c[1]),f)],e=[m-a.left-a.right-2*Math.abs(g[0]),n-a.top-a.bottom-2*Math.abs(g[1])];aM(e[0]>0&&e[1]>0);const i=e[0]/h[0],j=e[1]/h[1],u=(a.right-a.left)/2/i,v=(a.bottom-a.top)/2/j,w=[(d[0]+c[0])/2+u,(d[1]+c[1])/2+v],k=aS(w),l=Math.min(p,aF(Math.abs(Math.min(i,j))));return aM(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new aY({width:a,height:b,longitude:e,latitude:f,zoom:g})}getBounds(b){const a=this.getBoundingRegion(b),c=Math.min(...a.map(a=>a[0])),d=Math.max(...a.map(a=>a[0])),e=Math.min(...a.map(a=>a[1])),f=Math.max(...a.map(a=>a[1]));return[[c,e],[d,f]]}getBoundingRegion(a={}){return function(a,d=0){const{width:e,height:h,unproject:b}=a,c={targetZ:d},i=b([0,h],c),j=b([e,h],c);let f,g;const k=a.fovy?.5*a.fovy*aW:Math.atan(.5/a.altitude),l=(90-a.pitch)*aW;return k>l-.01?(f=aX(a,0,d),g=aX(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const aZ=["longitude","latitude","zoom"],a$={curve:1.414,speed:1.2};function a_(d,h,i){var f,j,k,o,p,q;i=Object.assign({},a$,i);const g=i.curve,l=d.zoom,w=[d.longitude,d.latitude],x=aQ(l),y=h.zoom,z=[h.longitude,h.latitude],A=aQ(y-l),r=aR(w),B=aR(z),s=(f=[],j=B,k=r,f[0]=j[0]-k[0],f[1]=j[1]-k[1],f),a=Math.max(d.width,d.height),e=a/A,t=(p=(o=s)[0],q=o[1],Math.hypot(p,q)*x),c=Math.max(t,.01),b=g*g,m=(e*e-a*a+b*b*c*c)/(2*a*b*c),n=(e*e-a*a-b*b*c*c)/(2*e*b*c),u=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(n*n+1)-n);return{startZoom:l,startCenterXY:r,uDelta:s,w0:a,u1:t,S:(v-u)/g,rho:g,rho2:b,r0:u,r1:v}}var N=function(){if("undefined"!=typeof Map)return Map;function a(a,c){var b=-1;return a.some(function(a,d){return a[0]===c&&(b=d,!0)}),b}return function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(c){var d=a(this.__entries__,c),b=this.__entries__[d];return b&&b[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(d){var b=this.__entries__,c=a(b,d);~c&&b.splice(c,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(e,a){void 0===a&&(a=null);for(var b=0,c=this.__entries__;b0},a.prototype.connect_=function(){a0&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),a3?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){a0&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(b){var a=b.propertyName,c=void 0===a?"":a;a2.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null,a}(),a5=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),bi="undefined"!=typeof WeakMap?new WeakMap:new N,O=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=a4.getInstance(),d=new bh(b,c,this);bi.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=bi.get(this))[a].apply(b,arguments)}});var bj=void 0!==o.ResizeObserver?o.ResizeObserver:O;function bk(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function bl(d,c){for(var b=0;b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function bq(a,c){if(a){if("string"==typeof a)return br(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return br(a,c)}}function br(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b1&& void 0!==arguments[1]?arguments[1]:"component";b.debug&&a.checkPropTypes(Q,b,"prop",c)}var i=function(){function a(b){var c=this;if(bk(this,a),g(this,"props",R),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return bm(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var d=this._map.getContainer(),c=b.container;for(c.classList.add("mapboxgl-map");d.childNodes.length>0;)c.appendChild(d.childNodes[0]);this._map._container=c,a.savedMap=null,b.mapStyle&&this._map.setStyle(bt(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var d=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=d,b.gl}}var c={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:bt(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(c.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},c,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var d=this;bv(a=Object.assign({},R,a),"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||R.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var b=a.container;Object.defineProperty(b,"offsetWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"clientWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"offsetHeight",{configurable:!0,get:function(){return d.height}}),Object.defineProperty(b,"clientHeight",{configurable:!0,get:function(){return d.height}});var c=this._map.getCanvas();c&&(c.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(b,a){if(this._map){bv(a=Object.assign({},this.props,a),"Mapbox");var c=this._updateMapViewport(b,a),d=this._updateMapSize(b,a);this._updateMapStyle(b,a),!a.asyncRender&&(c||d)&&this.redraw(),this.props=a}}},{key:"_updateMapStyle",value:function(b,a){b.mapStyle!==a.mapStyle&&this._map.setStyle(bt(a.mapStyle),{diff:!a.preventStyleDiffing})}},{key:"_updateMapSize",value:function(b,a){var c=b.width!==a.width||b.height!==a.height;return c&&(this.width=a.width,this.height=a.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(d,e){var b=this._getViewState(d),a=this._getViewState(e),c=a.latitude!==b.latitude||a.longitude!==b.longitude||a.zoom!==b.zoom||a.pitch!==b.pitch||a.bearing!==b.bearing||a.altitude!==b.altitude;return c&&(this._map.jumpTo(this._viewStateToMapboxProps(a)),a.altitude!==b.altitude&&(this._map.transform.altitude=a.altitude)),c}},{key:"_getViewState",value:function(b){var a=b.viewState||b,f=a.longitude,g=a.latitude,h=a.zoom,c=a.pitch,d=a.bearing,e=a.altitude;return{longitude:f,latitude:g,zoom:h,pitch:void 0===c?0:c,bearing:void 0===d?0:d,altitude:void 0===e?1.5:e}}},{key:"_checkStyleSheet",value:function(){var c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==P)try{var a=P.createElement("div");if(a.className="mapboxgl-map",a.style.display="none",P.body.appendChild(a),!("static"!==window.getComputedStyle(a).position)){var b=P.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("type","text/css"),b.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(c,"/mapbox-gl.css")),P.head.appendChild(b)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}}]),a}();g(i,"initialized",!1),g(i,"propTypes",Q),g(i,"defaultProps",R),g(i,"savedMap",null);var S=b(6158),A=b.n(S);function bw(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function bx(a,b){if(a===b)return!0;if(bw(a)&&bw(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function by(a,b,c){return Math.max(b,Math.min(c,a))}function bz(a,c,b){return bw(a)?a.map(function(a,d){return bz(a,c[d],b)}):b*c+(1-b)*a}function bA(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function bB(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bC(c){for(var a=1;a0,"`scale` must be a positive number");var f=this._state,b=f.startZoom,c=f.startZoomLngLat;Number.isFinite(b)||(b=this._viewportProps.zoom,c=this._unproject(i)||this._unproject(d)),bA(c,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var g=this._calculateNewZoom({scale:e,startZoom:b||0}),j=new aY(Object.assign({},this._viewportProps,{zoom:g})),k=j.getMapCenterByLngLatPosition({lngLat:c,pos:d}),h=aA(k,2),l=h[0],m=h[1];return this._getUpdatedMapState({zoom:g,longitude:l,latitude:m})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=by(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=by(g,f,e),Object.assign(a,function({width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k=0,bearing:c=0}){(b< -180||b>180)&&(b=aD(b+180,360)-180),(c< -180||c>180)&&(c=aD(c+180,360)-180);const f=aF(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=aS([0,g])[1];if(ai&&(a=i)}}return{width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k,bearing:c}}(a)),a}},{key:"_unproject",value:function(a){var b=new aY(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new aY(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var c=a.scale,d=a.startZoom,b=this._viewportProps,e=b.maxZoom,f=b.minZoom;return by(d+Math.log2(c),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(c){var f=c.deltaScaleX,a=c.deltaScaleY,g=c.startBearing,b=c.startPitch;a=by(a,-1,1);var e=this._viewportProps,h=e.minPitch,i=e.maxPitch,d=b;return a>0?d=b+a*(i-b):a<0&&(d=b-a*(h-b)),{pitch:d,bearing:g+180*f}}},{key:"_getRotationParams",value:function(c,d){var h=c[0]-d[0],e=c[1]-d[1],i=c[1],a=d[1],f=this._viewportProps,j=f.width,g=f.height,b=0;return e>0?Math.abs(g-a)>5&&(b=e/(a-g)*1.2):e<0&&a>5&&(b=1-i/a),{deltaScaleX:h/j,deltaScaleY:b=Math.min(1,Math.max(-1,b))}}}]),a}();function bF(a){return a[0].toLowerCase()+a.slice(1)}function bG(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bH(c){for(var a=1;a1&& void 0!==arguments[1]?arguments[1]:{},b=a.current&&a.current.getMap();return b&&b.queryRenderedFeatures(c,d)}}},[]);var p=(0,c.useCallback)(function(b){var a=b.target;a===o.current&&a.scrollTo(0,0)},[]),q=d&&c.createElement(bI,{value:bN(bN({},b),{},{viewport:b.viewport||bP(bN({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:bQ,onScroll:p},a.children)),r=a.className,s=a.width,t=a.height,u=a.style,v=a.visibilityConstraints,w=Object.assign({position:"relative"},u,{width:s,height:t}),x=a.visible&&function(c){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:B;for(var a in b){var d=a.slice(0,3),e=bF(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},bQ,{visibility:x?"inherit":"hidden"});return c.createElement("div",{key:"map-container",ref:h,style:w},c.createElement("div",{key:"map-mapbox",ref:n,style:y,className:r}),q,!l&&!a.disableTokenWarning&&c.createElement(bR,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bS(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(a.s();!(b=a.n()).done;){var c=b.value;if(!bx(d[c],e[c]))return!1}}catch(f){a.e(f)}finally{a.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){bA(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}}]),a}();function bT(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function bU(a,b){return(bU=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function bV(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),a&&bU(b,a)}function bW(a){return(bW="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function bX(b,a){if(a&&("object"===bW(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return bT(b)}function bY(a){return(bY=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var bZ={longitude:1,bearing:1};function b$(a){return Number.isFinite(a)||Array.isArray(a)}function b_(b,c,a){return b in bZ&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function b0(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=b1(a))||c&&a&&"number"==typeof a.length){e&&(a=e);var d=0,b=function(){};return{s:b,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b1(a,c){if(a){if("string"==typeof a)return b2(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b2(a,c)}}function b2(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b8(a,c){if(a){if("string"==typeof a)return b9(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b9(a,c)}}function b9(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,d),g(bT(a=e.call(this)),"propNames",b3),a.props=Object.assign({},b6,b),a}bm(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=b0(b4);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];bA(b$(g)&&b$(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=b_(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=b0(b5);try{for(d.s();!(l=d.n()).done;){var b=l.value,m=h[b]||0,o=i[b]||0;e[b]=m,f[b]=b_(b,m,o)}}catch(p){d.e(p)}finally{d.f()}return{start:e,end:f}}},{key:"interpolateProps",value:function(c,d,e){var f,g=function(h,i,j,r={}){var k,l,m,c,d,e;const a={},{startZoom:s,startCenterXY:t,uDelta:u,w0:v,u1:n,S:w,rho:o,rho2:x,r0:b}=a_(h,i,r);if(n<.01){for(const f of aZ){const y=h[f],z=i[f];a[f]=(k=y,l=z,(m=j)*l+(1-m)*k)}return a}const p=j*w,A=s+aF(1/(Math.cosh(b)/Math.cosh(b+o*p))),g=(c=[],d=u,e=v*((Math.cosh(b)*Math.tanh(b+o*p)-Math.sinh(b))/x)/n,c[0]=d[0]*e,c[1]=d[1]*e,c);aK(g,g,t);const q=aS(g);return a.longitude=q[0],a.latitude=q[1],a.zoom=A,a}(c,d,e,this.props),a=b0(b5);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=bz(c[b],d[b],e)}}catch(h){a.e(h)}finally{a.f()}return g}},{key:"getDuration",value:function(c,b){var a=b.transitionDuration;return"auto"===a&&(a=function(f,g,a={}){a=Object.assign({},a$,a);const{screenSpeed:c,speed:h,maxDuration:d}=a,{S:i,rho:j}=a_(f,g,a),e=1e3*i;let b;return b=Number.isFinite(c)?e/(c/j):e/h,Number.isFinite(d)&&b>d?0:b}(c,b,this.props)),a}}])}(C);var ca=["longitude","latitude","zoom","bearing","pitch"],D=function(b){bV(a,b);var c,d,e=(c=a,d=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(c);if(d){var e=bY(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||ca,b.around&&(c.around=b.around),c}return bm(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new aY(g).unproject(this.around);Object.assign(e,c,{around:new aY(c).project(h),aroundLngLat:h})}var i,b=b7(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];bA(b$(f)&&b$(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=b_(a,f,j)}}catch(k){b.e(k)}finally{b.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(e,a,f){var g,b={},c=b7(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=bz(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var h=aA(new aY(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:bz(e.around,a.around,f)}),2),j=h[0],k=h[1];b.longitude=j,b.latitude=k}return b}}]),a}(C),r=function(){},E={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},V={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new D,transitionInterruption:E.BREAK,onTransitionStart:r,onTransitionInterrupt:r,onTransitionEnd:r},F=function(){function a(){var c=this,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};bk(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){c._animationFrame=requestAnimationFrame(c._onTransitionFrame),c._updateViewport()}),this.props=null,this.onViewportChange=b.onViewportChange||r,this.onStateChange=b.onStateChange||r,this.time=b.getTime||Date.now}return bm(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(c){var a=this.props;if(this.props=c,!a||this._shouldIgnoreViewportChange(a,c))return!1;if(this._isTransitionEnabled(c)){var d=Object.assign({},a),b=Object.assign({},c);if(this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this.state.interruption===E.SNAP_TO_END?Object.assign(d,this.state.endProps):Object.assign(d,this.state.propsInTransition),this.state.interruption===E.UPDATE)){var f,g,h,e=this.time(),i=(e-this.state.startTime)/this.state.duration;b.transitionDuration=this.state.duration-(e-this.state.startTime),b.transitionEasing=(h=(f=this.state.easing)(g=i),function(a){return 1/(1-h)*(f(a*(1-g)+g)-h)}),b.transitionInterpolator=d.transitionInterpolator}return b.onTransitionStart(),this._triggerTransition(d,b),!0}return this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(b,a){return!b||(this._isTransitionInProgress()?this.state.interruption===E.IGNORE||this._isUpdateDueToCurrentTransition(a):!this._isTransitionEnabled(a)||a.transitionInterpolator.arePropsEqual(b,a))}},{key:"_triggerTransition",value:function(b,a){bA(this._isTransitionEnabled(a)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=a.transitionInterpolator,d=c.getDuration?c.getDuration(b,a):a.transitionDuration;if(0!==d){var e=a.transitionInterpolator.initializeProps(b,a),f={inTransition:!0,isZooming:b.zoom!==a.zoom,isPanning:b.longitude!==a.longitude||b.latitude!==a.latitude,isRotating:b.bearing!==a.bearing||b.pitch!==a.pitch};this.state={duration:d,easing:a.transitionEasing,interpolator:a.transitionInterpolator,interruption:a.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var d=this.time(),a=this.state,e=a.startTime,f=a.duration,g=a.easing,h=a.interpolator,i=a.startProps,j=a.endProps,c=!1,b=(d-e)/f;b>=1&&(b=1,c=!0),b=g(b);var k=h.interpolateProps(i,j,b),l=new bE(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),a}();g(F,"defaultProps",V);var W=b(840),k=b.n(W);const cb={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(b,c){for(let a=0;ab.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(k().PointerEventInput),k().MouseInput.prototype.handler=function(a){let b=cb[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const cc=k().Manager;var e=k();const cd=e?[[e.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[e.Rotate,{enable:!1}],[e.Pinch,{enable:!1}],[e.Swipe,{enable:!1}],[e.Pan,{threshold:0,enable:!1}],[e.Press,{enable:!1}],[e.Tap,{event:"doubletap",taps:2,enable:!1}],[e.Tap,{event:"anytap",enable:!1}],[e.Tap,{enable:!1}]]:null,ce={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},cf={doubletap:["tap"]},cg={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},s={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},ch={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},ci={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},X="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",G="undefined"!=typeof window?window:b.g;void 0!==b.g&&b.g;let Y=!1;try{const l={get passive(){return Y=!0,!0}};G.addEventListener("test",l,l),G.removeEventListener("test",l,l)}catch(cj){}const ck=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:cl}=s,cm="wheel";class cn{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=cl.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent,!!Y&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cm&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(ck&&b.deltaMode===G.WheelEvent.DOM_DELTA_PIXEL&&(a/=G.devicePixelRatio),b.deltaMode===G.WheelEvent.DOM_DELTA_LINE&&(a*=40));const c={x:b.clientX,y:b.clientY};0!==a&&a%4.000244140625==0&&(a=Math.floor(a/4.000244140625)),b.shiftKey&&a&&(a*=.25),this._onWheel(b,-a,c)}_onWheel(a,b,c){this.callback({type:cm,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:co}=s,cp="pointermove",cq="pointerover",cr="pointerout",cs="pointerleave";class ct{constructor(b,c,a={}){this.element=b,this.callback=c,this.pressed=!1,this.options=Object.assign({enable:!0},a),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=co.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cp&&(this.enableMoveEvent=b),a===cq&&(this.enableOverEvent=b),a===cr&&(this.enableOutEvent=b),a===cs&&(this.enableLeaveEvent=b)}handleEvent(a){this.handleOverEvent(a),this.handleOutEvent(a),this.handleLeaveEvent(a),this.handleMoveEvent(a)}handleOverEvent(a){this.enableOverEvent&&"mouseover"===a.type&&this.callback({type:cq,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:cr,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:cs,srcEvent:a,pointerType:"mouse",target:a.target})}handleMoveEvent(a){if(this.enableMoveEvent)switch(a.type){case"mousedown":a.button>=0&&(this.pressed=!0);break;case"mousemove":0===a.which&&(this.pressed=!1),this.pressed||this.callback({type:cp,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:cu}=s,cv="keydown",cw="keyup";class cx{constructor(a,c,b={}){this.element=a,this.callback=c,this.options=Object.assign({enable:!0},b),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=cu.concat(b.events||[]),this.handleEvent=this.handleEvent.bind(this),a.tabIndex=b.tabIndex||0,a.style.outline="none",this.events.forEach(b=>a.addEventListener(b,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cv&&(this.enableDownEvent=b),a===cw&&(this.enableUpEvent=b)}handleEvent(a){const b=a.target||a.srcElement;("INPUT"!==b.tagName||"text"!==b.type)&&"TEXTAREA"!==b.tagName&&(this.enableDownEvent&&"keydown"===a.type&&this.callback({type:cv,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:cw,srcEvent:a,key:a.key,target:a.target}))}}const cy="contextmenu";class cz{constructor(a,b,c={}){this.element=a,this.callback=b,this.options=Object.assign({enable:!0},c),this.handleEvent=this.handleEvent.bind(this),a.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(a,b){a===cy&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:cy,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const cA={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cB={srcElement:"root",priority:0};class cC{constructor(a){this.eventManager=a,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(f,g,a,h=!1,i=!1){const{handlers:j,handlersByElement:e}=this;a&&("object"!=typeof a||a.addEventListener)&&(a={srcElement:a}),a=a?Object.assign({},cB,a):cB;let b=e.get(a.srcElement);b||(b=[],e.set(a.srcElement,b));const c={type:f,handler:g,srcElement:a.srcElement,priority:a.priority};h&&(c.once=!0),i&&(c.passive=!0),j.push(c),this._active=this._active||!c.passive;let d=b.length-1;for(;d>=0&&!(b[d].priority>=c.priority);)d--;b.splice(d+1,0,c)}remove(f,g){const{handlers:b,handlersByElement:e}=this;for(let c=b.length-1;c>=0;c--){const a=b[c];if(a.type===f&&a.handler===g){b.splice(c,1);const d=e.get(a.srcElement);d.splice(d.indexOf(a),1),0===d.length&&e.delete(a.srcElement)}}this._active=b.some(a=>!a.passive)}handleEvent(c){if(this.isEmpty())return;const b=this._normalizeEvent(c);let a=c.srcEvent.target;for(;a&&a!==b.rootElement;){if(this._emit(b,a),b.handled)return;a=a.parentNode}this._emit(b,"root")}_emit(e,f){const a=this.handlersByElement.get(f);if(a){let g=!1;const h=()=>{e.handled=!0},i=()=>{e.handled=!0,g=!0},c=[];for(let b=0;b{const b=this.manager.get(a);b&&ce[a].forEach(a=>{b.recognizeWith(a)})}),b.recognizerOptions){const e=this.manager.get(d);if(e){const f=b.recognizerOptions[d];delete f.enable,e.set(f)}}for(const[h,c]of(this.wheelInput=new cn(a,this._onOtherEvent,{enable:!1}),this.moveInput=new ct(a,this._onOtherEvent,{enable:!1}),this.keyInput=new cx(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new cz(a,this._onOtherEvent,{enable:!1}),this.events))c.isEmpty()||(this._toggleRecognizer(c.recognizerName,!0),this.manager.on(h,c.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(a,b,c){this._addEventHandler(a,b,c,!1)}once(a,b,c){this._addEventHandler(a,b,c,!0)}watch(a,b,c){this._addEventHandler(a,b,c,!1,!0)}off(a,b){this._removeEventHandler(a,b)}_toggleRecognizer(a,b){const{manager:d}=this;if(!d)return;const c=d.get(a);if(c&&c.options.enable!==b){c.set({enable:b});const e=cf[a];e&&!this.options.recognizers&&e.forEach(e=>{const f=d.get(e);b?(f.requireFailure(a),c.dropRequireFailure(e)):f.dropRequireFailure(a)})}this.wheelInput.enableEventType(a,b),this.moveInput.enableEventType(a,b),this.keyInput.enableEventType(a,b),this.contextmenuInput.enableEventType(a,b)}_addEventHandler(b,e,d,f,g){if("string"!=typeof b){for(const h in d=e,b)this._addEventHandler(h,b[h],d,f,g);return}const{manager:i,events:j}=this,c=ci[b]||b;let a=j.get(c);!a&&(a=new cC(this),j.set(c,a),a.recognizerName=ch[c]||c,i&&i.on(c,a.handleEvent)),a.add(b,e,d,f,g),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(a,h){if("string"!=typeof a){for(const c in a)this._removeEventHandler(c,a[c]);return}const{events:d}=this,i=ci[a]||a,b=d.get(i);if(b&&(b.remove(a,h),b.isEmpty())){const{recognizerName:e}=b;let f=!1;for(const g of d.values())if(g.recognizerName===e&&!g.isEmpty()){f=!0;break}f||this._toggleRecognizer(e,!1)}}_onBasicInput(a){const{srcEvent:c}=a,b=cg[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function cE(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function cF(c){for(var a=1;a0),e=d&&!this.state.isHovering,h=!d&&this.state.isHovering;(c||e)&&(a.features=b,c&&c(a)),e&&cO.call(this,"onMouseEnter",a),h&&cO.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function cS(b){var c=this.props,d=c.onClick,f=c.onNativeClick,g=c.onDblClick,h=c.doubleClickZoom,a=[],e=g||h;switch(b.type){case"anyclick":a.push(f),e||a.push(d);break;case"click":e&&a.push(d)}(a=a.filter(Boolean)).length&&((b=cM.call(this,b)).features=cN.call(this,b.point),a.forEach(function(a){return a(b)}))}var m=(0,c.forwardRef)(function(b,h){var i,t,f=(0,c.useContext)(bJ),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new cD(null,{touchAction:b.touchAction,recognizerOptions:b.eventRecognizerOptions})},[]),g=(0,c.useRef)(null),e=(0,c.useRef)(null),a=(0,c.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;a.props=b,a.map=e.current&&e.current.getMap(),a.setState=function(c){a.state=cL(cL({},a.state),c),g.current.style.cursor=b.getCursor(a.state)};var j=!0,k=function(b,c,d){if(j){i=[b,c,d];return}var e=a.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(b,"position",{get:function(){return[0,0,bL(a.map,b)]}}),f&&f({viewState:b,interactionState:c,oldViewState:d}),g&&g(b,c,d)};(0,c.useImperativeHandle)(h,function(){var a;return{getMap:(a=e).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var d=(0,c.useMemo)(function(){return cL(cL({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||bP(a),a.viewport=d.viewport;var w=function(b){var c=b.isDragging,d=void 0!==c&&c;if(d!==a.state.isDragging&&a.setState({isDragging:d}),j){t=b;return}var e=a.props.onInteractionStateChange;e&&e(b)},l=function(){a.width&&a.height&&u.setOptions(cL(cL(cL({},a.props),a.props.viewState),{},{isInteractive:Boolean(a.props.onViewStateChange||a.props.onViewportChange),onViewportChange:k,onStateChange:w,eventManager:v,width:a.width,height:a.height}))},m=function(b){var c=b.width,d=b.height;a.width=c,a.height=d,l(),a.props.onResize({width:c,height:d})};(0,c.useEffect)(function(){return v.setElement(g.current),v.on({pointerdown:cP.bind(a),pointermove:cR.bind(a),pointerup:cQ.bind(a),pointerleave:cO.bind(a,"onMouseOut"),click:cS.bind(a),anyclick:cS.bind(a),dblclick:cO.bind(a,"onDblClick"),wheel:cO.bind(a,"onWheel"),contextmenu:cO.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),bK(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return ax(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ay(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}t&&w(t)}),l();var n=b.width,o=b.height,p=b.style,r=b.getCursor,s=(0,c.useMemo)(function(){return cL(cL({position:"relative"},p),{},{width:n,height:o,cursor:r(a.state)})},[p,n,o,r,a.state]);return i&&a._child||(a._child=c.createElement(bI,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,aw({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var cT=m;function cU(b,a){if(b===a)return!0;if(!b||!a)return!1;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!==a.length)return!1;for(var c=0;c prop: ".concat(e))}}(d,a,f.current):d=function(a,c,d){if(a.style&&a.style._loaded){var b=function(c){for(var a=1;a=0||(d[a]=c[a]);return d}(a,d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(a,b)&&(e[b]=a[b])}return e}(d,["layout","paint","filter","minzoom","maxzoom","beforeId"]);if(p!==a.beforeId&&b.moveLayer(c,p),e!==a.layout){var q=a.layout||{};for(var g in e)cU(e[g],q[g])||b.setLayoutProperty(c,g,e[g]);for(var r in q)e.hasOwnProperty(r)||b.setLayoutProperty(c,r,void 0)}if(f!==a.paint){var s=a.paint||{};for(var h in f)cU(f[h],s[h])||b.setPaintProperty(c,h,f[h]);for(var t in s)f.hasOwnProperty(t)||b.setPaintProperty(c,t,void 0)}for(var i in cU(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)cU(j[i],a[i])||b.setLayerProperty(c,i,j[i])}(c,d,a,b)}catch(e){console.warn(e)}}(a,d,b,e.current):function(a,d,b){if(a.style&&a.style._loaded){var c=cY(cY({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ab;var f={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},d={captureScroll:a.bool,captureDrag:a.bool,captureClick:a.bool,captureDoubleClick:a.bool,capturePointerMove:a.bool};function c$(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(bJ),e=(0,c.useRef)(null),f=(0,c.useRef)({props:d,state:{},context:a,containerRef:e}),b=f.current;return b.props=d,b.context=a,(0,c.useEffect)(function(){return function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(c){var b=a.props;b.captureScroll&&c.stopPropagation(),b.onScroll&&b.onScroll(c,a)},panstart:function(c){var b=a.props;b.captureDrag&&c.stopPropagation(),b.onDragStart&&b.onDragStart(c,a)},anyclick:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onNativeClick&&b.onNativeClick(c,a)},click:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onClick&&b.onClick(c,a)},dblclick:function(c){var b=a.props;b.captureDoubleClick&&c.stopPropagation(),b.onDoubleClick&&b.onDoubleClick(c,a)},pointermove:function(c){var b=a.props;b.capturePointerMove&&c.stopPropagation(),b.onPointerMove&&b.onPointerMove(c,a)}};return c.watch(d,b),function(){c.off(d)}}}(b)},[a.eventManager]),b}function c_(b){var a=b.instance,c=c$(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){bV(a,b);var d,e,f=(d=a,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(d);if(e){var c=bY(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var b;bk(this,a);for(var e=arguments.length,h=new Array(e),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var c="x"===d?a.offsetWidth:a.offsetHeight;return c6(b/100*c)/c*100};function c8(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}var ae=Object.assign({},ac,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),af=Object.assign({},ad,{className:""});function t(b){var d,j,e,k,f,l,m,a,h=(d=b,e=(j=aA((0,c.useState)(null),2))[0],k=j[1],f=aA((0,c.useState)(null),2),l=f[0],m=f[1],a=c$(c1(c1({},d),{},{onDragStart:c4})),a.callbacks=d,a.state.dragPos=e,a.state.setDragPos=k,a.state.dragOffset=l,a.state.setDragOffset=m,(0,c.useEffect)(function(){return function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return function(b,a){var h=a.props,c=a.callbacks,d=a.state,i=a.context;b.stopPropagation();var e=c2(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=c3(e,f,h,i),c.onDrag(g)}}(b,a)},panend:function(b){return function(c,a){var h=a.props,d=a.callbacks,b=a.state,i=a.context;c.stopPropagation();var e=b.dragPos,f=b.dragOffset;if(b.setDragPos(null),b.setDragOffset(null),d.onDragEnd&&e&&f){var g=Object.assign({},c);g.lngLat=c3(e,f,h,i),d.onDragEnd(g)}}(b,a)},pancancel:function(d){var c,b;return c=d,b=a.state,void(c.stopPropagation(),b.setDragPos(null),b.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}}(a)},[a.context.eventManager,Boolean(e)]),a),o=h.state,p=h.containerRef,q=b.children,r=b.className,s=b.draggable,A=b.style,t=o.dragPos,u=function(b){var a=b.props,e=b.state,f=b.context,g=a.longitude,h=a.latitude,j=a.offsetLeft,k=a.offsetTop,c=e.dragPos,d=e.dragOffset,l=f.viewport,m=f.map;if(c&&d)return[c[0]+d[0],c[1]+d[1]];var n=bL(m,{longitude:g,latitude:h}),i=aA(l.project([g,h,n]),2),o=i[0],p=i[1];return[o+=j,p+=k]}(h),n=aA(u,2),v=n[0],w=n[1],x="translate(".concat(c6(v),"px, ").concat(c6(w),"px)"),y=s?t?"grabbing":"grab":"auto",z=(0,c.useMemo)(function(){var a=function(c){for(var a=1;a0){var t=b,u=e;for(b=0;b<=1;b+=.5)k=(i=n-b*h)+h,e=Math.max(0,d-i)+Math.max(0,k-p+d),e0){var w=a,x=f;for(a=0;a<=1;a+=v)l=(j=m-a*g)+g,f=Math.max(0,d-j)+Math.max(0,l-o+d),f1||h< -1||f<0||f>p.width||g<0||g>p.height?i.display="none":i.zIndex=Math.floor((1-h)/2*1e5)),i),S=(0,c.useCallback)(function(b){t.props.onClose();var a=t.context.eventManager;a&&a.once("click",function(a){return a.stopPropagation()},b.target)},[]);return c.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(L," ").concat(N),style:R,ref:u},c.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:O}}),c.createElement("div",{key:"content",ref:j,className:"mapboxgl-popup-content"},P&&c.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:S},"\xd7"),Q))}function da(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}u.propTypes=ag,u.defaultProps=ah,c.memo(u);var ai=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string)])}),aj=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=c$(a),d=b.context,i=b.containerRef,j=(0,c.useRef)(null),e=aA((0,c.useState)(!1),2),f=e[0],m=e[1];(0,c.useEffect)(function(){var h,e,c,f,g,b;return d.map&&(h=(e={customAttribution:a.customAttribution},c=d.map,f=i.current,g=j.current,(b=new(A()).AttributionControl(e))._map=c,b._container=f,b._innerContainer=g,b._updateAttributions(),b._updateEditLink(),c.on("styledata",b._updateData),c.on("sourcedata",b._updateData),b)),function(){var a;return h&&void((a=h)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[d.map]);var h=void 0===a.compact?d.viewport.width<=640:a.compact;(0,c.useEffect)(function(){!h&&f&&m(!1)},[h]);var k=(0,c.useCallback)(function(){return m(function(a){return!a})},[]),l=(0,c.useMemo)(function(){return function(c){for(var a=1;ac)return 1}return 0}(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),f=b.viewport.bearing,d={transform:"rotate(".concat(-f,"deg)")},2===e?c.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:d}):c.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:d})))))}function di(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}y.propTypes=ao,y.defaultProps=ap,c.memo(y);var aq=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ar=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=c$(a),f=d.context,h=d.containerRef,e=aA((0,c.useState)(null),2),b=e[0],j=e[1];(0,c.useEffect)(function(){if(f.map){var a=new(A()).ScaleControl;a._map=f.map,a._container=h.current,j(a)}},[f.map]),b&&(b.options=a,b._onMove());var i=(0,c.useMemo)(function(){return function(c){for(var a=1;a\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=an(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=ao(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=as(j,k),a.distance=ar(j,k),al(b,a),a.offsetDirection=aq(a.deltaX,a.deltaY);var d=ap(a.deltaTime,a.deltaX,a.deltaY);a.overallVelocityX=d.x,a.overallVelocityY=d.y,a.overallVelocity=T(d.x)>T(d.y)?d.x:d.y,a.scale=c?au(c.pointers,e):1,a.rotation=c?at(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,am(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function al(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function am(h,a){var d,e,f,g,b=h.lastInterval||a,i=a.timeStamp-b.timeStamp;if(8!=a.eventType&&(i>25||l===b.velocity)){var j=a.deltaX-b.deltaX,k=a.deltaY-b.deltaY,c=ap(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=aq(j,k),h.lastInterval=a}else d=b.velocity,e=b.velocityX,f=b.velocityY,g=b.direction;a.velocity=d,a.velocityX=e,a.velocityY=f,a.direction=g}function an(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ar(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function as(b,c,a){a||(a=ah);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function at(a,b){return as(b[1],b[0],ai)+as(a[1],a[0],ai)}function au(a,b){return ar(b[0],b[1],ai)/ar(a[0],a[1],ai)}f.prototype={handler:function(){},init:function(){this.evEl&&H(this.element,this.evEl,this.domHandler),this.evTarget&&H(this.target,this.evTarget,this.domHandler),this.evWin&&H(ae(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&I(this.element,this.evEl,this.domHandler),this.evTarget&&I(this.target,this.evTarget,this.domHandler),this.evWin&&I(ae(this.element),this.evWin,this.domHandler)}};var av={mousedown:1,mousemove:2,mouseup:4};function u(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,f.apply(this,arguments)}e(u,f,{handler:function(a){var b=av[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:L,srcEvent:a}))}});var aw={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},ax={2:K,3:"pen",4:L,5:"kinect"},M="pointerdown",N="pointermove pointerup pointercancel";function v(){this.evEl=M,this.evWin=N,f.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}g.MSPointerEvent&&!g.PointerEvent&&(M="MSPointerDown",N="MSPointerMove MSPointerUp MSPointerCancel"),e(v,f,{handler:function(a){var b=this.store,e=!1,d=aw[a.type.toLowerCase().replace("ms","")],f=ax[a.pointerType]||a.pointerType,c=aa(b,a.pointerId,"pointerId");1&d&&(0===a.button||f==K)?c<0&&(b.push(a),c=b.length-1):12&d&&(e=!0),!(c<0)&&(b[c]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),e&&b.splice(c,1))}});var ay={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function w(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,f.apply(this,arguments)}function az(b,d){var a=ab(b.touches),c=ab(b.changedTouches);return 12&d&&(a=ac(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ay[c.type];if(1===a&&(this.started=!0),this.started){var b=az.call(this,c,a);12&a&&b[0].length-b[1].length==0&&(this.started=!1),this.callback(this.manager,a,{pointers:b[0],changedPointers:b[1],pointerType:K,srcEvent:c})}}});var aA={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function x(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},f.apply(this,arguments)}function aB(h,g){var b=ab(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ab(h.changedTouches),f=[],i=this.target;if(d=b.filter(function(a){return Z(a.target,i)}),1===g)for(a=0;a -1&&d.splice(a,1)},2500)}}function aE(b){for(var d=b.srcEvent.clientX,e=b.srcEvent.clientY,a=0;a -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(d){var c=this,a=this.state;function b(a){c.manager.emit(a,d)}a<8&&b(c.options.event+aM(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+aM(a))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ac.threshold&&b&c.direction},attrTest:function(a){return h.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=aN(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),e(p,h,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),e(q,i,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[aG]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=V(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=U(),this.manager.emit(this.options.event,this._input)))}}),e(r,h,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[aI]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),e(s,h,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return o.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&T(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=aN(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),e(j,i,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[aH]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var a=1;ac.length)&&(a=c.length);for(var b=0,d=new Array(a);bc?c:a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),bc=new h(4),h!=Float32Array&&(bc[0]=0,bc[1]=0,bc[2]=0,bc[3]=0);const aF=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function aG(e,f,g){var h=f[0],i=f[1],j=f[2],k=f[3],l=f[4],m=f[5],n=f[6],o=f[7],p=f[8],q=f[9],r=f[10],s=f[11],t=f[12],u=f[13],v=f[14],w=f[15],a=g[0],b=g[1],c=g[2],d=g[3];return e[0]=a*h+b*l+c*p+d*t,e[1]=a*i+b*m+c*q+d*u,e[2]=a*j+b*n+c*r+d*v,e[3]=a*k+b*o+c*s+d*w,a=g[4],b=g[5],c=g[6],d=g[7],e[4]=a*h+b*l+c*p+d*t,e[5]=a*i+b*m+c*q+d*u,e[6]=a*j+b*n+c*r+d*v,e[7]=a*k+b*o+c*s+d*w,a=g[8],b=g[9],c=g[10],d=g[11],e[8]=a*h+b*l+c*p+d*t,e[9]=a*i+b*m+c*q+d*u,e[10]=a*j+b*n+c*r+d*v,e[11]=a*k+b*o+c*s+d*w,a=g[12],b=g[13],c=g[14],d=g[15],e[12]=a*h+b*l+c*p+d*t,e[13]=a*i+b*m+c*q+d*u,e[14]=a*j+b*n+c*r+d*v,e[15]=a*k+b*o+c*s+d*w,e}function aH(b,a,f){var g,h,i,j,k,l,m,n,o,p,q,r,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],b[0]=g,b[1]=h,b[2]=i,b[3]=j,b[4]=k,b[5]=l,b[6]=m,b[7]=n,b[8]=o,b[9]=p,b[10]=q,b[11]=r,b[12]=g*c+k*d+o*e+a[12],b[13]=h*c+l*d+p*e+a[13],b[14]=i*c+m*d+q*e+a[14],b[15]=j*c+n*d+r*e+a[15]),b}function aI(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function aJ(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function aK(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function aL(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function aM(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}bd=new h(2),h!=Float32Array&&(bd[0]=0,bd[1]=0),be=new h(3),h!=Float32Array&&(be[0]=0,be[1]=0,be[2]=0);const n=Math.PI,aN=n/4,aO=n/180,aP=180/n;function aQ(a){return Math.pow(2,a)}function aR([b,a]){return aM(Number.isFinite(b)),aM(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*aO+n)/(2*n),512*(n+Math.log(Math.tan(aN+.5*(a*aO))))/(2*n)]}function aS([a,b]){return[(a/512*(2*n)-n)*aP,2*(Math.atan(Math.exp(b/512*(2*n)-n))-aN)*aP]}function aT(a){return 2*Math.atan(.5/a)*aP}function aU(a){return .5/Math.tan(.5*a*aO)}function aV(i,c,j=0){const[a,b,e]=i;if(aM(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=aC(c,[a,b,e,1]);return k}const f=aC(c,[a,b,0,1]),g=aC(c,[a,b,1,1]),d=f[2],h=g[2];return aL([],f,g,d===h?0:((j||0)-d)/(h-d))}const aW=Math.PI/180;function aX(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=aC(e,[c,0,1,1]),f=aC(e,[c,a.height,1,1]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=aL([],b,f,i),g=aS(j);return g[2]=d,g}class aY{constructor({width:f,height:c,latitude:l=0,longitude:m=0,zoom:p=0,pitch:n=0,bearing:q=0,altitude:a=null,fovy:b=null,position:o=null,nearZMultiplier:t=.02,farZMultiplier:u=1.01}={width:1,height:1}){f=f||1,c=c||1,null===b&&null===a?b=aT(a=1.5):null===b?b=aT(a):null===a&&(a=aU(b));const r=aQ(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){aM(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*aO),e=1.4222222222222223/d,a=12790407194604047e-21/d;if(b.unitsPerMeter=[a,a,a],b.metersPerUnit=[1/a,1/a,1/a],b.unitsPerDegree=[1.4222222222222223,e,a],b.degreesPerUnit=[.703125,1/e,1/a],j){const f=aO*Math.tan(c*aO)/d,k=1.4222222222222223*f/2,g=12790407194604047e-21*f,h=g/e*a;b.unitsPerDegree2=[0,k,g],b.unitsPerMeter2=[h,0,h]}return b}({longitude:m,latitude:l}),d=aR([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,k=(e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],e),i[0]=j[0]+k[0],i[1]=j[1]+k[1],i[2]=j[2]+k[2]}this.projectionMatrix=function({width:h,height:i,pitch:j,altitude:k,fovy:l,nearZMultiplier:m,farZMultiplier:n}){var a,f,g,c,b,d,e;const{fov:o,aspect:p,near:q,far:r}=function({width:f,height:g,fovy:a=aT(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=aT(d));const b=.5*a*aO,c=aU(a),e=h*aO;return{fov:2*b,aspect:f/g,focalDistance:c,near:i,far:(Math.sin(e)*(Math.sin(b)*c/Math.sin(Math.min(Math.max(Math.PI/2-e-b,.01),Math.PI-.01)))+c)*j}}({width:h,height:i,altitude:k,fovy:l,pitch:j,nearZMultiplier:m,farZMultiplier:n}),s=(a=[],f=o,g=p,c=q,b=r,e=1/Math.tan(f/2),a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(d=1/(c-b),a[10]=(b+c)*d,a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a);return s}({width:f,height:c,pitch:n,fovy:b,nearZMultiplier:t,farZMultiplier:u}),this.viewMatrix=function({height:F,pitch:G,bearing:H,altitude:I,scale:l,center:E=null}){var a,b,m,f,g,n,o,p,q,r,s,t,u,c,d,v,h,i,w,x,y,z,A,B,C,D,j,k;const e=aB();return aH(e,e,[0,0,-I]),a=e,b=e,m=-G*aO,f=Math.sin(m),g=Math.cos(m),n=b[4],o=b[5],p=b[6],q=b[7],r=b[8],s=b[9],t=b[10],u=b[11],b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=n*g+r*f,a[5]=o*g+s*f,a[6]=p*g+t*f,a[7]=q*g+u*f,a[8]=r*g-n*f,a[9]=s*g-o*f,a[10]=t*g-p*f,a[11]=u*g-q*f,c=e,d=e,v=H*aO,h=Math.sin(v),i=Math.cos(v),w=d[0],x=d[1],y=d[2],z=d[3],A=d[4],B=d[5],C=d[6],D=d[7],d!==c&&(c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15]),c[0]=w*i+A*h,c[1]=x*i+B*h,c[2]=y*i+C*h,c[3]=z*i+D*h,c[4]=A*i-w*h,c[5]=B*i-x*h,c[6]=C*i-y*h,c[7]=D*i-z*h,aI(e,e,[l/=F,l,l]),E&&aH(e,e,(j=[],k=E,j[0]=-k[0],j[1]=-k[1],j[2]=-k[2],j)),e}({height:c,scale:r,center:d,pitch:n,bearing:q,altitude:a}),this.width=f,this.height=c,this.scale=r,this.latitude=l,this.longitude=m,this.zoom=p,this.pitch=n,this.bearing=q,this.altitude=a,this.fovy=b,this.center=d,this.meterOffset=o||[0,0,0],this.distanceScales=s,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,a;const{width:I,height:J,projectionMatrix:K,viewMatrix:L}=this,G=aB();aG(G,G,K),aG(G,G,L),this.viewProjectionMatrix=G;const d=aB();aI(d,d,[I/2,-J/2,1]),aH(d,d,[1,-1,0]),aG(d,d,G);const H=(b=aB(),e=(c=d)[0],f=c[1],g=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=c[8],n=c[9],o=c[10],p=c[11],q=c[12],r=c[13],s=c[14],t=c[15],u=e*j-f*i,v=e*k-g*i,w=e*l-h*i,x=f*k-g*j,y=f*l-h*j,z=g*l-h*k,A=m*r-n*q,B=m*s-o*q,C=m*t-p*q,D=n*s-o*r,E=n*t-p*r,F=o*t-p*s,a=u*F-v*E+w*D+x*C-y*B+z*A,a?(a=1/a,b[0]=(j*F-k*E+l*D)*a,b[1]=(g*E-f*F-h*D)*a,b[2]=(r*z-s*y+t*x)*a,b[3]=(o*y-n*z-p*x)*a,b[4]=(k*C-i*F-l*B)*a,b[5]=(e*F-g*C+h*B)*a,b[6]=(s*w-q*z-t*v)*a,b[7]=(m*z-o*w+p*v)*a,b[8]=(i*E-j*C+l*A)*a,b[9]=(f*C-e*E-h*A)*a,b[10]=(q*y-r*w+t*u)*a,b[11]=(n*w-m*y-p*u)*a,b[12]=(j*B-i*D-k*A)*a,b[13]=(e*D-f*B+g*A)*a,b[14]=(r*v-q*x-s*u)*a,b[15]=(m*x-n*v+o*u)*a,b):null);if(!H)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=H}equals(a){return a instanceof aY&&a.width===this.width&&a.height===this.height&&aJ(a.projectionMatrix,this.projectionMatrix)&&aJ(a.viewMatrix,this.viewMatrix)}project(a,{topLeft:f=!0}={}){const g=this.projectPosition(a),b=function(d,e){const[a,b,c=0]=d;return aM(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),aC(e,[a,b,c,1])}(g,this.pixelProjectionMatrix),[c,d]=b,e=f?d:this.height-d;return 2===a.length?[c,e]:[c,e,b[2]]}unproject(f,{topLeft:g=!0,targetZ:a}={}){const[h,d,e]=f,i=g?d:this.height-d,j=a&&a*this.distanceScales.unitsPerMeter[2],k=aV([h,i,e],this.pixelUnprojectionMatrix,j),[b,c,l]=this.unprojectPosition(k);return Number.isFinite(e)?[b,c,l]:Number.isFinite(a)?[b,c,a]:[b,c]}projectPosition(a){const[b,c]=aR(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=aS(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return aR(a)}unprojectFlat(a){return aS(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=aV(d,this.pixelUnprojectionMatrix),f=aR(c),g=aK([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=aK([],this.center,g);return aS(h)}getLocationAtPoint({lngLat:a,pos:b}){return this.getMapCenterByLngLatPosition({lngLat:a,pos:b})}fitBounds(c,d={}){const{width:a,height:b}=this,{longitude:e,latitude:f,zoom:g}=function({width:m,height:n,bounds:o,minExtent:f=0,maxZoom:p=24,padding:a=0,offset:g=[0,0]}){const[[q,r],[s,t]]=o;if(Number.isFinite(a)){const b=a;a={top:b,bottom:b,left:b,right:b}}else aM(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=aR([q,aE(t,-85.051129,85.051129)]),d=aR([s,aE(r,-85.051129,85.051129)]),h=[Math.max(Math.abs(d[0]-c[0]),f),Math.max(Math.abs(d[1]-c[1]),f)],e=[m-a.left-a.right-2*Math.abs(g[0]),n-a.top-a.bottom-2*Math.abs(g[1])];aM(e[0]>0&&e[1]>0);const i=e[0]/h[0],j=e[1]/h[1],u=(a.right-a.left)/2/i,v=(a.bottom-a.top)/2/j,w=[(d[0]+c[0])/2+u,(d[1]+c[1])/2+v],k=aS(w),l=Math.min(p,aF(Math.abs(Math.min(i,j))));return aM(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new aY({width:a,height:b,longitude:e,latitude:f,zoom:g})}getBounds(b){const a=this.getBoundingRegion(b),c=Math.min(...a.map(a=>a[0])),d=Math.max(...a.map(a=>a[0])),e=Math.min(...a.map(a=>a[1])),f=Math.max(...a.map(a=>a[1]));return[[c,e],[d,f]]}getBoundingRegion(a={}){return function(a,d=0){const{width:e,height:h,unproject:b}=a,c={targetZ:d},i=b([0,h],c),j=b([e,h],c);let f,g;const k=a.fovy?.5*a.fovy*aW:Math.atan(.5/a.altitude),l=(90-a.pitch)*aW;return k>l-.01?(f=aX(a,0,d),g=aX(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const aZ=["longitude","latitude","zoom"],a$={curve:1.414,speed:1.2};function a_(d,h,i){var f,j,k,o,p,q;i=Object.assign({},a$,i);const g=i.curve,l=d.zoom,w=[d.longitude,d.latitude],x=aQ(l),y=h.zoom,z=[h.longitude,h.latitude],A=aQ(y-l),r=aR(w),B=aR(z),s=(f=[],j=B,k=r,f[0]=j[0]-k[0],f[1]=j[1]-k[1],f),a=Math.max(d.width,d.height),e=a/A,t=(p=(o=s)[0],q=o[1],Math.hypot(p,q)*x),c=Math.max(t,.01),b=g*g,m=(e*e-a*a+b*b*c*c)/(2*a*b*c),n=(e*e-a*a-b*b*c*c)/(2*e*b*c),u=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(n*n+1)-n);return{startZoom:l,startCenterXY:r,uDelta:s,w0:a,u1:t,S:(v-u)/g,rho:g,rho2:b,r0:u,r1:v}}var N=function(){if("undefined"!=typeof Map)return Map;function a(a,c){var b=-1;return a.some(function(a,d){return a[0]===c&&(b=d,!0)}),b}return function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(c){var d=a(this.__entries__,c),b=this.__entries__[d];return b&&b[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(d){var b=this.__entries__,c=a(b,d);~c&&b.splice(c,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(e,a){void 0===a&&(a=null);for(var b=0,c=this.__entries__;b0},a.prototype.connect_=function(){a0&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),a3?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){a0&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(b){var a=b.propertyName,c=void 0===a?"":a;a2.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a),this.instance_},a.instance_=null,a}(),a5=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),bi="undefined"!=typeof WeakMap?new WeakMap:new N,O=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=a4.getInstance(),d=new bh(b,c,this);bi.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=bi.get(this))[a].apply(b,arguments)}});var bj=void 0!==o.ResizeObserver?o.ResizeObserver:O;function bk(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function bl(d,c){for(var b=0;b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function bq(a,c){if(a){if("string"==typeof a)return br(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return br(a,c)}}function br(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b1&& void 0!==arguments[1]?arguments[1]:"component";b.debug&&a.checkPropTypes(Q,b,"prop",c)}var i=function(){function a(b){var c=this;if(bk(this,a),g(this,"props",R),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return bm(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var d=this._map.getContainer(),c=b.container;for(c.classList.add("mapboxgl-map");d.childNodes.length>0;)c.appendChild(d.childNodes[0]);this._map._container=c,a.savedMap=null,b.mapStyle&&this._map.setStyle(bt(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var d=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=d,b.gl}}var c={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:bt(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(c.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},c,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var d=this;bv(a=Object.assign({},R,a),"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||R.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var b=a.container;Object.defineProperty(b,"offsetWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"clientWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"offsetHeight",{configurable:!0,get:function(){return d.height}}),Object.defineProperty(b,"clientHeight",{configurable:!0,get:function(){return d.height}});var c=this._map.getCanvas();c&&(c.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(b,a){if(this._map){bv(a=Object.assign({},this.props,a),"Mapbox");var c=this._updateMapViewport(b,a),d=this._updateMapSize(b,a);this._updateMapStyle(b,a),!a.asyncRender&&(c||d)&&this.redraw(),this.props=a}}},{key:"_updateMapStyle",value:function(b,a){b.mapStyle!==a.mapStyle&&this._map.setStyle(bt(a.mapStyle),{diff:!a.preventStyleDiffing})}},{key:"_updateMapSize",value:function(b,a){var c=b.width!==a.width||b.height!==a.height;return c&&(this.width=a.width,this.height=a.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(d,e){var b=this._getViewState(d),a=this._getViewState(e),c=a.latitude!==b.latitude||a.longitude!==b.longitude||a.zoom!==b.zoom||a.pitch!==b.pitch||a.bearing!==b.bearing||a.altitude!==b.altitude;return c&&(this._map.jumpTo(this._viewStateToMapboxProps(a)),a.altitude!==b.altitude&&(this._map.transform.altitude=a.altitude)),c}},{key:"_getViewState",value:function(b){var a=b.viewState||b,f=a.longitude,g=a.latitude,h=a.zoom,c=a.pitch,d=a.bearing,e=a.altitude;return{longitude:f,latitude:g,zoom:h,pitch:void 0===c?0:c,bearing:void 0===d?0:d,altitude:void 0===e?1.5:e}}},{key:"_checkStyleSheet",value:function(){var c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==P)try{var a=P.createElement("div");if(a.className="mapboxgl-map",a.style.display="none",P.body.appendChild(a),!("static"!==window.getComputedStyle(a).position)){var b=P.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("type","text/css"),b.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(c,"/mapbox-gl.css")),P.head.appendChild(b)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}}]),a}();g(i,"initialized",!1),g(i,"propTypes",Q),g(i,"defaultProps",R),g(i,"savedMap",null);var S=b(6158),A=b.n(S);function bw(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function bx(a,b){if(a===b)return!0;if(bw(a)&&bw(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function by(a,b,c){return Math.max(b,Math.min(c,a))}function bz(a,c,b){return bw(a)?a.map(function(a,d){return bz(a,c[d],b)}):b*c+(1-b)*a}function bA(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function bB(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bC(c){for(var a=1;a0,"`scale` must be a positive number");var f=this._state,b=f.startZoom,c=f.startZoomLngLat;Number.isFinite(b)||(b=this._viewportProps.zoom,c=this._unproject(i)||this._unproject(d)),bA(c,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var g=this._calculateNewZoom({scale:e,startZoom:b||0}),j=new aY(Object.assign({},this._viewportProps,{zoom:g})),k=j.getMapCenterByLngLatPosition({lngLat:c,pos:d}),h=aA(k,2),l=h[0],m=h[1];return this._getUpdatedMapState({zoom:g,longitude:l,latitude:m})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=by(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=by(g,f,e),Object.assign(a,function({width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k=0,bearing:c=0}){(b< -180||b>180)&&(b=aD(b+180,360)-180),(c< -180||c>180)&&(c=aD(c+180,360)-180);const f=aF(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=aS([0,g])[1];if(ai&&(a=i)}}return{width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k,bearing:c}}(a)),a}},{key:"_unproject",value:function(a){var b=new aY(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new aY(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var c=a.scale,d=a.startZoom,b=this._viewportProps,e=b.maxZoom,f=b.minZoom;return by(d+Math.log2(c),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(c){var f=c.deltaScaleX,a=c.deltaScaleY,g=c.startBearing,b=c.startPitch;a=by(a,-1,1);var e=this._viewportProps,h=e.minPitch,i=e.maxPitch,d=b;return a>0?d=b+a*(i-b):a<0&&(d=b-a*(h-b)),{pitch:d,bearing:g+180*f}}},{key:"_getRotationParams",value:function(c,d){var h=c[0]-d[0],e=c[1]-d[1],i=c[1],a=d[1],f=this._viewportProps,j=f.width,g=f.height,b=0;return e>0?Math.abs(g-a)>5&&(b=e/(a-g)*1.2):e<0&&a>5&&(b=1-i/a),{deltaScaleX:h/j,deltaScaleY:b=Math.min(1,Math.max(-1,b))}}}]),a}();function bF(a){return a[0].toLowerCase()+a.slice(1)}function bG(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function bH(c){for(var a=1;a1&& void 0!==arguments[1]?arguments[1]:{},b=a.current&&a.current.getMap();return b&&b.queryRenderedFeatures(c,d)}}},[]);var p=(0,c.useCallback)(function(b){var a=b.target;a===o.current&&a.scrollTo(0,0)},[]),q=d&&c.createElement(bI,{value:bN(bN({},b),{},{viewport:b.viewport||bP(bN({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:bQ,onScroll:p},a.children)),r=a.className,s=a.width,t=a.height,u=a.style,v=a.visibilityConstraints,w=Object.assign({position:"relative"},u,{width:s,height:t}),x=a.visible&&function(c){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:B;for(var a in b){var d=a.slice(0,3),e=bF(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},bQ,{visibility:x?"inherit":"hidden"});return c.createElement("div",{key:"map-container",ref:h,style:w},c.createElement("div",{key:"map-mapbox",ref:n,style:y,className:r}),q,!l&&!a.disableTokenWarning&&c.createElement(bR,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bS(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(a.s();!(b=a.n()).done;){var c=b.value;if(!bx(d[c],e[c]))return!1}}catch(f){a.e(f)}finally{a.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){bA(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}}]),a}();function bT(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function bU(a,b){return(bU=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function bV(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),a&&bU(b,a)}function bW(a){return(bW="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function bX(b,a){if(a&&("object"===bW(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return bT(b)}function bY(a){return(bY=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var bZ={longitude:1,bearing:1};function b$(a){return Number.isFinite(a)||Array.isArray(a)}function b_(b,c,a){return b in bZ&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function b0(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=b1(a))||c&&a&&"number"==typeof a.length){e&&(a=e);var d=0,b=function(){};return{s:b,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b1(a,c){if(a){if("string"==typeof a)return b2(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b2(a,c)}}function b2(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function b8(a,c){if(a){if("string"==typeof a)return b9(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return b9(a,c)}}function b9(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,d),g(bT(a=e.call(this)),"propNames",b3),a.props=Object.assign({},b6,b),a}bm(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=b0(b4);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];bA(b$(g)&&b$(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=b_(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=b0(b5);try{for(d.s();!(l=d.n()).done;){var b=l.value,m=h[b]||0,o=i[b]||0;e[b]=m,f[b]=b_(b,m,o)}}catch(p){d.e(p)}finally{d.f()}return{start:e,end:f}}},{key:"interpolateProps",value:function(c,d,e){var f,g=function(h,i,j,r={}){var k,l,m,c,d,e;const a={},{startZoom:s,startCenterXY:t,uDelta:u,w0:v,u1:n,S:w,rho:o,rho2:x,r0:b}=a_(h,i,r);if(n<.01){for(const f of aZ){const y=h[f],z=i[f];a[f]=(k=y,l=z,(m=j)*l+(1-m)*k)}return a}const p=j*w,A=s+aF(1/(Math.cosh(b)/Math.cosh(b+o*p))),g=(c=[],d=u,e=v*((Math.cosh(b)*Math.tanh(b+o*p)-Math.sinh(b))/x)/n,c[0]=d[0]*e,c[1]=d[1]*e,c);aK(g,g,t);const q=aS(g);return a.longitude=q[0],a.latitude=q[1],a.zoom=A,a}(c,d,e,this.props),a=b0(b5);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=bz(c[b],d[b],e)}}catch(h){a.e(h)}finally{a.f()}return g}},{key:"getDuration",value:function(c,b){var a=b.transitionDuration;return"auto"===a&&(a=function(f,g,a={}){a=Object.assign({},a$,a);const{screenSpeed:c,speed:h,maxDuration:d}=a,{S:i,rho:j}=a_(f,g,a),e=1e3*i;let b;return b=Number.isFinite(c)?e/(c/j):e/h,Number.isFinite(d)&&b>d?0:b}(c,b,this.props)),a}}])}(C);var ca=["longitude","latitude","zoom","bearing","pitch"],D=function(b){bV(a,b);var c,d,e=(c=a,d=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(c);if(d){var e=bY(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return bk(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||ca,b.around&&(c.around=b.around),c}return bm(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new aY(g).unproject(this.around);Object.assign(e,c,{around:new aY(c).project(h),aroundLngLat:h})}var i,b=b7(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];bA(b$(f)&&b$(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=b_(a,f,j)}}catch(k){b.e(k)}finally{b.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(e,a,f){var g,b={},c=b7(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=bz(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var h=aA(new aY(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:bz(e.around,a.around,f)}),2),j=h[0],k=h[1];b.longitude=j,b.latitude=k}return b}}]),a}(C),r=function(){},E={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},V={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new D,transitionInterruption:E.BREAK,onTransitionStart:r,onTransitionInterrupt:r,onTransitionEnd:r},F=function(){function a(){var c=this,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};bk(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){c._animationFrame=requestAnimationFrame(c._onTransitionFrame),c._updateViewport()}),this.props=null,this.onViewportChange=b.onViewportChange||r,this.onStateChange=b.onStateChange||r,this.time=b.getTime||Date.now}return bm(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(c){var a=this.props;if(this.props=c,!a||this._shouldIgnoreViewportChange(a,c))return!1;if(this._isTransitionEnabled(c)){var d=Object.assign({},a),b=Object.assign({},c);if(this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this.state.interruption===E.SNAP_TO_END?Object.assign(d,this.state.endProps):Object.assign(d,this.state.propsInTransition),this.state.interruption===E.UPDATE)){var f,g,h,e=this.time(),i=(e-this.state.startTime)/this.state.duration;b.transitionDuration=this.state.duration-(e-this.state.startTime),b.transitionEasing=(h=(f=this.state.easing)(g=i),function(a){return 1/(1-h)*(f(a*(1-g)+g)-h)}),b.transitionInterpolator=d.transitionInterpolator}return b.onTransitionStart(),this._triggerTransition(d,b),!0}return this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(b,a){return!b||(this._isTransitionInProgress()?this.state.interruption===E.IGNORE||this._isUpdateDueToCurrentTransition(a):!this._isTransitionEnabled(a)||a.transitionInterpolator.arePropsEqual(b,a))}},{key:"_triggerTransition",value:function(b,a){bA(this._isTransitionEnabled(a)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=a.transitionInterpolator,d=c.getDuration?c.getDuration(b,a):a.transitionDuration;if(0!==d){var e=a.transitionInterpolator.initializeProps(b,a),f={inTransition:!0,isZooming:b.zoom!==a.zoom,isPanning:b.longitude!==a.longitude||b.latitude!==a.latitude,isRotating:b.bearing!==a.bearing||b.pitch!==a.pitch};this.state={duration:d,easing:a.transitionEasing,interpolator:a.transitionInterpolator,interruption:a.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var d=this.time(),a=this.state,e=a.startTime,f=a.duration,g=a.easing,h=a.interpolator,i=a.startProps,j=a.endProps,c=!1,b=(d-e)/f;b>=1&&(b=1,c=!0),b=g(b);var k=h.interpolateProps(i,j,b),l=new bE(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),a}();g(F,"defaultProps",V);var W=b(840),k=b.n(W);const cb={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(b,c){for(let a=0;ab.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(k().PointerEventInput),k().MouseInput.prototype.handler=function(a){let b=cb[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const cc=k().Manager;var e=k();const cd=e?[[e.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[e.Rotate,{enable:!1}],[e.Pinch,{enable:!1}],[e.Swipe,{enable:!1}],[e.Pan,{threshold:0,enable:!1}],[e.Press,{enable:!1}],[e.Tap,{event:"doubletap",taps:2,enable:!1}],[e.Tap,{event:"anytap",enable:!1}],[e.Tap,{enable:!1}]]:null,ce={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},cf={doubletap:["tap"]},cg={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},s={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},ch={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},ci={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},X="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",G="undefined"!=typeof window?window:b.g;void 0!==b.g&&b.g;let Y=!1;try{const l={get passive(){return Y=!0,!0}};G.addEventListener("test",l,l),G.removeEventListener("test",l,l)}catch(cj){}const ck=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:cl}=s,cm="wheel";class cn{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=cl.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent,!!Y&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cm&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(ck&&b.deltaMode===G.WheelEvent.DOM_DELTA_PIXEL&&(a/=G.devicePixelRatio),b.deltaMode===G.WheelEvent.DOM_DELTA_LINE&&(a*=40));const c={x:b.clientX,y:b.clientY};0!==a&&a%4.000244140625==0&&(a=Math.floor(a/4.000244140625)),b.shiftKey&&a&&(a*=.25),this._onWheel(b,-a,c)}_onWheel(a,b,c){this.callback({type:cm,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:co}=s,cp="pointermove",cq="pointerover",cr="pointerout",cs="pointerleave";class ct{constructor(b,c,a={}){this.element=b,this.callback=c,this.pressed=!1,this.options=Object.assign({enable:!0},a),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=co.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cp&&(this.enableMoveEvent=b),a===cq&&(this.enableOverEvent=b),a===cr&&(this.enableOutEvent=b),a===cs&&(this.enableLeaveEvent=b)}handleEvent(a){this.handleOverEvent(a),this.handleOutEvent(a),this.handleLeaveEvent(a),this.handleMoveEvent(a)}handleOverEvent(a){this.enableOverEvent&&"mouseover"===a.type&&this.callback({type:cq,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:cr,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:cs,srcEvent:a,pointerType:"mouse",target:a.target})}handleMoveEvent(a){if(this.enableMoveEvent)switch(a.type){case"mousedown":a.button>=0&&(this.pressed=!0);break;case"mousemove":0===a.which&&(this.pressed=!1),this.pressed||this.callback({type:cp,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:cu}=s,cv="keydown",cw="keyup";class cx{constructor(a,c,b={}){this.element=a,this.callback=c,this.options=Object.assign({enable:!0},b),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=cu.concat(b.events||[]),this.handleEvent=this.handleEvent.bind(this),a.tabIndex=b.tabIndex||0,a.style.outline="none",this.events.forEach(b=>a.addEventListener(b,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===cv&&(this.enableDownEvent=b),a===cw&&(this.enableUpEvent=b)}handleEvent(a){const b=a.target||a.srcElement;("INPUT"!==b.tagName||"text"!==b.type)&&"TEXTAREA"!==b.tagName&&(this.enableDownEvent&&"keydown"===a.type&&this.callback({type:cv,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:cw,srcEvent:a,key:a.key,target:a.target}))}}const cy="contextmenu";class cz{constructor(a,b,c={}){this.element=a,this.callback=b,this.options=Object.assign({enable:!0},c),this.handleEvent=this.handleEvent.bind(this),a.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(a,b){a===cy&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:cy,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const cA={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},cB={srcElement:"root",priority:0};class cC{constructor(a){this.eventManager=a,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(f,g,a,h=!1,i=!1){const{handlers:j,handlersByElement:e}=this;a&&("object"!=typeof a||a.addEventListener)&&(a={srcElement:a}),a=a?Object.assign({},cB,a):cB;let b=e.get(a.srcElement);b||(b=[],e.set(a.srcElement,b));const c={type:f,handler:g,srcElement:a.srcElement,priority:a.priority};h&&(c.once=!0),i&&(c.passive=!0),j.push(c),this._active=this._active||!c.passive;let d=b.length-1;for(;d>=0&&!(b[d].priority>=c.priority);)d--;b.splice(d+1,0,c)}remove(f,g){const{handlers:b,handlersByElement:e}=this;for(let c=b.length-1;c>=0;c--){const a=b[c];if(a.type===f&&a.handler===g){b.splice(c,1);const d=e.get(a.srcElement);d.splice(d.indexOf(a),1),0===d.length&&e.delete(a.srcElement)}}this._active=b.some(a=>!a.passive)}handleEvent(c){if(this.isEmpty())return;const b=this._normalizeEvent(c);let a=c.srcEvent.target;for(;a&&a!==b.rootElement;){if(this._emit(b,a),b.handled)return;a=a.parentNode}this._emit(b,"root")}_emit(e,f){const a=this.handlersByElement.get(f);if(a){let g=!1;const h=()=>{e.handled=!0},i=()=>{e.handled=!0,g=!0},c=[];for(let b=0;b{const b=this.manager.get(a);b&&ce[a].forEach(a=>{b.recognizeWith(a)})}),b.recognizerOptions){const e=this.manager.get(d);if(e){const f=b.recognizerOptions[d];delete f.enable,e.set(f)}}for(const[h,c]of(this.wheelInput=new cn(a,this._onOtherEvent,{enable:!1}),this.moveInput=new ct(a,this._onOtherEvent,{enable:!1}),this.keyInput=new cx(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new cz(a,this._onOtherEvent,{enable:!1}),this.events))c.isEmpty()||(this._toggleRecognizer(c.recognizerName,!0),this.manager.on(h,c.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(a,b,c){this._addEventHandler(a,b,c,!1)}once(a,b,c){this._addEventHandler(a,b,c,!0)}watch(a,b,c){this._addEventHandler(a,b,c,!1,!0)}off(a,b){this._removeEventHandler(a,b)}_toggleRecognizer(a,b){const{manager:d}=this;if(!d)return;const c=d.get(a);if(c&&c.options.enable!==b){c.set({enable:b});const e=cf[a];e&&!this.options.recognizers&&e.forEach(e=>{const f=d.get(e);b?(f.requireFailure(a),c.dropRequireFailure(e)):f.dropRequireFailure(a)})}this.wheelInput.enableEventType(a,b),this.moveInput.enableEventType(a,b),this.keyInput.enableEventType(a,b),this.contextmenuInput.enableEventType(a,b)}_addEventHandler(b,e,d,f,g){if("string"!=typeof b){for(const h in d=e,b)this._addEventHandler(h,b[h],d,f,g);return}const{manager:i,events:j}=this,c=ci[b]||b;let a=j.get(c);!a&&(a=new cC(this),j.set(c,a),a.recognizerName=ch[c]||c,i&&i.on(c,a.handleEvent)),a.add(b,e,d,f,g),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(a,h){if("string"!=typeof a){for(const c in a)this._removeEventHandler(c,a[c]);return}const{events:d}=this,i=ci[a]||a,b=d.get(i);if(b&&(b.remove(a,h),b.isEmpty())){const{recognizerName:e}=b;let f=!1;for(const g of d.values())if(g.recognizerName===e&&!g.isEmpty()){f=!0;break}f||this._toggleRecognizer(e,!1)}}_onBasicInput(a){const{srcEvent:c}=a,b=cg[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function cE(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function cF(c){for(var a=1;a0),e=d&&!this.state.isHovering,h=!d&&this.state.isHovering;(c||e)&&(a.features=b,c&&c(a)),e&&cO.call(this,"onMouseEnter",a),h&&cO.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function cS(b){var c=this.props,d=c.onClick,f=c.onNativeClick,g=c.onDblClick,h=c.doubleClickZoom,a=[],e=g||h;switch(b.type){case"anyclick":a.push(f),e||a.push(d);break;case"click":e&&a.push(d)}(a=a.filter(Boolean)).length&&((b=cM.call(this,b)).features=cN.call(this,b.point),a.forEach(function(a){return a(b)}))}var m=(0,c.forwardRef)(function(b,h){var i,t,f=(0,c.useContext)(bJ),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new cD(null,{touchAction:b.touchAction,recognizerOptions:b.eventRecognizerOptions})},[]),g=(0,c.useRef)(null),e=(0,c.useRef)(null),a=(0,c.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;a.props=b,a.map=e.current&&e.current.getMap(),a.setState=function(c){a.state=cL(cL({},a.state),c),g.current.style.cursor=b.getCursor(a.state)};var j=!0,k=function(b,c,d){if(j){i=[b,c,d];return}var e=a.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(b,"position",{get:function(){return[0,0,bL(a.map,b)]}}),f&&f({viewState:b,interactionState:c,oldViewState:d}),g&&g(b,c,d)};(0,c.useImperativeHandle)(h,function(){var a;return{getMap:(a=e).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var d=(0,c.useMemo)(function(){return cL(cL({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||bP(a),a.viewport=d.viewport;var w=function(b){var c=b.isDragging,d=void 0!==c&&c;if(d!==a.state.isDragging&&a.setState({isDragging:d}),j){t=b;return}var e=a.props.onInteractionStateChange;e&&e(b)},l=function(){a.width&&a.height&&u.setOptions(cL(cL(cL({},a.props),a.props.viewState),{},{isInteractive:Boolean(a.props.onViewStateChange||a.props.onViewportChange),onViewportChange:k,onStateChange:w,eventManager:v,width:a.width,height:a.height}))},m=function(b){var c=b.width,d=b.height;a.width=c,a.height=d,l(),a.props.onResize({width:c,height:d})};(0,c.useEffect)(function(){return v.setElement(g.current),v.on({pointerdown:cP.bind(a),pointermove:cR.bind(a),pointerup:cQ.bind(a),pointerleave:cO.bind(a,"onMouseOut"),click:cS.bind(a),anyclick:cS.bind(a),dblclick:cO.bind(a,"onDblClick"),wheel:cO.bind(a,"onWheel"),contextmenu:cO.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),bK(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return ax(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ay(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}t&&w(t)}),l();var n=b.width,o=b.height,p=b.style,r=b.getCursor,s=(0,c.useMemo)(function(){return cL(cL({position:"relative"},p),{},{width:n,height:o,cursor:r(a.state)})},[p,n,o,r,a.state]);return i&&a._child||(a._child=c.createElement(bI,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,aw({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var cT=m;function cU(b,a){if(b===a)return!0;if(!b||!a)return!1;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!==a.length)return!1;for(var c=0;c prop: ".concat(e))}}(d,a,f.current):d=function(a,c,d){if(a.style&&a.style._loaded){var b=function(c){for(var a=1;a=0||(d[a]=c[a]);return d}(a,d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(a,b)&&(e[b]=a[b])}return e}(d,["layout","paint","filter","minzoom","maxzoom","beforeId"]);if(p!==a.beforeId&&b.moveLayer(c,p),e!==a.layout){var q=a.layout||{};for(var g in e)cU(e[g],q[g])||b.setLayoutProperty(c,g,e[g]);for(var r in q)e.hasOwnProperty(r)||b.setLayoutProperty(c,r,void 0)}if(f!==a.paint){var s=a.paint||{};for(var h in f)cU(f[h],s[h])||b.setPaintProperty(c,h,f[h]);for(var t in s)f.hasOwnProperty(t)||b.setPaintProperty(c,t,void 0)}for(var i in cU(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)cU(j[i],a[i])||b.setLayerProperty(c,i,j[i])}(c,d,a,b)}catch(e){console.warn(e)}}(a,d,b,e.current):function(a,d,b){if(a.style&&a.style._loaded){var c=cY(cY({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ab;var f={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},d={captureScroll:a.bool,captureDrag:a.bool,captureClick:a.bool,captureDoubleClick:a.bool,capturePointerMove:a.bool};function c$(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(bJ),e=(0,c.useRef)(null),f=(0,c.useRef)({props:d,state:{},context:a,containerRef:e}),b=f.current;return b.props=d,b.context=a,(0,c.useEffect)(function(){return function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(c){var b=a.props;b.captureScroll&&c.stopPropagation(),b.onScroll&&b.onScroll(c,a)},panstart:function(c){var b=a.props;b.captureDrag&&c.stopPropagation(),b.onDragStart&&b.onDragStart(c,a)},anyclick:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onNativeClick&&b.onNativeClick(c,a)},click:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onClick&&b.onClick(c,a)},dblclick:function(c){var b=a.props;b.captureDoubleClick&&c.stopPropagation(),b.onDoubleClick&&b.onDoubleClick(c,a)},pointermove:function(c){var b=a.props;b.capturePointerMove&&c.stopPropagation(),b.onPointerMove&&b.onPointerMove(c,a)}};return c.watch(d,b),function(){c.off(d)}}}(b)},[a.eventManager]),b}function c_(b){var a=b.instance,c=c$(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){bV(a,b);var d,e,f=(d=a,e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=bY(d);if(e){var c=bY(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return bX(this,a)});function a(){var b;bk(this,a);for(var e=arguments.length,h=new Array(e),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var c="x"===d?a.offsetWidth:a.offsetHeight;return c6(b/100*c)/c*100};function c8(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}var ae=Object.assign({},ac,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),af=Object.assign({},ad,{className:""});function t(b){var d,j,e,k,f,l,m,a,h=(d=b,e=(j=aA((0,c.useState)(null),2))[0],k=j[1],f=aA((0,c.useState)(null),2),l=f[0],m=f[1],a=c$(c1(c1({},d),{},{onDragStart:c4})),a.callbacks=d,a.state.dragPos=e,a.state.setDragPos=k,a.state.dragOffset=l,a.state.setDragOffset=m,(0,c.useEffect)(function(){return function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return function(b,a){var h=a.props,c=a.callbacks,d=a.state,i=a.context;b.stopPropagation();var e=c2(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=c3(e,f,h,i),c.onDrag(g)}}(b,a)},panend:function(b){return function(c,a){var h=a.props,d=a.callbacks,b=a.state,i=a.context;c.stopPropagation();var e=b.dragPos,f=b.dragOffset;if(b.setDragPos(null),b.setDragOffset(null),d.onDragEnd&&e&&f){var g=Object.assign({},c);g.lngLat=c3(e,f,h,i),d.onDragEnd(g)}}(b,a)},pancancel:function(d){var c,b;return c=d,b=a.state,void(c.stopPropagation(),b.setDragPos(null),b.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}}(a)},[a.context.eventManager,Boolean(e)]),a),o=h.state,p=h.containerRef,q=b.children,r=b.className,s=b.draggable,A=b.style,t=o.dragPos,u=function(b){var a=b.props,e=b.state,f=b.context,g=a.longitude,h=a.latitude,j=a.offsetLeft,k=a.offsetTop,c=e.dragPos,d=e.dragOffset,l=f.viewport,m=f.map;if(c&&d)return[c[0]+d[0],c[1]+d[1]];var n=bL(m,{longitude:g,latitude:h}),i=aA(l.project([g,h,n]),2),o=i[0],p=i[1];return[o+=j,p+=k]}(h),n=aA(u,2),v=n[0],w=n[1],x="translate(".concat(c6(v),"px, ").concat(c6(w),"px)"),y=s?t?"grabbing":"grab":"auto",z=(0,c.useMemo)(function(){var a=function(c){for(var a=1;a0){var t=b,u=e;for(b=0;b<=1;b+=.5)k=(i=n-b*h)+h,e=Math.max(0,d-i)+Math.max(0,k-p+d),e0){var w=a,x=f;for(a=0;a<=1;a+=v)l=(j=m-a*g)+g,f=Math.max(0,d-j)+Math.max(0,l-o+d),f1||h< -1||f<0||f>p.width||g<0||g>p.height?i.display="none":i.zIndex=Math.floor((1-h)/2*1e5)),i),S=(0,c.useCallback)(function(b){t.props.onClose();var a=t.context.eventManager;a&&a.once("click",function(a){return a.stopPropagation()},b.target)},[]);return c.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(L," ").concat(N),style:R,ref:u},c.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:O}}),c.createElement("div",{key:"content",ref:j,className:"mapboxgl-popup-content"},P&&c.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:S},"\xd7"),Q))}function da(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}u.propTypes=ag,u.defaultProps=ah,c.memo(u);var ai=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string)])}),aj=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=c$(a),d=b.context,i=b.containerRef,j=(0,c.useRef)(null),e=aA((0,c.useState)(!1),2),f=e[0],m=e[1];(0,c.useEffect)(function(){var h,e,c,f,g,b;return d.map&&(h=(e={customAttribution:a.customAttribution},c=d.map,f=i.current,g=j.current,(b=new(A()).AttributionControl(e))._map=c,b._container=f,b._innerContainer=g,b._updateAttributions(),b._updateEditLink(),c.on("styledata",b._updateData),c.on("sourcedata",b._updateData),b)),function(){var a;return h&&void((a=h)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[d.map]);var h=void 0===a.compact?d.viewport.width<=640:a.compact;(0,c.useEffect)(function(){!h&&f&&m(!1)},[h]);var k=(0,c.useCallback)(function(){return m(function(a){return!a})},[]),l=(0,c.useMemo)(function(){return function(c){for(var a=1;ac)return 1}return 0}(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),f=b.viewport.bearing,d={transform:"rotate(".concat(-f,"deg)")},2===e?c.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:d}):c.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:d})))))}function di(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}y.propTypes=ao,y.defaultProps=ap,c.memo(y);var aq=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ar=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=c$(a),f=d.context,h=d.containerRef,e=aA((0,c.useState)(null),2),b=e[0],j=e[1];(0,c.useEffect)(function(){if(f.map){var a=new(A()).ScaleControl;a._map=f.map,a._container=h.current,j(a)}},[f.map]),b&&(b.options=a,b._onMove());var i=(0,c.useMemo)(function(){return function(c){for(var a=1;a. Did you mean "together", "forwards" or "backwards"?', revealOrder); - break; } else error1('%s is not a supported value for revealOrder on . Did you mean "together", "forwards" or "backwards"?', revealOrder); - if (void 0 !== revealOrder && 'forwards' !== revealOrder && 'backwards' !== revealOrder && 'together' !== revealOrder && !didWarnAboutRevealOrder[revealOrder]) if (didWarnAboutRevealOrder[revealOrder] = !0, 'string' == typeof revealOrder) switch(revealOrder.toLowerCase()){ - case 'together': - case 'forwards': - case 'backwards': - error1('"%s" is not a valid value for revealOrder on . Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase()); - break; - case 'forward': - case 'backward': - error1('"%s" is not a valid value for revealOrder on . React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase()); - break; - default: - error1('"%s" is not a supported revealOrder on . Did you mean "together", "forwards" or "backwards"?', revealOrder); } }(revealOrder1), tailMode = tailMode1, revealOrder2 = revealOrder1, void 0 === tailMode || didWarnAboutTailOptions[tailMode] || ('collapsed' !== tailMode && 'hidden' !== tailMode ? (didWarnAboutTailOptions[tailMode] = !0, error1('"%s" is not a supported value for tail on . Did you mean "collapsed" or "hidden"?', tailMode)) : 'forwards' !== revealOrder2 && 'backwards' !== revealOrder2 && (didWarnAboutTailOptions[tailMode] = !0, error1(' is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?', tailMode))), function(children, revealOrder) { if (('forwards' === revealOrder || 'backwards' === revealOrder) && null != children && !1 !== children) { @@ -7679,12 +7666,7 @@ var ref = finishedWork.ref; if (null !== ref) { var instanceToUse, instance = finishedWork.stateNode; - switch(finishedWork.tag){ - case 5: - default: - instanceToUse = instance; - } - 'function' == typeof ref ? ref(instanceToUse) : (ref.hasOwnProperty('current') || error1("Unexpected ref object provided for %s. Use either a ref-setter function or React.createRef().", getComponentName(finishedWork.type)), ref.current = instanceToUse); + instanceToUse = (finishedWork.tag, instance), 'function' == typeof ref ? ref(instanceToUse) : (ref.hasOwnProperty('current') || error1("Unexpected ref object provided for %s. Use either a ref-setter function or React.createRef().", getComponentName(finishedWork.type)), ref.current = instanceToUse); } } function commitDetachRef(current) { @@ -9162,13 +9144,7 @@ } function getPublicRootInstance(container) { var containerFiber = container.current; - if (!containerFiber.child) return null; - switch(containerFiber.child.tag){ - case 5: - return containerFiber.child.stateNode; - default: - return containerFiber.child.stateNode; - } + return containerFiber.child ? (containerFiber.child.tag, containerFiber.child.stateNode) : null; } function markRetryLaneImpl(fiber, retryLane) { var a, b, suspenseState = fiber.memoizedState; diff --git a/crates/swc_ecma_minifier/tests/terser/compress/reduce_vars/issue_1670_6/output.js b/crates/swc_ecma_minifier/tests/terser/compress/reduce_vars/issue_1670_6/output.js index 9df228ffa19a..9f4edfadb505 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/reduce_vars/issue_1670_6/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/reduce_vars/issue_1670_6/output.js @@ -1,9 +1,4 @@ -(function (a) { - switch (1) { - case (a = 1): - console.log(a); - break; - default: - console.log(2); - } +(function(a) { + if (1 === (a = 1)) console.log(a); + else console.log(2); })(1); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1679/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1679/output.js index f856f019829a..00e78d24bfcb 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1679/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1679/output.js @@ -1,14 +1,10 @@ -var a = 100, - b = 10; +var a = 100, b = 10; function f() { - switch (--b) { + switch(--b){ default: case false: case b--: - switch (0) { - default: - case a--: - } + a--; break; case a++: } diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1705_1/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1705_1/output.js index 5b3eaa6d1847..2f102e6bd9af 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1705_1/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1705_1/output.js @@ -1,6 +1,3 @@ var a = 0; -switch (a) { - default: - console.log("FAIL"); - case 0: -} +a; +console.log("FAIL"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/keep_default/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/keep_default/output.js index 4f2eaddb914e..d3e90e1e1cf9 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/keep_default/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/keep_default/output.js @@ -1,6 +1,2 @@ -switch (foo) { - case "bar": - baz(); - default: - something(); -} +if ("bar" === foo) baz(); +something(); From 3e29bb5bd10e0f039ef345aeb39e2463b8f72a14 Mon Sep 17 00:00:00 2001 From: austaras Date: Sun, 17 Apr 2022 11:51:05 +0800 Subject: [PATCH 06/27] remove label --- .../src/compress/optimize/mod.rs | 18 ++-------- .../src/compress/optimize/switches.rs | 34 +++---------------- 2 files changed, 7 insertions(+), 45 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 9917a34be46a..d78a868764da 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -133,8 +133,6 @@ struct Ctx { /// `true` while handling `expr` of `!expr` in_bang_arg: bool, in_var_decl_of_for_in_or_of_loop: bool, - /// `true` while handling inner statements of a labelled statement. - stmt_labelled: bool, dont_use_negated_iife: bool, @@ -1551,7 +1549,6 @@ where #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] fn visit_mut_block_stmt(&mut self, n: &mut BlockStmt) { let ctx = Ctx { - stmt_labelled: false, top_level: false, in_block: true, scope: n.span.ctxt, @@ -1957,13 +1954,7 @@ where #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] fn visit_mut_function(&mut self, n: &mut Function) { - { - let ctx = Ctx { - stmt_labelled: false, - ..self.ctx - }; - n.decorators.visit_mut_with(&mut *self.with_ctx(ctx)); - } + n.decorators.visit_mut_with(self); let is_standalone = n.span.has_mark(self.marks.standalone); @@ -1978,7 +1969,6 @@ where { let ctx = Ctx { skip_standalone: self.ctx.skip_standalone || is_standalone, - stmt_labelled: false, in_fn_like: true, scope: n.span.ctxt, can_inline_arguments: true, @@ -2044,13 +2034,9 @@ where #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] fn visit_mut_labeled_stmt(&mut self, n: &mut LabeledStmt) { - let ctx = Ctx { - stmt_labelled: true, - ..self.ctx - }; let old_label = self.label.take(); self.label = Some(n.label.to_id()); - n.visit_mut_children_with(&mut *self.with_ctx(ctx)); + n.visit_mut_children_with(self); if self.label.is_none() { report_change!("Removing label `{}`", n.label); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 53147d2b6799..dd72067cece5 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -2,7 +2,7 @@ use std::mem::take; use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, DUMMY_SP}; use swc_ecma_ast::*; -use swc_ecma_utils::{ident::IdentLike, prepend, ExprExt, StmtExt, Type, Value::Known}; +use swc_ecma_utils::{prepend, ExprExt, StmtExt, Type, Value::Known}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use super::Optimizer; @@ -19,16 +19,12 @@ where /// Handle switches in the case where we can know which branch will be /// taken. pub(super) fn optimize_const_switches(&mut self, s: &mut Stmt) { - if !self.options.switches || !self.options.dead_code || self.ctx.stmt_labelled { + if !self.options.switches || !self.options.dead_code { return; } - let (label, stmt) = match s { - Stmt::Switch(s) => (None, s), - Stmt::Labeled(l) => match &mut *l.body { - Stmt::Switch(s) => (Some(l.label.clone()), s), - _ => return, - }, + let stmt = match s { + Stmt::Switch(s) => s, _ => return, }; @@ -121,19 +117,6 @@ where found_break = true; false } - - // TODO: Search recursively. - Stmt::Break(BreakStmt { - label: Some(break_label), - .. - }) => { - if Some(break_label.to_id()) == label.as_ref().map(|label| label.to_id()) { - found_break = true; - false - } else { - !found_break - } - } _ => !found_break, }); @@ -185,14 +168,7 @@ where }) }; - *s = match label { - Some(label) => Stmt::Labeled(LabeledStmt { - span: DUMMY_SP, - label, - body: Box::new(inner), - }), - None => inner, - }; + *s = inner; } } From f7747c67a74f967433f217d3fbf0b9004ecbb47d Mon Sep 17 00:00:00 2001 From: austaras Date: Sun, 17 Apr 2022 17:09:28 +0800 Subject: [PATCH 07/27] refact --- .../src/compress/optimize/conditionals.rs | 11 ++-- .../src/compress/optimize/if_return.rs | 11 +--- .../src/compress/optimize/switches.rs | 9 +-- .../src/compress/pure/dead_code.rs | 7 +-- .../src/compress/util/mod.rs | 38 ------------- crates/swc_ecma_utils/src/lib.rs | 57 +++++++++++++------ 6 files changed, 51 insertions(+), 82 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/conditionals.rs b/crates/swc_ecma_minifier/src/compress/optimize/conditionals.rs index 29ee9bd75ca8..57d0cd944406 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/conditionals.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/conditionals.rs @@ -3,14 +3,11 @@ use std::mem::swap; use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::ext::ExprRefExt; -use swc_ecma_utils::{ident::IdentLike, ExprExt, ExprFactory, StmtLike}; +use swc_ecma_utils::{ident::IdentLike, ExprExt, ExprFactory, StmtExt, StmtLike}; use super::Optimizer; use crate::{ - compress::{ - optimize::Ctx, - util::{always_terminates, negate_cost}, - }, + compress::{optimize::Ctx, util::negate_cost}, mode::Mode, DISABLE_BUGGY_PASSES, }; @@ -701,7 +698,7 @@ where cons, alt: Some(..), .. - })) => always_terminates(cons), + })) => cons.terminates(), _ => false, }); if !need_work { @@ -720,7 +717,7 @@ where cons, alt: Some(alt), .. - }) if always_terminates(&cons) => { + }) if cons.terminates() => { new_stmts.push(T::from_stmt(Stmt::If(IfStmt { span, test, diff --git a/crates/swc_ecma_minifier/src/compress/optimize/if_return.rs b/crates/swc_ecma_minifier/src/compress/optimize/if_return.rs index b83c7266af41..e7b706b8c8d3 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/if_return.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/if_return.rs @@ -1,15 +1,10 @@ use swc_common::{util::take::Take, Spanned, DUMMY_SP}; use swc_ecma_ast::*; -use swc_ecma_utils::{prepend, undefined, StmtLike}; +use swc_ecma_utils::{prepend, undefined, StmtExt, StmtLike}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use super::Optimizer; -use crate::{ - compress::util::{always_terminates, is_pure_undefined}, - debug::dump, - mode::Mode, - util::ExprOptExt, -}; +use crate::{compress::util::is_pure_undefined, debug::dump, mode::Mode, util::ExprOptExt}; /// Methods related to the option `if_return`. All methods are noop if /// `if_return` is false. @@ -587,7 +582,7 @@ fn always_terminates_with_return_arg(s: &Stmt) -> bool { fn can_merge_as_if_return(s: &Stmt) -> bool { fn cost(s: &Stmt) -> Option { if let Stmt::Block(..) = s { - if !always_terminates(s) { + if !s.terminates() { return None; } } diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index dd72067cece5..234618d2c0de 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -6,10 +6,7 @@ use swc_ecma_utils::{prepend, ExprExt, StmtExt, Type, Value::Known}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use super::Optimizer; -use crate::{ - compress::util::{abort_stmts, is_pure_undefined}, - mode::Mode, -}; +use crate::{compress::util::is_pure_undefined, mode::Mode}; /// Methods related to option `switches`. impl Optimizer<'_, M> @@ -378,9 +375,9 @@ where } [first, second] if first.test.is_none() || second.test.is_none() => { report_change!("switches: Turn two cases switch into if else"); - let abort = abort_stmts(&first.cons); + let terminate = first.cons.terminates(); - if abort { + if terminate { if let Stmt::Break(BreakStmt { label: None, .. }) = first.cons.last().unwrap() { diff --git a/crates/swc_ecma_minifier/src/compress/pure/dead_code.rs b/crates/swc_ecma_minifier/src/compress/pure/dead_code.rs index 2da2743d4ab5..e13281aecd28 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/dead_code.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/dead_code.rs @@ -4,10 +4,7 @@ use swc_ecma_utils::{ExprExt, StmtExt, StmtLike, Value}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use super::Pure; -use crate::{ - compress::util::{always_terminates, is_fine_for_if_cons}, - util::ModuleItemExt, -}; +use crate::{compress::util::is_fine_for_if_cons, util::ModuleItemExt}; /// Methods related to option `dead_code`. impl Pure<'_> { @@ -204,7 +201,7 @@ impl Pure<'_> { .iter() .enumerate() .find(|(_, stmt)| match stmt.as_stmt() { - Some(s) => always_terminates(s), + Some(s) => s.terminates(), _ => false, }); diff --git a/crates/swc_ecma_minifier/src/compress/util/mod.rs b/crates/swc_ecma_minifier/src/compress/util/mod.rs index 686c50b25c9b..7fbcdfe2e3b1 100644 --- a/crates/swc_ecma_minifier/src/compress/util/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/util/mod.rs @@ -533,18 +533,6 @@ pub(crate) fn eval_as_number(e: &Expr) -> Option { None } -pub(crate) fn always_terminates(s: &Stmt) -> bool { - match s { - Stmt::Return(..) | Stmt::Throw(..) | Stmt::Break(..) | Stmt::Continue(..) => true, - Stmt::If(IfStmt { cons, alt, .. }) => { - always_terminates(cons) && alt.as_deref().map(always_terminates).unwrap_or(false) - } - Stmt::Block(s) => s.stmts.iter().any(always_terminates), - - _ => false, - } -} - pub(crate) fn is_ident_used_by(id: Id, node: &N) -> bool where N: for<'aa> VisitWith>, @@ -793,29 +781,3 @@ impl Visit for SuperFinder { self.found = true; } } - -/// stmts contain top level return/break/continue/throw -pub(crate) fn abort(stmt: &Stmt) -> bool { - match stmt { - Stmt::Break(_) | Stmt::Continue(_) | Stmt::Throw(_) | Stmt::Return(_) => return true, - Stmt::Block(block) if abort_stmts(&block.stmts) => return true, - Stmt::If(IfStmt { - cons, - alt: Some(alt), - .. - }) if abort(cons) && abort(alt) => return true, - _ => (), - } - - false -} - -pub(crate) fn abort_stmts(stmts: &[Stmt]) -> bool { - for s in stmts { - if abort(s) { - return true; - } - } - - false -} diff --git a/crates/swc_ecma_utils/src/lib.rs b/crates/swc_ecma_utils/src/lib.rs index 509024634414..814fb84d71b3 100644 --- a/crates/swc_ecma_utils/src/lib.rs +++ b/crates/swc_ecma_utils/src/lib.rs @@ -350,13 +350,8 @@ pub fn extract_var_ids>(node: &T) -> Vec { } pub trait StmtExt { - fn into_stmt(self) -> Stmt; - fn as_stmt(&self) -> &Stmt; - /// Extracts hoisted variables - fn extract_var_ids(&self) -> Vec { - extract_var_ids(self.as_stmt()) - } + fn extract_var_ids(&self) -> Vec; fn extract_var_ids_as_var(&self) -> Option { let ids = self.extract_var_ids(); @@ -379,29 +374,55 @@ pub trait StmtExt { .collect(), }) } + + /// stmts contain top level return/break/continue/throw + fn terminates(&self) -> bool; } impl StmtExt for Stmt { - #[inline] - fn into_stmt(self) -> Stmt { - self + fn extract_var_ids(&self) -> Vec { + extract_var_ids(self) } - #[inline] - fn as_stmt(&self) -> &Stmt { - self + fn terminates(&self) -> bool { + match self { + Stmt::Break(_) | Stmt::Continue(_) | Stmt::Throw(_) | Stmt::Return(_) => return true, + Stmt::Block(block) if block.stmts.terminates() => return true, + Stmt::If(IfStmt { + cons, + alt: Some(alt), + .. + }) if cons.terminates() && alt.terminates() => return true, + _ => (), + } + + false } } impl StmtExt for Box { - #[inline] - fn into_stmt(self) -> Stmt { - *self + fn extract_var_ids(&self) -> Vec { + extract_var_ids(&**self) } - #[inline] - fn as_stmt(&self) -> &Stmt { - &**self + fn terminates(&self) -> bool { + (&**self).terminates() + } +} + +impl StmtExt for Vec { + fn extract_var_ids(&self) -> Vec { + extract_var_ids(self) + } + + fn terminates(&self) -> bool { + for s in self { + if s.terminates() { + return true; + } + } + + false } } From 147210b82b230bbc92f5e3e6a76356d3762faf0a Mon Sep 17 00:00:00 2001 From: austaras Date: Mon, 18 Apr 2022 18:52:13 +0800 Subject: [PATCH 08/27] add test --- .../{ => call}/analysis-snapshot.rust-debug | 0 .../simple/switch/const/{ => call}/input.js | 0 .../simple/switch/const/{ => call}/output.js | 0 .../const/order/analysis-snapshot.rust-debug | 80 +++++++++++++++++++ .../simple/switch/const/order/input.js | 10 +++ .../simple/switch/const/order/output.js | 2 + 6 files changed, 92 insertions(+) rename crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/{ => call}/analysis-snapshot.rust-debug (100%) rename crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/{ => call}/input.js (100%) rename crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/{ => call}/output.js (100%) create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/input.js create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/analysis-snapshot.rust-debug similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/analysis-snapshot.rust-debug rename to crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/analysis-snapshot.rust-debug diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/input.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/input.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/input.js rename to crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/input.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/output.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/output.js rename to crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/output.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..eb5a7472317c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('a' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 3, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 3, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/input.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/input.js new file mode 100644 index 000000000000..96fc826c4c22 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/input.js @@ -0,0 +1,10 @@ +switch (1) { + case a(): + console.log(111); + break; + case 1: + console.log(222); + break; + case 2: + console.log(333); +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js new file mode 100644 index 000000000000..9943b6038e02 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js @@ -0,0 +1,2 @@ +if (1 === a()) console.log(111); +else console.log(222); From b7b489cf261034430681ecfc663fc447ac888937 Mon Sep 17 00:00:00 2001 From: austaras Date: Tue, 19 Apr 2022 01:40:42 +0800 Subject: [PATCH 09/27] const switch --- .../src/compress/optimize/mod.rs | 2 - .../src/compress/optimize/switches.rs | 273 ++++++++---------- .../src/compress/util/mod.rs | 12 + .../default/analysis-snapshot.rust-debug | 42 +++ .../simple/switch/const/default/config.json | 5 + .../simple/switch/const/default/input.js | 10 + .../simple/switch/const/default/output.js | 1 + .../simple/switch/const/order/output.js | 3 +- .../compress/switch/issue_1680_1/output.js | 8 +- .../compress/switch/issue_1750/output.js | 5 +- 10 files changed, 202 insertions(+), 159 deletions(-) create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/config.json create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/input.js create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/output.js diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index d78a868764da..eeb3822044d9 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -2526,8 +2526,6 @@ where fn visit_mut_switch_stmt(&mut self, n: &mut SwitchStmt) { n.discriminant.visit_mut_with(self); - self.drop_unreachable_cases(n); - n.cases.visit_mut_with(self); } diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 234618d2c0de..0b7b8bfd1d4c 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -1,12 +1,10 @@ -use std::mem::take; - use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, DUMMY_SP}; use swc_ecma_ast::*; -use swc_ecma_utils::{prepend, ExprExt, StmtExt, Type, Value::Known}; +use swc_ecma_utils::{prepend, ExprFactory, StmtExt}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use super::Optimizer; -use crate::{compress::util::is_pure_undefined, mode::Mode}; +use crate::{compress::util::is_primitive, mode::Mode}; /// Methods related to option `switches`. impl Optimizer<'_, M> @@ -35,137 +33,121 @@ where let discriminant = &mut stmt.discriminant; - let tail = tail_expr(discriminant); - - match tail { - Expr::Lit(_) => (), - e if is_pure_undefined(e) => (), - _ => return, - } - - let matching_case = stmt.cases.iter_mut().position(|case| { - case.test - .as_ref() - .map(|test| tail.eq_ignore_span(tail_expr(test))) - .unwrap_or(false) - }); + let tail = if let Some(e) = is_primitive(tail_expr(discriminant)) { + e + } else { + return; + }; - if let Some(case_idx) = matching_case { - let mut var_ids = vec![]; - let mut stmts = vec![]; - - let should_preserve_switch = stmt.cases[..=case_idx].iter().any(|case| { - let mut v = BreakFinder { - top_level: true, - nested_unlabelled_break: false, - }; - case.visit_with(&mut v); - v.nested_unlabelled_break - }); - if should_preserve_switch { - // Prevent infinite loop. - if stmt.cases.len() == 1 { - return; + let mut var_ids = vec![]; + let mut cases = Vec::new(); + let mut exact = None; + + for (idx, case) in stmt.cases.iter_mut().enumerate() { + if let Some(test) = case.test.as_ref() { + if let Some(e) = is_primitive(tail_expr(test)) { + if e.eq_ignore_span(tail) { + cases.push(case.take()); + exact = Some(idx); + break; + } else { + var_ids.extend(case.cons.extract_var_ids()) + } + } else { + cases.push(case.take()) } - - report_change!("switches: Removing unreachable cases from a constant switch"); } else { - report_change!("switches: Removing a constant switch"); + cases.push(case.take()) } + } - self.changed = true; - let mut preserved = vec![]; - if !should_preserve_switch && !discriminant.is_lit() { - preserved.push(Stmt::Expr(ExprStmt { - span: stmt.span, - expr: discriminant.take(), - })); - - for test in stmt.cases[..case_idx] - .iter_mut() - .filter_map(|case| case.test.as_mut()) - { - preserved.push(Stmt::Expr(ExprStmt { - span: DUMMY_SP, - expr: test.take(), - })); + if let Some(exact) = exact { + let exact_case = cases.last_mut().unwrap(); + let mut terminate = exact_case.cons.terminates(); + for case in stmt.cases[(exact + 1)..].iter_mut() { + if terminate { + var_ids.extend(case.cons.extract_var_ids()) + } else { + terminate |= case.cons.terminates(); + exact_case.cons.extend(case.cons.take()) } } + // remove default if there's an exact match + cases.retain(|case| case.test.is_some()) + } - for case in &stmt.cases[..case_idx] { - for cons in &case.cons { - var_ids.extend( - cons.extract_var_ids() - .into_iter() - .map(|name| VarDeclarator { - span: DUMMY_SP, - name: Pat::Ident(name.into()), - init: None, - definite: Default::default(), - }), - ); - } + if cases.len() == stmt.cases.len() { + stmt.cases = cases; + return; + } + + self.changed = true; + + let var_ids: Vec = var_ids + .into_iter() + .map(|name| VarDeclarator { + span: DUMMY_SP, + name: Pat::Ident(name.into()), + init: None, + definite: Default::default(), + }) + .collect(); + + // only exact or default match + if cases.len() == 1 && !contains_nested_break(&cases[0]) { + report_change!("switches: Removing a constant switch"); + + let mut stmts = Vec::new(); + + if !var_ids.is_empty() { + stmts.push(Stmt::Decl(Decl::Var(VarDecl { + span: DUMMY_SP, + kind: VarDeclKind::Var, + declare: Default::default(), + decls: var_ids, + }))) } - for case in stmt.cases.iter_mut().skip(case_idx) { - let mut found_break = false; - case.cons.retain(|stmt| match stmt { - Stmt::Break(BreakStmt { label: None, .. }) => { - found_break = true; - false - } - _ => !found_break, - }); + stmts.push(discriminant.take().into_stmt()); + let mut last = cases.pop().unwrap(); + remove_last_break(&mut last.cons); - for case_stmt in case.cons.take() { - match case_stmt { - Stmt::Decl(Decl::Var(v)) if v.decls.iter().all(|v| v.init.is_none()) => { - var_ids.extend(v.decls) - } - _ => { - stmts.push(case_stmt); - } - } - } - if found_break { - break; - } + if let Some(test) = last.test { + stmts.push(test.into_stmt()); } - if !var_ids.is_empty() { - prepend( - &mut stmts, - Stmt::Decl(Decl::Var(VarDecl { - span: DUMMY_SP, - kind: VarDeclKind::Var, - declare: Default::default(), - decls: take(&mut var_ids), - })), - ) + stmts.extend(last.cons); + *s = Stmt::Block(BlockStmt { + span: DUMMY_SP, + stmts, + }) + } else { + report_change!("switches: Removing unreachable cases from a constant switch"); + + if cases.len() == 2 { + let last = cases.last_mut().unwrap(); + remove_last_break(&mut last.cons); + if let Some(test) = last.test.take() { + prepend(&mut last.cons, test.into_stmt()) + } } - let inner = if should_preserve_switch { - let mut cases = stmt.cases.take(); - let case = SwitchCase { - span: cases[case_idx].span, - test: cases[case_idx].test.take(), - cons: stmts, - }; - - Stmt::Switch(SwitchStmt { - span: stmt.span, - discriminant: stmt.discriminant.take(), - cases: vec![case], - }) - } else { - preserved.extend(stmts); - Stmt::Block(BlockStmt { + stmt.cases = cases; + + if !var_ids.is_empty() { + *s = Stmt::Block(BlockStmt { span: DUMMY_SP, - stmts: preserved, + stmts: vec![ + Stmt::Decl(Decl::Var(VarDecl { + span: DUMMY_SP, + kind: VarDeclKind::Var, + declare: Default::default(), + decls: var_ids, + })), + s.take(), + ], }) - }; - - *s = inner; + } } } @@ -226,11 +208,7 @@ where } if let Some(last) = cases.last_mut() { - if let Some(Stmt::Break(BreakStmt { label: None, .. })) = last.cons.last() { - report_change!("switches: Removing `break` at the end"); - self.changed = true; - last.cons.pop(); - } + self.changed |= remove_last_break(&mut last.cons); } } @@ -291,29 +269,6 @@ where } } - /// Remove unreachable cases using discriminant. - pub(super) fn drop_unreachable_cases(&mut self, s: &mut SwitchStmt) { - if !self.options.switches { - return; - } - - let dt = s.discriminant.get_type(); - - if let Known(Type::Bool) = dt { - let db = s.discriminant.as_pure_bool(); - - if let Known(db) = db { - s.cases.retain(|case| match case.test.as_deref() { - Some(test) => { - let tb = test.as_pure_bool(); - !matches!(tb, Known(tb) if db != tb) - } - None => false, - }) - } - } - } - /// Try turn switch into if and remove empty switch pub(super) fn optimize_switches(&mut self, s: &mut Stmt) { if !self.options.switches { @@ -331,12 +286,7 @@ where } [case] => { report_change!("switches: Turn one case switch into if"); - let mut v = BreakFinder { - top_level: true, - nested_unlabelled_break: false, - }; - case.visit_with(&mut v); - if v.nested_unlabelled_break { + if contains_nested_break(case) { return; } @@ -446,6 +396,25 @@ where } } +fn remove_last_break(stmt: &mut Vec) -> bool { + if let Some(Stmt::Break(BreakStmt { label: None, .. })) = stmt.last() { + report_change!("switches: Removing `break` at the end"); + stmt.pop(); + true + } else { + false + } +} + +fn contains_nested_break(case: &SwitchCase) -> bool { + let mut v = BreakFinder { + top_level: true, + nested_unlabelled_break: false, + }; + case.visit_with(&mut v); + v.nested_unlabelled_break +} + #[derive(Default)] struct BreakFinder { top_level: bool, diff --git a/crates/swc_ecma_minifier/src/compress/util/mod.rs b/crates/swc_ecma_minifier/src/compress/util/mod.rs index 7fbcdfe2e3b1..cf0a2a309dc9 100644 --- a/crates/swc_ecma_minifier/src/compress/util/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/util/mod.rs @@ -381,6 +381,18 @@ pub(crate) fn is_pure_undefined(e: &Expr) -> bool { } } +pub(crate) fn is_primitive(e: &Expr) -> Option<&Expr> { + if is_pure_undefined(e) { + Some(e) + } else { + match e { + Expr::Lit(Lit::Regex(_)) => None, + Expr::Lit(_) => Some(e), + _ => None, + } + } +} + pub(crate) fn is_valid_identifier(s: &str, ascii_only: bool) -> bool { if ascii_only { if s.chars().any(|c| !c.is_ascii()) { diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..731daaa0caa3 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/analysis-snapshot.rust-debug @@ -0,0 +1,42 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 3, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 3, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/config.json b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/config.json new file mode 100644 index 000000000000..ced94d4770b7 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/config.json @@ -0,0 +1,5 @@ +{ + "conditionals": false, + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/input.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/input.js new file mode 100644 index 000000000000..42898d684758 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/input.js @@ -0,0 +1,10 @@ +switch (1) { + case 2: + console.log(111); + break; + case 3: + console.log(222); + break; + default: + console.log(333); +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/output.js new file mode 100644 index 000000000000..6068bdbcf96a --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/output.js @@ -0,0 +1 @@ +console.log(333); diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js index 9943b6038e02..c5d1d069d224 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js @@ -1,2 +1 @@ -if (1 === a()) console.log(111); -else console.log(222); +1 === a() ? console.log(111) : console.log(222); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1680_1/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1680_1/output.js index 8e5058d564bc..7cfad2d7d982 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1680_1/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1680_1/output.js @@ -2,4 +2,10 @@ function f(x) { console.log(x); return x + 1; } -f(5); +switch(2){ + case f(0): + case f(1): + f(2); + case 2: + f(5); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1750/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1750/output.js index 5e03cc4a7afd..884c64ff0f19 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1750/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1750/output.js @@ -1,3 +1,4 @@ -var a = 0, - b = 1; +var a = 0, b = 1; +a; +b = 2; console.log(a, b); From 671808feb9b6005461f9c51041de1c30942e55ae Mon Sep 17 00:00:00 2001 From: austaras Date: Tue, 19 Apr 2022 01:44:22 +0800 Subject: [PATCH 10/27] update tests --- ...ithSwitchStatements01_es2015.2.minified.js | 7 ---- ...lsWithSwitchStatements01_es5.2.minified.js | 7 ---- ...ithSwitchStatements03_es2015.2.minified.js | 11 ------ ...lsWithSwitchStatements03_es5.2.minified.js | 11 ------ ...ithSwitchStatements04_es2015.2.minified.js | 8 ---- ...lsWithSwitchStatements04_es5.2.minified.js | 8 ---- ...switchBreakStatements_es2015.2.minified.js | 12 +++--- .../switchBreakStatements_es5.2.minified.js | 12 +++--- .../switchStatements_es2015.2.minified.js | 37 +------------------ .../switchStatements_es5.2.minified.js | 35 ------------------ ...ingInSwitchAndCaseES6_es2015.2.minified.js | 1 - ...StringInSwitchAndCase_es2015.2.minified.js | 1 - ...InEnclosingStatements_es2015.2.minified.js | 12 +----- ...rowInEnclosingStatements_es5.2.minified.js | 22 ++--------- ...fFormFunctionEquality_es2015.2.minified.js | 3 +- ...rdOfFormFunctionEquality_es5.2.minified.js | 3 +- 16 files changed, 20 insertions(+), 170 deletions(-) diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es2015.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es2015.2.minified.js index 9025d4c9edfd..e69de29bb2d1 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es2015.2.minified.js @@ -1,7 +0,0 @@ -let x, y; -switch(x){ - case "foo": - break; - case "bar": - case y: -} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es5.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es5.2.minified.js index 640327e9a3c1..e69de29bb2d1 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements01_es5.2.minified.js @@ -1,7 +0,0 @@ -var x, y; -switch(x){ - case "foo": - break; - case "bar": - case y: -} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es2015.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es2015.2.minified.js index 1d2ee654888a..e69de29bb2d1 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es2015.2.minified.js @@ -1,11 +0,0 @@ -let x, z; -switch(x){ - case randBool() ? "foo" : "baz": - case randBool(), "bar": - case "bar": - case "baz": - case "foo": - break; - case "bar": - case z || "baz": -} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es5.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es5.2.minified.js index 6013014f3474..e69de29bb2d1 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements03_es5.2.minified.js @@ -1,11 +0,0 @@ -var x, z; -switch(x){ - case randBool() ? "foo" : "baz": - case randBool(), "bar": - case "bar": - case "baz": - case "foo": - break; - case "bar": - case z || "baz": -} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es2015.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es2015.2.minified.js index 068d5a3ef978..e69de29bb2d1 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es2015.2.minified.js @@ -1,8 +0,0 @@ -let x, y; -switch(y){ - case x: - case "foo": - case "baz": - break; - case x: -} diff --git a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es5.2.minified.js b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es5.2.minified.js index 4f4db3f8f566..e69de29bb2d1 100644 --- a/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/stringLiteralsWithSwitchStatements04_es5.2.minified.js @@ -1,8 +0,0 @@ -var x, y; -switch(y){ - case x: - case "foo": - case "baz": - break; - case x: -} diff --git a/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js index 110e6d502e11..872a4b1cc7f0 100644 --- a/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/switchBreakStatements_es2015.2.minified.js @@ -1,6 +1,6 @@ -ONE: if (0) break ONE; -TWO: THREE: if (0) break THREE; -FOUR: if (0) { - FIVE: if (0) break FOUR; -} -SEVEN: ; +''; +ONE: ''; +TWO: THREE: ''; +FOUR: ''; +''; +SEVEN: ''; diff --git a/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js index 110e6d502e11..700463322f80 100644 --- a/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/switchBreakStatements_es5.2.minified.js @@ -1,6 +1,6 @@ -ONE: if (0) break ONE; -TWO: THREE: if (0) break THREE; -FOUR: if (0) { - FIVE: if (0) break FOUR; -} -SEVEN: ; +""; +ONE: ""; +TWO: THREE: ""; +FOUR: ""; +""; +SEVEN: ""; diff --git a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js index 3940cd423548..48fafa369072 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es2015.2.minified.js @@ -5,40 +5,5 @@ var M; } M1.fn = fn; }(M || (M = {})), new class { -}(), new Object(); -}(M || (M = {})), x){ - case '': - case 12: - case !0: - case null: - case void 0: - case new Date(12): - case new Object(): - case /[a-z]/: - case []: - case {}: - case { - id: 12 - }: - case [ - 'a' - ]: - case typeof x: - case typeof M: - case M.fn(1): - case (x)=>'' - : -} -class C { -} -switch(new C()){ - case new class extends C { - }(): - case { - id: 12, - name: '' - }: - case new C(): -} -new Date(12), new Object(), (x)=>'' +}(), new Object(), (x)=>'' ; diff --git a/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js index 290ef64b756b..a463698f4be1 100644 --- a/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/switchStatements_es5.2.minified.js @@ -3,31 +3,6 @@ import * as swcHelpers from "@swc/helpers"; return ""; }; var M, C = function() { -}, x){ - case "": - case 12: - case !0: - case null: - case void 0: - case new Date(12): - case new Object(): - case /[a-z]/: - case []: - case {}: - case { - id: 12 - }: - case [ - "a" - ]: - case void 0 === x ? "undefined" : swcHelpers.typeOf(x): - case void 0 === M ? "undefined" : swcHelpers.typeOf(M): - case M.fn(1): - case function(x) { - return ""; - }: -} -var M, x, C = function() { "use strict"; swcHelpers.classCallCheck(this, C); }, D = function(C1) { @@ -40,13 +15,3 @@ var M, x, C = function() { return D; }(C); new C(), new Object(); -switch(new C()){ - case new D(): - case { - id: 12, - name: "" - }: - case new C(): -} -new Date(12), new Object(); -new C(), new C(), new Date(12), new Object(); diff --git a/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es2015.2.minified.js b/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es2015.2.minified.js index d67c8c8a7dbe..e69de29bb2d1 100644 --- a/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInSwitchAndCaseES6_es2015.2.minified.js @@ -1 +0,0 @@ -"def1def"; diff --git a/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es2015.2.minified.js b/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es2015.2.minified.js index d67c8c8a7dbe..e69de29bb2d1 100644 --- a/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringInSwitchAndCase_es2015.2.minified.js @@ -1 +0,0 @@ -"def1def"; diff --git a/crates/swc/tests/tsc-references/throwInEnclosingStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/throwInEnclosingStatements_es2015.2.minified.js index ca0f2235b0da..c0f66859d4e4 100644 --- a/crates/swc/tests/tsc-references/throwInEnclosingStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/throwInEnclosingStatements_es2015.2.minified.js @@ -1,11 +1,3 @@ var y; -switch(y){ - case 'a': - throw y; - default: - throw y; -} -for(;;)throw 0; -for(;;)throw 0; -for(var idx in {})throw idx; -for(;;)throw null; +if ('a' === y) throw y; +throw y; diff --git a/crates/swc/tests/tsc-references/throwInEnclosingStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/throwInEnclosingStatements_es5.2.minified.js index 121d8fea41fa..793d5e42d221 100644 --- a/crates/swc/tests/tsc-references/throwInEnclosingStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/throwInEnclosingStatements_es5.2.minified.js @@ -1,20 +1,4 @@ +var y; import * as swcHelpers from "@swc/helpers"; -switch(y){ - case "a": - throw y; - default: - throw y; -} -for(;;)throw 0; -for(;;)throw 0; -for(var idx in {})throw idx; -for(;;)throw null; -var y, C = function() { - "use strict"; - function C() { - throw swcHelpers.classCallCheck(this, C), this; - } - return C.prototype.biz = function() { - throw this.value; - }, C; -}(); +if ("a" === y) throw y; +throw y; diff --git a/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es2015.2.minified.js index 39774c3fd3ea..de5c4ada3a81 100644 --- a/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es2015.2.minified.js @@ -1,2 +1 @@ -isString1(0, ""), isString1(0, ""), isString2(""); -isString1(0, "") === isString2(""), isString1(0, "") === isString2(""); +isString1(0, ""), isString2(""), isString1(0, ""), isString2(""); diff --git a/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es5.2.minified.js b/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es5.2.minified.js index 39774c3fd3ea..de5c4ada3a81 100644 --- a/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardOfFormFunctionEquality_es5.2.minified.js @@ -1,2 +1 @@ -isString1(0, ""), isString1(0, ""), isString2(""); -isString1(0, "") === isString2(""), isString1(0, "") === isString2(""); +isString1(0, ""), isString2(""), isString1(0, ""), isString2(""); From 4ad69fccecdd559a5df610acf1594ecca816e9b6 Mon Sep 17 00:00:00 2001 From: austaras Date: Tue, 19 Apr 2022 17:35:04 +0800 Subject: [PATCH 11/27] add lots of tests --- .../src/compress/optimize/switches.rs | 1 + .../switch/merge/analysis-snapshot.rust-debug | 80 +++++++++ .../fixture/simple/switch/merge/input.js | 10 ++ .../fixture/simple/switch/merge/output.js | 8 + .../drop_case_2/analysis-snapshot.rust-debug | 118 +++++++++++++ .../compress/switch/drop_case_2/config.json | 4 + .../compress/switch/drop_case_2/input.js | 9 + .../compress/switch/drop_case_2/output.js | 6 + .../switch/drop_case_2/output.terser.js | 6 + .../analysis-snapshot.rust-debug | 80 +++++++++ .../switch/gut_entire_switch/config.json | 4 + .../switch/gut_entire_switch/input.js | 7 + .../switch/gut_entire_switch/output.js | 2 + .../switch/gut_entire_switch/output.terser.js | 2 + .../analysis-snapshot.rust-debug | 80 +++++++++ .../switch/gut_entire_switch_2/config.json | 4 + .../switch/gut_entire_switch_2/input.js | 7 + .../switch/gut_entire_switch_2/output.js | 2 + .../gut_entire_switch_2/output.terser.js | 2 + .../if_else/analysis-snapshot.rust-debug | 118 +++++++++++++ .../compress/switch/if_else/config.json | 4 + .../terser/compress/switch/if_else/input.js | 7 + .../terser/compress/switch/if_else/output.js | 2 + .../compress/switch/if_else/output.terser.js | 2 + .../if_else2/analysis-snapshot.rust-debug | 118 +++++++++++++ .../compress/switch/if_else2/config.json | 4 + .../terser/compress/switch/if_else2/input.js | 6 + .../terser/compress/switch/if_else2/output.js | 2 + .../compress/switch/if_else2/output.terser.js | 2 + .../if_else3/analysis-snapshot.rust-debug | 118 +++++++++++++ .../compress/switch/if_else3/config.json | 4 + .../terser/compress/switch/if_else3/input.js | 7 + .../terser/compress/switch/if_else3/output.js | 2 + .../compress/switch/if_else3/output.terser.js | 2 + .../if_else4/analysis-snapshot.rust-debug | 118 +++++++++++++ .../compress/switch/if_else4/config.json | 4 + .../terser/compress/switch/if_else4/input.js | 6 + .../terser/compress/switch/if_else4/output.js | 2 + .../compress/switch/if_else4/output.terser.js | 2 + .../if_else5/analysis-snapshot.rust-debug | 80 +++++++++ .../compress/switch/if_else5/config.json | 5 + .../terser/compress/switch/if_else5/input.js | 7 + .../terser/compress/switch/if_else5/output.js | 5 + .../compress/switch/if_else5/output.terser.js | 5 + .../if_else6/analysis-snapshot.rust-debug | 80 +++++++++ .../compress/switch/if_else6/config.json | 5 + .../terser/compress/switch/if_else6/input.js | 6 + .../terser/compress/switch/if_else6/output.js | 3 + .../compress/switch/if_else6/output.terser.js | 3 + .../if_else7/analysis-snapshot.rust-debug | 118 +++++++++++++ .../compress/switch/if_else7/config.json | 4 + .../terser/compress/switch/if_else7/input.js | 7 + .../terser/compress/switch/if_else7/output.js | 2 + .../compress/switch/if_else7/output.terser.js | 2 + .../if_else8/analysis-snapshot.rust-debug | 118 +++++++++++++ .../compress/switch/if_else8/config.json | 3 + .../terser/compress/switch/if_else8/input.js | 9 + .../terser/compress/switch/if_else8/output.js | 4 + .../compress/switch/if_else8/output.terser.js | 4 + .../issue_1083_1/analysis-snapshot.rust-debug | 156 ++++++++++++++++++ .../compress/switch/issue_1083_1/config.json | 4 + .../compress/switch/issue_1083_1/input.js | 13 ++ .../compress/switch/issue_1083_1/output.js | 12 ++ .../switch/issue_1083_1/output.terser.js | 12 ++ .../issue_1083_2/analysis-snapshot.rust-debug | 156 ++++++++++++++++++ .../compress/switch/issue_1083_2/config.json | 4 + .../compress/switch/issue_1083_2/input.js | 13 ++ .../compress/switch/issue_1083_2/output.js | 12 ++ .../switch/issue_1083_2/output.terser.js | 12 ++ .../issue_1083_3/analysis-snapshot.rust-debug | 156 ++++++++++++++++++ .../compress/switch/issue_1083_3/config.json | 4 + .../compress/switch/issue_1083_3/input.js | 13 ++ .../compress/switch/issue_1083_3/output.js | 6 + .../switch/issue_1083_3/output.terser.js | 6 + .../issue_1083_4/analysis-snapshot.rust-debug | 156 ++++++++++++++++++ .../compress/switch/issue_1083_4/config.json | 4 + .../compress/switch/issue_1083_4/input.js | 13 ++ .../compress/switch/issue_1083_4/output.js | 6 + .../switch/issue_1083_4/output.terser.js | 6 + .../issue_1083_5/analysis-snapshot.rust-debug | 156 ++++++++++++++++++ .../compress/switch/issue_1083_5/config.json | 4 + .../compress/switch/issue_1083_5/input.js | 15 ++ .../compress/switch/issue_1083_5/output.js | 14 ++ .../switch/issue_1083_5/output.terser.js | 14 ++ .../issue_1083_6/analysis-snapshot.rust-debug | 156 ++++++++++++++++++ .../compress/switch/issue_1083_6/config.json | 4 + .../compress/switch/issue_1083_6/input.js | 15 ++ .../compress/switch/issue_1083_6/output.js | 14 ++ .../switch/issue_1083_6/output.terser.js | 14 ++ .../turn_into_if/analysis-snapshot.rust-debug | 80 +++++++++ .../compress/switch/turn_into_if/config.json | 4 + .../compress/switch/turn_into_if/input.js | 5 + .../compress/switch/turn_into_if/output.js | 2 + .../switch/turn_into_if/output.terser.js | 2 + .../analysis-snapshot.rust-debug | 80 +++++++++ .../switch/turn_into_if_2/config.json | 4 + .../compress/switch/turn_into_if_2/input.js | 6 + .../compress/switch/turn_into_if_2/output.js | 2 + .../switch/turn_into_if_2/output.terser.js | 2 + 99 files changed, 2789 insertions(+) create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/input.js create mode 100644 crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/output.terser.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/config.json create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/input.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/output.js create mode 100644 crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/output.terser.js diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 0b7b8bfd1d4c..f3ce5ad5bd60 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -127,6 +127,7 @@ where if cases.len() == 2 { let last = cases.last_mut().unwrap(); remove_last_break(&mut last.cons); + // so that following pass could turn it into if else if let Some(test) = last.test.take() { prepend(&mut last.cons, test.into_stmt()) } diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..f516e7f286fd --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('a' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 3, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 3, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/input.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/input.js new file mode 100644 index 000000000000..dbc1c2cc4255 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/input.js @@ -0,0 +1,10 @@ +switch (a) { + case 1: + console.log(1); + break; + case 2: + console.log(2); + break; + default: + console.log(1); +} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js new file mode 100644 index 000000000000..3d3bede5bd42 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js @@ -0,0 +1,8 @@ +switch (a) { + case 1: + default: + console.log(1); + break; + case 2: + console.log(2); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..a3f0d8906ff4 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/analysis-snapshot.rust-debug @@ -0,0 +1,118 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('bar' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('foo' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('moo' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/config.json new file mode 100644 index 000000000000..7c685532f125 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/config.json @@ -0,0 +1,4 @@ +{ + "dead_code": true, + "switches": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/input.js new file mode 100644 index 000000000000..d2dc51796c99 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/input.js @@ -0,0 +1,9 @@ +switch (foo) { + case "bar": + bar(); + break; + case "moo": + case moo: + case "baz": + break; +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.js new file mode 100644 index 000000000000..67bc9b72b4a8 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.js @@ -0,0 +1,6 @@ +switch (foo) { + case "bar": + bar(); + case "moo": + case moo: +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.terser.js new file mode 100644 index 000000000000..67bc9b72b4a8 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.terser.js @@ -0,0 +1,6 @@ +switch (foo) { + case "bar": + bar(); + case "moo": + case moo: +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..e863fb5028a4 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('id' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/input.js new file mode 100644 index 000000000000..d3913948a5f2 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/input.js @@ -0,0 +1,7 @@ +switch (id(123)) { + case 1: + case 2: + case 3: + default: + console.log("PASS"); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js new file mode 100644 index 000000000000..5cf989a75381 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js @@ -0,0 +1,2 @@ +id(123); +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.terser.js new file mode 100644 index 000000000000..5cf989a75381 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.terser.js @@ -0,0 +1,2 @@ +id(123); +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..e863fb5028a4 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('id' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/input.js new file mode 100644 index 000000000000..43893cee675c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/input.js @@ -0,0 +1,7 @@ +switch (id(123)) { + case 1: + "no side effect"; + case 1: + default: + console.log("PASS"); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.js new file mode 100644 index 000000000000..5cf989a75381 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.js @@ -0,0 +1,2 @@ +id(123); +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.terser.js new file mode 100644 index 000000000000..5cf989a75381 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.terser.js @@ -0,0 +1,2 @@ +id(123); +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..2c808e8807e9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/analysis-snapshot.rust-debug @@ -0,0 +1,118 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('bar' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('foo' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('other' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/config.json new file mode 100644 index 000000000000..7c685532f125 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/config.json @@ -0,0 +1,4 @@ +{ + "dead_code": true, + "switches": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/input.js new file mode 100644 index 000000000000..c727eb4e448f --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/input.js @@ -0,0 +1,7 @@ +switch (foo) { + case "bar": + bar(); + break; + default: + other(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/output.js new file mode 100644 index 000000000000..8e0bd39ab587 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/output.js @@ -0,0 +1,2 @@ +if ("bar" === foo) bar(); +else other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/output.terser.js new file mode 100644 index 000000000000..8e0bd39ab587 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else/output.terser.js @@ -0,0 +1,2 @@ +if ("bar" === foo) bar(); +else other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..2c808e8807e9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/analysis-snapshot.rust-debug @@ -0,0 +1,118 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('bar' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('foo' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('other' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/config.json new file mode 100644 index 000000000000..7c685532f125 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/config.json @@ -0,0 +1,4 @@ +{ + "dead_code": true, + "switches": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/input.js new file mode 100644 index 000000000000..c3f919d9a444 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/input.js @@ -0,0 +1,6 @@ +switch (foo) { + case "bar": + bar(); + default: + other(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/output.js new file mode 100644 index 000000000000..ca79f1ea6acc --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/output.js @@ -0,0 +1,2 @@ +if ("bar" === foo) bar(); +other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/output.terser.js new file mode 100644 index 000000000000..ca79f1ea6acc --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else2/output.terser.js @@ -0,0 +1,2 @@ +if ("bar" === foo) bar(); +other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..2c808e8807e9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/analysis-snapshot.rust-debug @@ -0,0 +1,118 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('bar' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('foo' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('other' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/config.json new file mode 100644 index 000000000000..7c685532f125 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/config.json @@ -0,0 +1,4 @@ +{ + "dead_code": true, + "switches": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/input.js new file mode 100644 index 000000000000..51668684e757 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/input.js @@ -0,0 +1,7 @@ +switch (foo) { + default: + other(); + break; + case "bar": + bar(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/output.js new file mode 100644 index 000000000000..8e0bd39ab587 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/output.js @@ -0,0 +1,2 @@ +if ("bar" === foo) bar(); +else other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/output.terser.js new file mode 100644 index 000000000000..8e0bd39ab587 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else3/output.terser.js @@ -0,0 +1,2 @@ +if ("bar" === foo) bar(); +else other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..2c808e8807e9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/analysis-snapshot.rust-debug @@ -0,0 +1,118 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('bar' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('foo' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('other' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/config.json new file mode 100644 index 000000000000..7c685532f125 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/config.json @@ -0,0 +1,4 @@ +{ + "dead_code": true, + "switches": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/input.js new file mode 100644 index 000000000000..21fb9b647d25 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/input.js @@ -0,0 +1,6 @@ +switch (foo) { + default: + other(); + case "bar": + bar(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/output.js new file mode 100644 index 000000000000..861c3ce19443 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/output.js @@ -0,0 +1,2 @@ +if ("bar" !== foo) other(); +bar(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/output.terser.js new file mode 100644 index 000000000000..861c3ce19443 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else4/output.terser.js @@ -0,0 +1,2 @@ +if ("bar" !== foo) other(); +bar(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..31593d33f01b --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('bar' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('other' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/config.json new file mode 100644 index 000000000000..592bd78fdf8c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/config.json @@ -0,0 +1,5 @@ +{ + "dead_code": true, + "switches": true, + "evaluate": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/input.js new file mode 100644 index 000000000000..f3c3654b1428 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/input.js @@ -0,0 +1,7 @@ +switch (1) { + case bar: + bar(); + break; + case 1: + other(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.js new file mode 100644 index 000000000000..be0116bee079 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.js @@ -0,0 +1,5 @@ +if (1 === bar) bar(); +else { + 1; + other(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.terser.js new file mode 100644 index 000000000000..be0116bee079 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.terser.js @@ -0,0 +1,5 @@ +if (1 === bar) bar(); +else { + 1; + other(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..31593d33f01b --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('bar' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('other' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/config.json new file mode 100644 index 000000000000..592bd78fdf8c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/config.json @@ -0,0 +1,5 @@ +{ + "dead_code": true, + "switches": true, + "evaluate": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/input.js new file mode 100644 index 000000000000..d3b63c5579b0 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/input.js @@ -0,0 +1,6 @@ +switch (1) { + case bar: + bar(); + case 1: + other(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.js new file mode 100644 index 000000000000..1300d6adcc71 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.js @@ -0,0 +1,3 @@ +if (1 === bar) bar(); +1; +other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.terser.js new file mode 100644 index 000000000000..1300d6adcc71 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.terser.js @@ -0,0 +1,3 @@ +if (1 === bar) bar(); +1; +other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..2c808e8807e9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/analysis-snapshot.rust-debug @@ -0,0 +1,118 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('bar' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('foo' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('other' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/config.json new file mode 100644 index 000000000000..7c685532f125 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/config.json @@ -0,0 +1,4 @@ +{ + "dead_code": true, + "switches": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/input.js new file mode 100644 index 000000000000..cea593247136 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/input.js @@ -0,0 +1,7 @@ +switch (foo) { + case "bar": + break; + bar(); + default: + other(); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.js new file mode 100644 index 000000000000..63849f978001 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.js @@ -0,0 +1,2 @@ +if ("bar" === foo); +else other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.terser.js new file mode 100644 index 000000000000..63849f978001 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.terser.js @@ -0,0 +1,2 @@ +if ("bar" === foo); +else other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..3f4771abbb33 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/analysis-snapshot.rust-debug @@ -0,0 +1,118 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('foo' type=inline), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('test' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 1, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: true, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/config.json new file mode 100644 index 000000000000..ee65e9fdc67e --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/config.json @@ -0,0 +1,3 @@ +{ + "defaults": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/input.js new file mode 100644 index 000000000000..9c4ccd6f9a9d --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/input.js @@ -0,0 +1,9 @@ +function test(foo) { + switch (foo) { + case "bar": + return "PASS"; + default: + return "FAIL"; + } +} +console.log(test("bar")); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/output.js new file mode 100644 index 000000000000..4a0cfa4e3318 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/output.js @@ -0,0 +1,4 @@ +function test(foo) { + return "bar" === foo ? "PASS" : "FAIL"; +} +console.log(test("bar")); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/output.terser.js new file mode 100644 index 000000000000..4a0cfa4e3318 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else8/output.terser.js @@ -0,0 +1,4 @@ +function test(foo) { + return "bar" === foo ? "PASS" : "FAIL"; +} +console.log(test("bar")); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..e905e161aa1f --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/analysis-snapshot.rust-debug @@ -0,0 +1,156 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('definitely_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('maybe_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('test' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/input.js new file mode 100644 index 000000000000..dc11bff83493 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/input.js @@ -0,0 +1,13 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + default: + console.log("PASS"); + break; + case maybe_true: + console.log("FAIL"); + break; + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/output.js new file mode 100644 index 000000000000..5741ce780ad8 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/output.js @@ -0,0 +1,12 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + default: + console.log("PASS"); + break; + case maybe_true: + console.log("FAIL"); + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/output.terser.js new file mode 100644 index 000000000000..5741ce780ad8 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_1/output.terser.js @@ -0,0 +1,12 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + default: + console.log("PASS"); + break; + case maybe_true: + console.log("FAIL"); + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..e905e161aa1f --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/analysis-snapshot.rust-debug @@ -0,0 +1,156 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('definitely_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('maybe_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('test' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/input.js new file mode 100644 index 000000000000..dc11bff83493 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/input.js @@ -0,0 +1,13 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + default: + console.log("PASS"); + break; + case maybe_true: + console.log("FAIL"); + break; + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/output.js new file mode 100644 index 000000000000..5741ce780ad8 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/output.js @@ -0,0 +1,12 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + default: + console.log("PASS"); + break; + case maybe_true: + console.log("FAIL"); + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/output.terser.js new file mode 100644 index 000000000000..5741ce780ad8 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_2/output.terser.js @@ -0,0 +1,12 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + default: + console.log("PASS"); + break; + case maybe_true: + console.log("FAIL"); + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..e905e161aa1f --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/analysis-snapshot.rust-debug @@ -0,0 +1,156 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('definitely_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('maybe_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('test' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/input.js new file mode 100644 index 000000000000..c5d398a8e3ee --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/input.js @@ -0,0 +1,13 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case maybe_true: + console.log("maybe"); + break; + default: + case definitely_true: + console.log("definitely"); + break; + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/output.js new file mode 100644 index 000000000000..b892764257bf --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/output.js @@ -0,0 +1,6 @@ +function test(definitely_true, maybe_true) { + if (true === maybe_true) console.log("maybe"); + else console.log("definitely"); +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/output.terser.js new file mode 100644 index 000000000000..b892764257bf --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_3/output.terser.js @@ -0,0 +1,6 @@ +function test(definitely_true, maybe_true) { + if (true === maybe_true) console.log("maybe"); + else console.log("definitely"); +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..e905e161aa1f --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/analysis-snapshot.rust-debug @@ -0,0 +1,156 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('definitely_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('maybe_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('test' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/input.js new file mode 100644 index 000000000000..ef3a6539544c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/input.js @@ -0,0 +1,13 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case maybe_true: + console.log("maybe"); + break; + case definitely_true: + default: + console.log("definitely"); + break; + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/output.js new file mode 100644 index 000000000000..b892764257bf --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/output.js @@ -0,0 +1,6 @@ +function test(definitely_true, maybe_true) { + if (true === maybe_true) console.log("maybe"); + else console.log("definitely"); +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/output.terser.js new file mode 100644 index 000000000000..b892764257bf --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_4/output.terser.js @@ -0,0 +1,6 @@ +function test(definitely_true, maybe_true) { + if (true === maybe_true) console.log("maybe"); + else console.log("definitely"); +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..c75633ae3d23 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/analysis-snapshot.rust-debug @@ -0,0 +1,156 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 3, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 3, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('definitely_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('maybe_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('test' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/input.js new file mode 100644 index 000000000000..4eacbef4ac0d --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/input.js @@ -0,0 +1,15 @@ +function test(definitely_true, maybe_true) { + switch (true) { + default: + console.log("definitely"); + break; + case maybe_true: + console.log("maybe"); + break; + case definitely_true: + console.log("definitely"); + break; + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js new file mode 100644 index 000000000000..f107471c8528 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js @@ -0,0 +1,14 @@ +function test(definitely_true, maybe_true) { + switch (true) { + default: + console.log("definitely"); + break; + case maybe_true: + console.log("maybe"); + break; + case definitely_true: + console.log("definitely"); + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.terser.js new file mode 100644 index 000000000000..f107471c8528 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.terser.js @@ -0,0 +1,14 @@ +function test(definitely_true, maybe_true) { + switch (true) { + default: + console.log("definitely"); + break; + case maybe_true: + console.log("maybe"); + break; + case definitely_true: + console.log("definitely"); + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..c75633ae3d23 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/analysis-snapshot.rust-debug @@ -0,0 +1,156 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 3, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 3, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('definitely_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('maybe_true' type=dynamic), + #2, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 1, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: true, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 1, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: true, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('test' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: true, + declared_count: 1, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: false, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: true, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/input.js new file mode 100644 index 000000000000..42a600de91c1 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/input.js @@ -0,0 +1,15 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + console.log("definitely"); + break; + case maybe_true: + console.log("maybe"); + break; + default: + console.log("definitely"); + break; + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.js new file mode 100644 index 000000000000..8909a538a1ad --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.js @@ -0,0 +1,14 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + console.log("definitely"); + break; + case maybe_true: + console.log("maybe"); + break; + default: + console.log("definitely"); + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.terser.js new file mode 100644 index 000000000000..8909a538a1ad --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.terser.js @@ -0,0 +1,14 @@ +function test(definitely_true, maybe_true) { + switch (true) { + case definitely_true: + console.log("definitely"); + break; + case maybe_true: + console.log("maybe"); + break; + default: + console.log("definitely"); + } +} +test(true, false); +test(true, true); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..962344713970 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('id' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/input.js new file mode 100644 index 000000000000..a80f5186341d --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/input.js @@ -0,0 +1,5 @@ +switch (id(1)) { + case id(2): + console.log("FAIL"); +} +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/output.js new file mode 100644 index 000000000000..5f26a6a1d46c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/output.js @@ -0,0 +1,2 @@ +if (id(1) === id(2)) console.log("FAIL"); +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/output.terser.js new file mode 100644 index 000000000000..5f26a6a1d46c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if/output.terser.js @@ -0,0 +1,2 @@ +if (id(1) === id(2)) console.log("FAIL"); +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..962344713970 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('id' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/config.json b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/config.json new file mode 100644 index 000000000000..c39c8d07f6c9 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/config.json @@ -0,0 +1,4 @@ +{ + "switches": true, + "dead_code": true +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/input.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/input.js new file mode 100644 index 000000000000..54a54151fa66 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/input.js @@ -0,0 +1,6 @@ +switch (id(1)) { + case id(2): + console.log("FAIL"); + default: + console.log("PASS"); +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/output.js new file mode 100644 index 000000000000..5f26a6a1d46c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/output.js @@ -0,0 +1,2 @@ +if (id(1) === id(2)) console.log("FAIL"); +console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/output.terser.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/output.terser.js new file mode 100644 index 000000000000..5f26a6a1d46c --- /dev/null +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/turn_into_if_2/output.terser.js @@ -0,0 +1,2 @@ +if (id(1) === id(2)) console.log("FAIL"); +console.log("PASS"); From 24e175ce4f7895273dcf2cb227ec00d6a2c3dc32 Mon Sep 17 00:00:00 2001 From: austaras Date: Tue, 19 Apr 2022 19:17:10 +0800 Subject: [PATCH 12/27] fix --- .../src/compress/optimize/switches.rs | 98 ++++++++++--------- .../simple/switch/const/call/output.js | 2 +- .../terser/compress/switch/if_else5/output.js | 5 +- .../terser/compress/switch/if_else6/output.js | 1 - .../compress/switch/issue_1083_5/output.js | 4 +- .../compress/switch/issue_1705_1/output.js | 3 +- 6 files changed, 55 insertions(+), 58 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index f3ce5ad5bd60..31145e9d5f37 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -73,7 +73,17 @@ where } } // remove default if there's an exact match - cases.retain(|case| case.test.is_some()) + cases.retain(|case| case.test.is_some()); + + if cases.len() == 2 { + let last = cases.last_mut().unwrap(); + + self.changed = true; + // so that following pass could turn it into if else + if let Some(test) = last.test.take() { + prepend(&mut last.cons, test.into_stmt()) + } + } } if cases.len() == stmt.cases.len() { @@ -81,6 +91,8 @@ where return; } + self.optimize_switch_cases(&mut cases); + self.changed = true; let var_ids: Vec = var_ids @@ -93,8 +105,10 @@ where }) .collect(); - // only exact or default match - if cases.len() == 1 && !contains_nested_break(&cases[0]) { + if cases.len() == 1 + && (cases[0].test.is_none() || exact.is_some()) + && !contains_nested_break(&cases[0]) + { report_change!("switches: Removing a constant switch"); let mut stmts = Vec::new(); @@ -124,15 +138,6 @@ where } else { report_change!("switches: Removing unreachable cases from a constant switch"); - if cases.len() == 2 { - let last = cases.last_mut().unwrap(); - remove_last_break(&mut last.cons); - // so that following pass could turn it into if else - if let Some(test) = last.test.take() { - prepend(&mut last.cons, test.into_stmt()) - } - } - stmt.cases = cases; if !var_ids.is_empty() { @@ -279,6 +284,7 @@ where if let Stmt::Switch(sw) = s { match &mut *sw.cases { [] => { + self.changed = true; report_change!("switches: Removing empty switch"); *s = Stmt::Expr(ExprStmt { span: sw.span, @@ -286,10 +292,12 @@ where }) } [case] => { - report_change!("switches: Turn one case switch into if"); if contains_nested_break(case) { return; } + self.changed = true; + report_change!("switches: Turn one case switch into if"); + remove_last_break(&mut case.cons); let case = case.take(); let discriminant = sw.discriminant.take(); @@ -325,15 +333,15 @@ where } } [first, second] if first.test.is_none() || second.test.is_none() => { + if contains_nested_break(first) || contains_nested_break(second) { + return; + } + self.changed = true; report_change!("switches: Turn two cases switch into if else"); let terminate = first.cons.terminates(); if terminate { - if let Stmt::Break(BreakStmt { label: None, .. }) = - first.cons.last().unwrap() - { - first.cons.pop(); - } + remove_last_break(&mut first.cons); // they cannot both be default as that's syntax error let (def, case) = if first.test.is_none() { (first, second) @@ -363,28 +371,32 @@ where ), }) } else { - let (def, case) = if first.test.is_none() { - (first, second) - } else { - (second, first) - }; let mut stmts = vec![Stmt::If(IfStmt { span: DUMMY_SP, - test: Expr::Bin(BinExpr { - span: DUMMY_SP, - op: op!("==="), - left: sw.discriminant.take(), - right: case.test.take().unwrap(), + test: Expr::Bin(if first.test.is_none() { + BinExpr { + span: DUMMY_SP, + op: op!("!=="), + left: sw.discriminant.take(), + right: second.test.take().unwrap(), + } + } else { + BinExpr { + span: DUMMY_SP, + op: op!("==="), + left: sw.discriminant.take(), + right: first.test.take().unwrap(), + } }) .into(), cons: Stmt::Block(BlockStmt { span: DUMMY_SP, - stmts: case.cons.take(), + stmts: first.cons.take(), }) .into(), alt: None, })]; - stmts.extend(def.cons.take()); + stmts.extend(second.cons.take()); *s = Stmt::Block(BlockStmt { span: sw.span, stmts, @@ -422,18 +434,6 @@ struct BreakFinder { nested_unlabelled_break: bool, } -impl BreakFinder { - fn visit_nested + ?Sized>(&mut self, s: &S) { - if self.top_level { - self.top_level = false; - s.visit_children_with(self); - self.top_level = true; - } else { - s.visit_children_with(self); - } - } -} - impl Visit for BreakFinder { noop_visit_type!(); @@ -443,12 +443,14 @@ impl Visit for BreakFinder { } } - fn visit_stmts(&mut self, stmts: &[Stmt]) { - self.visit_nested(stmts) - } - fn visit_if_stmt(&mut self, i: &IfStmt) { - self.visit_nested(i) + if self.top_level { + self.top_level = false; + i.visit_children_with(self); + self.top_level = true; + } else { + i.visit_children_with(self); + } } /// We don't care about breaks in a loop @@ -466,6 +468,8 @@ impl Visit for BreakFinder { /// We don't care about breaks in a loop fn visit_while_stmt(&mut self, _: &WhileStmt) {} + fn visit_switch_stmt(&mut self, _: &SwitchStmt) {} + fn visit_function(&mut self, _: &Function) {} fn visit_arrow_expr(&mut self, _: &ArrowExpr) {} diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/output.js index 7591ac66bc52..0ae5a4396820 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/output.js @@ -1 +1 @@ -if (a() === a()) console.log(123); +a() === a() && console.log(123); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.js index be0116bee079..3ff0c5a96448 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else5/output.js @@ -1,5 +1,2 @@ if (1 === bar) bar(); -else { - 1; - other(); -} +else other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.js index 1300d6adcc71..8b487596170d 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else6/output.js @@ -1,3 +1,2 @@ if (1 === bar) bar(); -1; other(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js index f107471c8528..5ee4dcd329fe 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js @@ -1,8 +1,6 @@ function test(definitely_true, maybe_true) { - switch (true) { + switch(true){ default: - console.log("definitely"); - break; case maybe_true: console.log("maybe"); break; diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1705_1/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1705_1/output.js index 2f102e6bd9af..012de9e478a6 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1705_1/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1705_1/output.js @@ -1,3 +1,2 @@ var a = 0; -a; -console.log("FAIL"); +if (0 !== a) console.log("FAIL"); From d0d759e5ae50381fe384e7a2f92e1062c61a12df Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 01:25:21 +0800 Subject: [PATCH 13/27] merge cases --- .../src/compress/optimize/switches.rs | 91 +++++++++---------- .../fixture/simple/switch/merge/output.js | 2 +- 2 files changed, 46 insertions(+), 47 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 31145e9d5f37..016120f94e5f 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -1,6 +1,6 @@ use swc_common::{util::take::Take, EqIgnoreSpan, Spanned, DUMMY_SP}; use swc_ecma_ast::*; -use swc_ecma_utils::{prepend, ExprFactory, StmtExt}; +use swc_ecma_utils::{prepend, ExprExt, ExprFactory, StmtExt}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use super::Optimizer; @@ -162,18 +162,20 @@ where /// This method will /// /// - drop the empty cases at the end. + /// - drop break at last case + /// - merge branch with default at the end pub(super) fn optimize_switch_cases(&mut self, cases: &mut Vec) { if !self.options.switches || !self.options.dead_code { return; } // If default is not last, we can't remove empty cases. - let has_default = cases.iter().any(|case| case.test.is_none()); + let default_idx = cases.iter().position(|case| case.test.is_none()); let all_ends_with_break = cases .iter() .all(|case| case.cons.is_empty() || case.cons.last().unwrap().is_break_stmt()); let mut preserve_cases = false; - if !all_ends_with_break && has_default { + if !all_ends_with_break && default_idx.is_some() { if let Some(last) = cases.last() { if last.test.is_some() { preserve_cases = true; @@ -218,66 +220,63 @@ where } } - /// If a case ends with break but content is same with the consecutive case - /// except the break statement, we merge them. + /// If a case ends with break but content is same with the another case + /// without break evaluation order, except the break statement, we merge + /// them. fn merge_cases_with_same_cons(&mut self, cases: &mut Vec) { - let mut stop_pos_opt = cases + let boundary: Vec = cases .iter() - .position(|case| matches!(case.test.as_deref(), Some(Expr::Update(..)))); + .enumerate() + .map(|(idx, case)| { + case.test + .as_deref() + .map(|test| test.may_have_side_effects()) + .unwrap_or(false) + || !(case.cons.is_empty() || case.cons.terminates() || idx == cases.len() - 1) + }) + .collect(); - let mut found = None; - 'l: for (li, l) in cases.iter().enumerate().rev() { - if l.cons.is_empty() { - continue; - } + let mut i = 0; + let len = cases.len(); - if let Some(stop_pos) = stop_pos_opt { - if li == stop_pos { - // Look for next stop position - stop_pos_opt = cases - .iter() - .skip(li) - .position(|case| matches!(case.test.as_deref(), Some(Expr::Update(..)))) - .map(|v| v + li); - continue; - } - } - - if let Some(l_last) = l.cons.last() { - match l_last { - Stmt::Break(BreakStmt { label: None, .. }) => {} - _ => continue, - } + while i < len { + if cases[i].cons.is_empty() { + i += 1; + continue; } - for r in cases.iter().skip(li + 1) { - if r.cons.is_empty() { - continue; + for j in (i + 1)..len { + if boundary[j] { + // TODO: default + break; } - let mut r_cons_slice = r.cons.len(); - - if let Some(Stmt::Break(BreakStmt { label: None, .. })) = r.cons.last() { - r_cons_slice -= 1; - } + let found = if j != len - 1 { + cases[i].cons.eq_ignore_span(&cases[j].cons) + } else { + if let Some(Stmt::Break(BreakStmt { label: None, .. })) = cases[i].cons.last() { + cases[i].cons[..(cases[i].cons.len() - 1)].eq_ignore_span(&cases[j].cons) + } else { + cases[i].cons.eq_ignore_span(&cases[j].cons) + } + }; - if l.cons[..l.cons.len() - 1].eq_ignore_span(&r.cons[..r_cons_slice]) { - found = Some(li); - break 'l; + if found { + self.changed = true; + report_change!("switches: Merging cases with same cons"); + cases[j].cons = cases[i].cons.take(); + cases[(i + 1)..=j].rotate_right(1); + i += 1; } } - } - if let Some(idx) = found { - self.changed = true; - report_change!("switches: Merging cases with same cons"); - cases[idx].cons.clear(); + i += 1; } } /// Try turn switch into if and remove empty switch pub(super) fn optimize_switches(&mut self, s: &mut Stmt) { - if !self.options.switches { + if !self.options.switches || !self.options.dead_code { return; } diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js index 3d3bede5bd42..c03dbefeb420 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js @@ -1,4 +1,4 @@ -switch (a) { +switch(a){ case 1: default: console.log(1); From db005890f459da8814f1f2b5250d93a81fef430b Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 14:20:14 +0800 Subject: [PATCH 14/27] update tests --- .../throwInEnclosingStatements_es2015.2.minified.js | 4 +--- .../throwInEnclosingStatements_es5.2.minified.js | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/swc/tests/tsc-references/throwInEnclosingStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/throwInEnclosingStatements_es2015.2.minified.js index c0f66859d4e4..7c0b37df7d9b 100644 --- a/crates/swc/tests/tsc-references/throwInEnclosingStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/throwInEnclosingStatements_es2015.2.minified.js @@ -1,3 +1 @@ -var y; -if ('a' === y) throw y; -throw y; +throw void 0; diff --git a/crates/swc/tests/tsc-references/throwInEnclosingStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/throwInEnclosingStatements_es5.2.minified.js index 793d5e42d221..74ea1fc27bd1 100644 --- a/crates/swc/tests/tsc-references/throwInEnclosingStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/throwInEnclosingStatements_es5.2.minified.js @@ -1,4 +1,3 @@ var y; import * as swcHelpers from "@swc/helpers"; -if ("a" === y) throw y; throw y; From b8bea177138385fe3bf040b37338423d734b7a67 Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 15:15:36 +0800 Subject: [PATCH 15/27] fix --- .../swc_ecma_minifier/src/compress/optimize/switches.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 016120f94e5f..0d152cb03d4a 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -230,7 +230,7 @@ where .map(|(idx, case)| { case.test .as_deref() - .map(|test| test.may_have_side_effects()) + .map(|test| is_primitive(test).is_none()) .unwrap_or(false) || !(case.cons.is_empty() || case.cons.terminates() || idx == cases.len() - 1) }) @@ -239,6 +239,7 @@ where let mut i = 0; let len = cases.len(); + // may some smarter person find a better solution while i < len { if cases[i].cons.is_empty() { i += 1; @@ -264,8 +265,12 @@ where if found { self.changed = true; report_change!("switches: Merging cases with same cons"); + let mut len = 1; + while len < j && cases[j - len].cons.is_empty() { + len += 1; + } cases[j].cons = cases[i].cons.take(); - cases[(i + 1)..=j].rotate_right(1); + cases[(i + 1)..=j].rotate_right(len); i += 1; } } From 4402ad644c9759bb2d0f144a39de9258b4b734c3 Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 17:19:36 +0800 Subject: [PATCH 16/27] empty branch and last break --- .../src/compress/optimize/switches.rs | 63 +++++++------------ .../tests/fixture/issues/2257/full/output.js | 41 +++++------- .../tests/projects/output/react-dom-17.0.2.js | 54 ++++++---------- .../compress/switch/issue_1083_5/output.js | 2 + .../compress/switch/issue_1083_6/output.js | 2 +- .../compress/switch/issue_1679/output.js | 2 +- .../compress/switch/issue_1680_2/output.js | 1 - .../compress/switch/issue_1690_2/output.js | 3 +- .../compress/switch/issue_1698/output.js | 3 +- 9 files changed, 66 insertions(+), 105 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 0d152cb03d4a..604df28aa848 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -165,58 +165,40 @@ where /// - drop break at last case /// - merge branch with default at the end pub(super) fn optimize_switch_cases(&mut self, cases: &mut Vec) { - if !self.options.switches || !self.options.dead_code { + if !self.options.switches || !self.options.dead_code || cases.is_empty() { return; } - // If default is not last, we can't remove empty cases. - let default_idx = cases.iter().position(|case| case.test.is_none()); - let all_ends_with_break = cases - .iter() - .all(|case| case.cons.is_empty() || case.cons.last().unwrap().is_break_stmt()); - let mut preserve_cases = false; - if !all_ends_with_break && default_idx.is_some() { - if let Some(last) = cases.last() { - if last.test.is_some() { - preserve_cases = true; - } - } - } - self.merge_cases_with_same_cons(cases); - let last_non_empty = cases.iter().rposition(|case| { - // We should preserve test cases if the test is not a literal. - match case.test.as_deref() { - Some(Expr::Lit(..)) | None => {} - _ => return true, - } + // last case with no empty body + let mut last = cases.len(); - if case.cons.is_empty() { - return false; - } + for (idx, case) in cases.iter_mut().enumerate().rev() { + self.changed |= remove_last_break(&mut case.cons); - if case.cons.len() == 1 { - if let Stmt::Break(BreakStmt { label: None, .. }) = case.cons[0] { - return false; - } + if !case.cons.is_empty() { + last = idx + 1; + break; } + } - true + let has_side_effect = cases.iter().skip(last).rposition(|case| { + case.test + .as_deref() + .map(|test| test.may_have_side_effects()) + .unwrap_or(false) }); - if !preserve_cases { - if let Some(last_non_empty) = last_non_empty { - if last_non_empty + 1 != cases.len() { - report_change!("switches: Removing empty cases at the end"); - self.changed = true; - cases.drain(last_non_empty + 1..); - } - } + if let Some(has_side_effect) = has_side_effect { + last += has_side_effect + 1 } - if let Some(last) = cases.last_mut() { - self.changed |= remove_last_break(&mut last.cons); + // if default is before empty cases, we must ensure empty case is preserved + if last < cases.len() && !cases.iter().take(last).any(|case| case.test.is_none()) { + self.changed = true; + report_change!("switches: Removing empty cases at the end"); + cases.drain(last..); } } @@ -247,6 +229,9 @@ where } for j in (i + 1)..len { + if cases[j].cons.is_empty() { + continue; + } if boundary[j] { // TODO: default break; 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 0bb0aa1909cb..fd5905a552f6 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 @@ -12519,6 +12519,7 @@ if (ie) return "compositionend" === a || !ae && ge(a, b) ? (a = nd(), md = ld = kd = null, ie = !1, a) : null; switch(a){ case "paste": + default: return null; case "keypress": if (!(b.ctrlKey || b.altKey || b.metaKey) || b.ctrlKey && b.altKey) { @@ -12528,8 +12529,6 @@ return null; case "compositionend": return de && "ko" !== b.locale ? null : b.data; - default: - return null; } }(a12, c5)) && 0 < (d = oe(d, "onBeforeInput")).length && (e = new Ld("onBeforeInput", "beforeinput", null, c5, e), g.push({ event: e, @@ -13240,7 +13239,6 @@ case 6: return null !== (b = "" === a.pendingProps || 3 !== b.nodeType ? null : b) && (a.stateNode = b, !0); case 13: - return !1; default: return !1; } @@ -14004,6 +14002,7 @@ case 14: return null; case 1: + case 17: return Ff(b.type) && Gf(), null; case 3: return fh(), H(N), H(M), uh(), (d = b.stateNode).pendingContext && (d.context = d.pendingContext, d.pendingContext = null), (null === a || null === a.child) && (rh(b) ? b.flags |= 4 : d.hydrate || (b.flags |= 256)), Ci(b), null; @@ -14163,8 +14162,6 @@ return fh(), Ci(b), null === a && cf(b.stateNode.containerInfo), null; case 10: return rg(b), null; - case 17: - return Ff(b.type) && Gf(), null; case 19: if (H(P), null === (d = b.memoizedState)) return null; if (f = 0 != (64 & b.flags), null === (g = d.rendering)) { @@ -14358,6 +14355,10 @@ case 11: case 15: case 22: + case 5: + case 6: + case 4: + case 17: return; case 1: if (256 & b.flags && null !== a) { @@ -14368,11 +14369,6 @@ case 3: 256 & b.flags && qf(b.stateNode.containerInfo); return; - case 5: - case 6: - case 4: - case 17: - return; } throw Error(y(163)); } @@ -14417,14 +14413,8 @@ a = c.stateNode, null === b && 4 & c.flags && mf(c.type, c.memoizedProps) && a.focus(); return; case 6: - return; case 4: - return; case 12: - return; - case 13: - null === c.memoizedState && null !== (c = c.alternate) && null !== (c = c.memoizedState) && null !== (c = c.dehydrated) && Cc(c); - return; case 19: case 17: case 20: @@ -14432,6 +14422,9 @@ case 23: case 24: return; + case 13: + null === c.memoizedState && null !== (c = c.alternate) && null !== (c = c.memoizedState) && null !== (c = c.dehydrated) && Cc(c); + return; } throw Error(y(163)); } @@ -14565,8 +14558,6 @@ f = !1; break a; case 3: - e = e.containerInfo, f = !0; - break a; case 4: e = e.containerInfo, f = !0; break a; @@ -14618,6 +14609,8 @@ } return; case 1: + case 12: + case 17: return; case 5: if (null != (c = b.stateNode)) { @@ -14650,16 +14643,12 @@ case 3: (c = b.stateNode).hydrate && (c.hydrate = !1, Cc(c.containerInfo)); return; - case 12: - return; case 13: null !== b.memoizedState && (jj = O(), aj(b.child, !0)), kj(b); return; case 19: kj(b); return; - case 17: - return; case 23: case 24: aj(b, null !== b.memoizedState); @@ -14800,6 +14789,9 @@ case 1: throw Error(y(345)); case 2: + case 5: + Uj(a); + break; case 3: if (Ii(a, c), (62914560 & c) === c && 10 < (d = jj + 500 - O())) { if (0 !== Uc(a, 0)) break; @@ -14824,9 +14816,6 @@ } Uj(a); break; - case 5: - Uj(a); - break; default: throw Error(y(329)); } @@ -15586,7 +15575,6 @@ case 7: return fi(a23, b, b.pendingProps, c), b.child; case 8: - return fi(a23, b, b.pendingProps.children, c), b.child; case 12: return fi(a23, b, b.pendingProps.children, c), b.child; case 10: @@ -15640,7 +15628,6 @@ case 19: return Ai(a23, b, c); case 23: - return mi(a23, b, c); case 24: return mi(a23, b, c); } diff --git a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js index d6520790a5f5..82be1216c301 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js +++ b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js @@ -2380,6 +2380,9 @@ function findUpdateLane(lanePriority, wipLanes) { switch(lanePriority){ case 0: + case 6: + case 5: + break; case 15: return SyncLane; case 14: @@ -2395,9 +2398,6 @@ case 8: var _lane3 = pickArbitraryLane(3584 & ~wipLanes); return _lane3 === NoLane && (_lane3 = pickArbitraryLane(4186112 & ~wipLanes)) === NoLane && (_lane3 = pickArbitraryLane(3584)), _lane3; - case 6: - case 5: - break; case 2: var lane = pickArbitraryLane(805306368 & ~wipLanes); return lane === NoLane && (lane = pickArbitraryLane(805306368)), lane; @@ -3509,6 +3509,7 @@ } switch(domEventName){ case 'paste': + default: return null; case 'keypress': if (!(nativeEvent9 = nativeEvent).ctrlKey && !nativeEvent9.altKey && !nativeEvent9.metaKey || nativeEvent9.ctrlKey && nativeEvent9.altKey) { @@ -3518,8 +3519,6 @@ return null; case 'compositionend': return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data; - default: - return null; } }(domEventName10, nativeEvent8))) return null; var chars1, listeners = accumulateTwoPhaseListeners(targetInst, 'onBeforeInput'); @@ -5174,7 +5173,6 @@ if (null !== textInstance) return fiber.stateNode = textInstance, !0; return !1; case 13: - return !1; default: return !1; } @@ -6947,6 +6945,7 @@ case 14: return null; case 1: + case 17: return isContextProvider(workInProgress.type) && popContext(workInProgress), null; case 3: popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), resetWorkInProgressVersions(); @@ -7197,8 +7196,6 @@ return popHostContainer(workInProgress), updateHostContainer(workInProgress), null === current && listenToAllSupportedEvents(workInProgress.stateNode.containerInfo), null; case 10: return popProvider(workInProgress), null; - case 17: - return isContextProvider(workInProgress.type) && popContext(workInProgress), null; case 19: popSuspenseContext(workInProgress); var renderState = workInProgress.memoizedState; @@ -7536,6 +7533,10 @@ case 11: case 15: case 22: + case 5: + case 6: + case 4: + case 17: return; case 1: if (256 & finishedWork.flags && null !== current) { @@ -7548,11 +7549,6 @@ case 3: 256 & finishedWork.flags && clearContainer(finishedWork.stateNode.containerInfo); return; - case 5: - case 6: - case 4: - case 17: - return; } throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."); } @@ -7619,8 +7615,13 @@ } return; case 6: - return; case 4: + case 19: + case 17: + case 20: + case 21: + case 23: + case 24: return; case 12: var _finishedWork$memoize2 = finishedWork1.memoizedProps, onRender = (_finishedWork$memoize2.onCommit, _finishedWork$memoize2.onRender); @@ -7631,13 +7632,6 @@ case 13: commitSuspenseHydrationCallbacks(finishedRoot, finishedWork1); return; - case 19: - case 17: - case 20: - case 21: - case 23: - case 24: - return; } throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."); } @@ -7710,9 +7704,7 @@ unmountHostComponents(finishedRoot, current); return; case 20: - return; case 18: - return; case 21: return; } @@ -7815,8 +7807,6 @@ currentParent = parentStateNode, currentParentIsContainer = !1; break findParent; case 3: - currentParent = parentStateNode.containerInfo, currentParentIsContainer = !0; - break findParent; case 4: currentParent = parentStateNode.containerInfo, currentParentIsContainer = !0; break findParent; @@ -7870,6 +7860,8 @@ }(3, finishedWork2); return; case 1: + case 12: + case 17: return; case 5: var instance = finishedWork2.stateNode; @@ -7905,16 +7897,12 @@ var _root = finishedWork2.stateNode; _root.hydrate && (_root.hydrate = !1, retryIfBlockedOn(_root.containerInfo)); return; - case 12: - return; case 13: commitSuspenseComponent(finishedWork2), attachSuspenseRetryListeners(finishedWork2); return; case 19: attachSuspenseRetryListeners(finishedWork2); return; - case 17: - return; case 20: case 21: break; @@ -8087,6 +8075,9 @@ case 1: throw Error("Root did not complete. This is a bug in React."); case 2: + case 5: + commitRoot(root4); + break; case 3: if (markRootSuspended$1(root4, lanes5), (62914560 & (lanes3 = lanes5)) === lanes3 && !(actingUpdatesScopeDepth > 0)) { var msUntilTimeout = globalMostRecentFallbackTime + 500 - now(); @@ -8120,9 +8111,6 @@ } commitRoot(root4); break; - case 5: - commitRoot(root4); - break; default: throw Error("Unknown root exit status."); } @@ -8881,8 +8869,6 @@ hostInstances.add(node.stateNode); return; case 4: - hostInstances.add(node.stateNode.containerInfo); - return; case 3: hostInstances.add(node.stateNode.containerInfo); return; diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js index 5ee4dcd329fe..7e280683d97b 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_5/output.js @@ -1,6 +1,8 @@ function test(definitely_true, maybe_true) { switch(true){ default: + console.log("definitely"); + break; case maybe_true: console.log("maybe"); break; diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.js index 8909a538a1ad..a1327ae6886d 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1083_6/output.js @@ -1,5 +1,5 @@ function test(definitely_true, maybe_true) { - switch (true) { + switch(true){ case definitely_true: console.log("definitely"); break; diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1679/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1679/output.js index 00e78d24bfcb..eefc6f02fd46 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1679/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1679/output.js @@ -3,9 +3,9 @@ function f() { switch(--b){ default: case false: + break; case b--: a--; - break; case a++: } } diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1680_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1680_2/output.js index 96c4cd443b11..3f19a534b3ef 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1680_2/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1680_2/output.js @@ -5,7 +5,6 @@ switch (b) { break; case b: var c; - break; case a: case a--: } diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1690_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1690_2/output.js index 5669eec47340..5507d9829d7d 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1690_2/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1690_2/output.js @@ -1 +1,2 @@ -console.log("PASS"); +switch(console.log("PASS")){ +} diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1698/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1698/output.js index 6d0620725948..890ec1aa3d8a 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1698/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_1698/output.js @@ -1,5 +1,6 @@ var a = 1; !function() { - a++; + switch(a++){ + } }(); console.log(a); From 12a322641d7a0b08447e791ecd6bc537445d2bea Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 17:53:39 +0800 Subject: [PATCH 17/27] fix and non-actionable --- .../src/compress/optimize/mod.rs | 79 ++++++++++++++++++- .../compress/switch/drop_case_2/output.js | 7 +- .../switch/gut_entire_switch/output.js | 1 - .../compress/switch/keep_case/output.js | 7 +- 4 files changed, 79 insertions(+), 15 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index eeb3822044d9..916ef7636466 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -12,8 +12,8 @@ use swc_common::{ }; use swc_ecma_ast::*; use swc_ecma_utils::{ - ident::IdentLike, prepend_stmts, undefined, ExprExt, ExprFactory, Id, IsEmpty, ModuleItemLike, - StmtLike, Type, Value, + extract_var_ids, ident::IdentLike, prepend_stmts, undefined, ExprExt, ExprFactory, Id, IsEmpty, + ModuleItemLike, StmtLike, Type, Value, }; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith}; use tracing::{debug, span, Level}; @@ -2474,6 +2474,81 @@ where return; } + if self.options.dead_code { + // copy from [Remover] + // TODO: make it better + let orig_len = stmts.len(); + + let mut new_stmts = Vec::with_capacity(stmts.len()); + + let mut iter = stmts.take().into_iter(); + while let Some(mut stmt) = iter.next() { + stmt.visit_mut_with(self); + + let stmt = match stmt { + // Remove empty statements. + Stmt::Empty(..) => continue, + + // Control flow + Stmt::Throw(..) + | Stmt::Return { .. } + | Stmt::Continue { .. } + | Stmt::Break { .. } => { + // Hoist function and `var` declarations above return. + let mut decls = vec![]; + let mut hoisted_fns = vec![]; + for t in iter { + match t.try_into_stmt() { + Ok(Stmt::Decl(Decl::Fn(f))) => { + hoisted_fns.push(Stmt::Decl(Decl::Fn(f))); + } + Ok(t) => { + let ids = + extract_var_ids(&t).into_iter().map(|i| VarDeclarator { + span: i.span, + name: i.into(), + init: None, + definite: false, + }); + decls.extend(ids); + } + Err(item) => new_stmts.push(item), + } + } + + if !decls.is_empty() { + new_stmts.push(Stmt::Decl(Decl::Var(VarDecl { + span: DUMMY_SP, + kind: VarDeclKind::Var, + decls, + declare: false, + }))); + } + + new_stmts.push(stmt); + new_stmts.extend(hoisted_fns); + + *stmts = new_stmts; + if stmts.len() != orig_len { + self.changed = true; + + if cfg!(feature = "debug") { + debug!("Dropping statements after a control keyword"); + } + } + + return; + } + + _ => stmt, + }; + + new_stmts.push(stmt); + } + + *stmts = new_stmts; + } + let ctx = Ctx { ..self.ctx }; self.with_ctx(ctx).inject_else(stmts); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.js index 67bc9b72b4a8..5b45fc5df4d5 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/drop_case_2/output.js @@ -1,6 +1 @@ -switch (foo) { - case "bar": - bar(); - case "moo": - case moo: -} +if ("bar" === foo) bar(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js index 5cf989a75381..5669eec47340 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js @@ -1,2 +1 @@ -id(123); console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/keep_case/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/keep_case/output.js index f2b9091386e1..a3a043e13da0 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/keep_case/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/keep_case/output.js @@ -1,6 +1 @@ -switch (foo) { - case "bar": - baz(); - break; - case moo: -} +if ("bar" === foo) baz(); From 547cbd8acc2799ba17c071908176d701ac845bad Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 18:02:07 +0800 Subject: [PATCH 18/27] move --- .../fixture/simple/switch/const/call/analysis-snapshot.rust-debug | 0 .../{compress => }/fixture/simple/switch/const/call/input.js | 0 .../{compress => }/fixture/simple/switch/const/call/output.js | 0 .../simple/switch/const/default/analysis-snapshot.rust-debug | 0 .../fixture/simple/switch/const/default/config.json | 0 .../{compress => }/fixture/simple/switch/const/default/input.js | 0 .../{compress => }/fixture/simple/switch/const/default/output.js | 0 .../simple/switch/const/order/analysis-snapshot.rust-debug | 0 .../{compress => }/fixture/simple/switch/const/order/input.js | 0 .../{compress => }/fixture/simple/switch/const/order/output.js | 0 .../fixture/simple/switch/merge/analysis-snapshot.rust-debug | 0 .../tests/{compress => }/fixture/simple/switch/merge/input.js | 0 .../tests/{compress => }/fixture/simple/switch/merge/output.js | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/call/analysis-snapshot.rust-debug (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/call/input.js (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/call/output.js (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/default/analysis-snapshot.rust-debug (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/default/config.json (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/default/input.js (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/default/output.js (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/order/analysis-snapshot.rust-debug (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/order/input.js (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/const/order/output.js (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/merge/analysis-snapshot.rust-debug (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/merge/input.js (100%) rename crates/swc_ecma_minifier/tests/{compress => }/fixture/simple/switch/merge/output.js (100%) diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/call/analysis-snapshot.rust-debug similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/analysis-snapshot.rust-debug rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/call/analysis-snapshot.rust-debug diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/input.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/call/input.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/input.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/call/input.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/output.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/call/output.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/call/output.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/call/output.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/default/analysis-snapshot.rust-debug similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/analysis-snapshot.rust-debug rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/default/analysis-snapshot.rust-debug diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/config.json b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/default/config.json similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/config.json rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/default/config.json diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/input.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/default/input.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/input.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/default/input.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/output.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/default/output.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/default/output.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/default/output.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/order/analysis-snapshot.rust-debug similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/analysis-snapshot.rust-debug rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/order/analysis-snapshot.rust-debug diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/input.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/order/input.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/input.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/order/input.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/const/order/output.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/const/order/output.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/const/order/output.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/analysis-snapshot.rust-debug similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/analysis-snapshot.rust-debug rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/analysis-snapshot.rust-debug diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/input.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/input.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/input.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/input.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/output.js similarity index 100% rename from crates/swc_ecma_minifier/tests/compress/fixture/simple/switch/merge/output.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/output.js From a0908931746f34e0af97c5cc5b5593071dfe1c1d Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 18:33:11 +0800 Subject: [PATCH 19/27] fix merge equal --- .../src/compress/optimize/mod.rs | 52 +++++++++---------- .../src/compress/optimize/switches.rs | 14 +++-- .../tests/fixture/issues/2257/full/output.js | 6 --- .../8a28b14e.d8fbda268ed281a1/output.js | 14 +++-- .../2c796e83-0724e2af5f19128a/output.js | 2 +- .../terser/compress/switch/if_else7/output.js | 3 +- 6 files changed, 42 insertions(+), 49 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 916ef7636466..bc886303d31b 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -2474,6 +2474,30 @@ where return; } + let ctx = Ctx { ..self.ctx }; + + self.with_ctx(ctx).inject_else(stmts); + + self.with_ctx(ctx).handle_stmt_likes(stmts); + + self.with_ctx(ctx).merge_var_decls(stmts); + + drop_invalid_stmts(stmts); + + if stmts.len() == 1 { + if let Stmt::Expr(ExprStmt { expr, .. }) = &stmts[0] { + if let Expr::Lit(Lit::Str(s)) = &**expr { + if s.value == *"use strict" { + stmts.clear(); + } + } + } + } + + if cfg!(debug_assertions) { + stmts.visit_with(&mut AssertValid); + } + if self.options.dead_code { // copy from [Remover] // TODO: make it better @@ -2482,9 +2506,7 @@ where let mut new_stmts = Vec::with_capacity(stmts.len()); let mut iter = stmts.take().into_iter(); - while let Some(mut stmt) = iter.next() { - stmt.visit_mut_with(self); - + while let Some(stmt) = iter.next() { let stmt = match stmt { // Remove empty statements. Stmt::Empty(..) => continue, @@ -2548,30 +2570,6 @@ where *stmts = new_stmts; } - - let ctx = Ctx { ..self.ctx }; - - self.with_ctx(ctx).inject_else(stmts); - - self.with_ctx(ctx).handle_stmt_likes(stmts); - - self.with_ctx(ctx).merge_var_decls(stmts); - - drop_invalid_stmts(stmts); - - if stmts.len() == 1 { - if let Stmt::Expr(ExprStmt { expr, .. }) = &stmts[0] { - if let Expr::Lit(Lit::Str(s)) = &**expr { - if s.value == *"use strict" { - stmts.clear(); - } - } - } - } - - if cfg!(debug_assertions) { - stmts.visit_with(&mut AssertValid); - } } fn visit_mut_str(&mut self, s: &mut Str) { diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 604df28aa848..358512c2c621 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -228,15 +228,16 @@ where continue; } + let mut cannot_cross = false; + for j in (i + 1)..len { + // TODO: default + cannot_cross |= boundary[j]; if cases[j].cons.is_empty() { continue; } - if boundary[j] { - // TODO: default - break; - } + // first case with a body and don't cross non-primitive branch let found = if j != len - 1 { cases[i].cons.eq_ignore_span(&cases[j].cons) } else { @@ -256,7 +257,10 @@ where } cases[j].cons = cases[i].cons.take(); cases[(i + 1)..=j].rotate_right(len); - i += 1; + i += len; + } + if cannot_cross { + break; } } 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 fd5905a552f6..2d425cab2844 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 @@ -3477,13 +3477,7 @@ if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND]; switch(KIND){ case KEYS: - return function() { - return new IteratorConstructor(this, KIND); - }; case VALUES: - return function() { - return new IteratorConstructor(this, KIND); - }; case ENTRIES: return function() { return new IteratorConstructor(this, KIND); 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 37e57b5229c3..4423ed8b24e6 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 @@ -2445,6 +2445,11 @@ switch(cType){ case 0: case 1: + case 13: + case 14: + case 16: + case 17: + case 15: lastArabic = !1; case 4: case 3: @@ -2454,6 +2459,7 @@ case 7: return lastArabic = !0, hasUBAT_AL = !0, 1; case 8: + case 18: return 4; case 9: if (ix < 1 || ix + 1 >= types.length || 2 != (wType = classes[ix - 1]) && 3 != wType || 2 != (nType = types[ix + 1]) && 3 != nType) return 4; @@ -2479,14 +2485,6 @@ return lastArabic = !1, hasUBAT_B = !0, dir; case 6: return hasUBAT_S = !0, 4; - case 13: - case 14: - case 16: - case 17: - case 15: - lastArabic = !1; - case 18: - return 4; } } function _getCharacterType(ch) { 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 49288085f593..1d5a17c86f1a 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js @@ -1,4 +1,4 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(b,c,a){var d=a(3454);!function(c,a){b.exports=a()}(this,function(){"use strict";var c,e,b;function a(g,a){if(c){if(e){var f="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+c+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",d={};c(d),b=a(d),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(b.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else e=a}else c=a}return a(["exports"],function(a){"use strict";var bq="2.7.0",eG=H;function H(a,c,d,b){this.cx=3*a,this.bx=3*(d-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*c,this.by=3*(b-c)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=b,this.p2x=d,this.p2y=b}H.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},H.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},H.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},H.prototype.solveCurveX=function(c,e){var b,d,a,f,g;for(void 0===e&&(e=1e-6),a=c,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(a)-c)Math.abs(h))break;a-=f/h}if((a=c)<(b=0))return b;if(a>(d=1))return d;for(;bf?b=a:d=a,a=.5*(d-b)+b}return a},H.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var aF=aG;function aG(a,b){this.x=a,this.y=b}aG.prototype={clone:function(){return new aG(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(b,a){var c=Math.cos(b),d=Math.sin(b),e=a.y+d*(this.x-a.x)+c*(this.y-a.y);return this.x=a.x+c*(this.x-a.x)-d*(this.y-a.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},aG.convert=function(a){return a instanceof aG?a:Array.isArray(a)?new aG(a[0],a[1]):a};var s="undefined"!=typeof self?self:{},I="undefined"!=typeof Float32Array?Float32Array:Array;function aH(){var a=new I(9);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function aI(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function aJ(a,b,c){var h=b[0],i=b[1],j=b[2],k=b[3],l=b[4],m=b[5],n=b[6],o=b[7],p=b[8],q=b[9],r=b[10],s=b[11],t=b[12],u=b[13],v=b[14],w=b[15],d=c[0],e=c[1],f=c[2],g=c[3];return a[0]=d*h+e*l+f*p+g*t,a[1]=d*i+e*m+f*q+g*u,a[2]=d*j+e*n+f*r+g*v,a[3]=d*k+e*o+f*s+g*w,a[4]=(d=c[4])*h+(e=c[5])*l+(f=c[6])*p+(g=c[7])*t,a[5]=d*i+e*m+f*q+g*u,a[6]=d*j+e*n+f*r+g*v,a[7]=d*k+e*o+f*s+g*w,a[8]=(d=c[8])*h+(e=c[9])*l+(f=c[10])*p+(g=c[11])*t,a[9]=d*i+e*m+f*q+g*u,a[10]=d*j+e*n+f*r+g*v,a[11]=d*k+e*o+f*s+g*w,a[12]=(d=c[12])*h+(e=c[13])*l+(f=c[14])*p+(g=c[15])*t,a[13]=d*i+e*m+f*q+g*u,a[14]=d*j+e*n+f*r+g*v,a[15]=d*k+e*o+f*s+g*w,a}function br(b,a,f){var r,g,h,i,j,k,l,m,n,o,p,q,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[1],h=a[2],i=a[3],j=a[4],k=a[5],l=a[6],m=a[7],n=a[8],o=a[9],p=a[10],q=a[11],b[0]=r=a[0],b[1]=g,b[2]=h,b[3]=i,b[4]=j,b[5]=k,b[6]=l,b[7]=m,b[8]=n,b[9]=o,b[10]=p,b[11]=q,b[12]=r*c+j*d+n*e+a[12],b[13]=g*c+k*d+o*e+a[13],b[14]=h*c+l*d+p*e+a[14],b[15]=i*c+m*d+q*e+a[15]),b}function bs(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function bt(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*d+j*c,a[5]=g*d+k*c,a[6]=h*d+l*c,a[7]=i*d+m*c,a[8]=j*d-f*c,a[9]=k*d-g*c,a[10]=l*d-h*c,a[11]=m*d-i*c,a}function bu(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d-j*c,a[1]=g*d-k*c,a[2]=h*d-l*c,a[3]=i*d-m*c,a[8]=f*c+j*d,a[9]=g*c+k*d,a[10]=h*c+l*d,a[11]=i*c+m*d,a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)});var bv=aJ;function aK(){var a=new I(3);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function eH(b){var a=new I(3);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a}function aL(a){return Math.hypot(a[0],a[1],a[2])}function Q(b,c,d){var a=new I(3);return a[0]=b,a[1]=c,a[2]=d,a}function bw(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function aM(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function aN(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function eI(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function bx(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function by(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function bz(c,a){var d=a[0],e=a[1],f=a[2],b=d*d+e*e+f*f;return b>0&&(b=1/Math.sqrt(b)),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function bA(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function bB(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function bC(b,g,a){var c=g[0],d=g[1],e=g[2],f=a[3]*c+a[7]*d+a[11]*e+a[15];return b[0]=(a[0]*c+a[4]*d+a[8]*e+a[12])/(f=f||1),b[1]=(a[1]*c+a[5]*d+a[9]*e+a[13])/f,b[2]=(a[2]*c+a[6]*d+a[10]*e+a[14])/f,b}function bD(a,h,b){var c=b[0],d=b[1],e=b[2],i=h[0],j=h[1],k=h[2],l=d*k-e*j,f=e*i-c*k,g=c*j-d*i,p=d*g-e*f,n=e*l-c*g,o=c*f-d*l,m=2*b[3];return f*=m,g*=m,n*=2,o*=2,a[0]=i+(l*=m)+(p*=2),a[1]=j+f+n,a[2]=k+g+o,a}var J,bE=aM;function bF(b,c,a){var d=c[0],e=c[1],f=c[2],g=c[3];return b[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*g,b[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*g,b[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*g,b[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*g,b}function aO(){var a=new I(4);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function bG(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function bH(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+i*c,a[1]=g*d+h*c,a[2]=h*d-g*c,a[3]=i*d-f*c,a}function eJ(a,b){return a[0]===b[0]&&a[1]===b[1]}aK(),J=new I(4),I!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0,J[3]=0),aK(),Q(1,0,0),Q(0,1,0),aO(),aO(),aH(),ll=new I(2),I!=Float32Array&&(ll[0]=0,ll[1]=0);const aP=Math.PI/180,eK=180/Math.PI;function bI(a){return a*aP}function bJ(a){return a*eK}const eL=[[0,0],[1,0],[1,1],[0,1]];function bK(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function aQ(a,b,c,d){const e=new eG(a,b,c,d);return function(a){return e.solve(a)}}const bL=aQ(.25,.1,.25,1);function bM(a,b,c){return Math.min(c,Math.max(b,a))}function bN(b,c,a){return(a=bM((a-b)/(c-b),0,1))*a*(3-2*a)}function bO(e,a,c){const b=c-a,d=((e-a)%b+b)%b+a;return d===a?c:d}function bP(a,c,b){if(!a.length)return b(null,[]);let d=a.length;const e=new Array(a.length);let f=null;a.forEach((a,g)=>{c(a,(a,c)=>{a&&(f=a),e[g]=c,0== --d&&b(f,e)})})}function bQ(a){const b=[];for(const c in a)b.push(a[c]);return b}function bR(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}let eM=1;function bS(){return eM++}function eN(){return function b(a){return a?(a^16*Math.random()>>a/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,b)}()}function bT(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function eO(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function bU(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function bV(a,b){return -1!==a.indexOf(b,a.length-b.length)}function eP(a,d,e){const c={};for(const b in a)c[b]=d.call(e||this,a[b],b,a);return c}function bW(a,d,e){const c={};for(const b in a)d.call(e||this,a[b],b,a)&&(c[b]=a[b]);return c}function bX(a){return Array.isArray(a)?a.map(bX):"object"==typeof a&&a?eP(a,bX):a}const eQ={};function bY(a){eQ[a]||("undefined"!=typeof console&&console.warn(a),eQ[a]=!0)}function eR(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function eS(a){let e=0;for(let b,c,d=0,f=a.length,g=f-1;d@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,c,d,e)=>{const b=d||e;return a[c]=!b||b.toLowerCase(),""}),a["max-age"]){const b=parseInt(a["max-age"],10);isNaN(b)?delete a["max-age"]:a["max-age"]=b}return a}let eU,af,eV,eW=null;function eX(b){if(null==eW){const a=b.navigator?b.navigator.userAgent:null;eW=!!b.safari||!(!a||!(/\b(iPad|iPhone|iPod)\b/.test(a)||a.match("Safari")&&!a.match("Chrome")))}return eW}function eY(b){try{const a=s[b];return a.setItem("_mapbox_test_",1),a.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const b$={now:()=>void 0!==eV?eV:s.performance.now(),setNow(a){eV=a},restoreNow(){eV=void 0},frame(a){const b=s.requestAnimationFrame(a);return{cancel:()=>s.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=s.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(eU||(eU=s.document.createElement("a")),eU.href=a,eU.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==af&&(af=s.matchMedia("(prefers-reduced-motion: reduce)")),af.matches)}};let R;const b_={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==R){const aR=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R=null!=d.env.API_URL_REGEX?new RegExp(d.env.API_URL_REGEX):aR}catch(eZ){R=aR}}return R},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},b0={supported:!1,testSupport:function(a){!e_&&ag&&(e0?e1(a):e$=a)}};let e$,ag,e_=!1,e0=!1;function e1(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,ag),a.isContextLost())return;b0.supported=!0}catch(c){}a.deleteTexture(b),e_=!0}s.document&&((ag=s.document.createElement("img")).onload=function(){e$&&e1(e$),e$=null,e0=!0},ag.onerror=function(){e_=!0,e$=null},ag.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const b1="NO_ACCESS_TOKEN";function b2(a){return 0===a.indexOf("mapbox:")}function e2(a){return b_.API_URL_REGEX.test(a)}const e3=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function e4(b){const a=b.match(e3);if(!a)throw new Error("Unable to parse URL object");return{protocol:a[1],authority:a[2],path:a[3]||"/",params:a[4]?a[4].split("&"):[]}}function e5(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function e6(b){if(!b)return null;const a=b.split(".");if(!a||3!==a.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(a[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class e7{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(c){const a=e6(b_.ACCESS_TOKEN);let b="";return b=a&&a.u?s.btoa(encodeURIComponent(a.u).replace(/%([0-9A-F]{2})/g,(b,a)=>String.fromCharCode(Number("0x"+a)))):b_.ACCESS_TOKEN||"",c?`mapbox.eventData.${c}:${b}`:`mapbox.eventData:${b}`}fetchEventData(){const c=eY("localStorage"),d=this.getStorageKey(),e=this.getStorageKey("uuid");if(c)try{const a=s.localStorage.getItem(d);a&&(this.eventData=JSON.parse(a));const b=s.localStorage.getItem(e);b&&(this.anonId=b)}catch(f){bY("Unable to read from LocalStorage")}}saveEventData(){const a=eY("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{s.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){bY("Unable to write to LocalStorage")}}processRequests(a){}postEvent(d,a,h,e){if(!b_.EVENTS_URL)return;const b=e4(b_.EVENTS_URL);b.params.push(`access_token=${e||b_.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(d).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:bq,skuId:"01",userId:this.anonId},f=a?bR(c,a):c,g={url:e5(b),headers:{"Content-Type":"text/plain"},body:JSON.stringify([f])};this.pendingRequest=fj(g,a=>{this.pendingRequest=null,h(a),this.saveEventData(),this.processRequests(e)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const aS=new class extends e7{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){b_.EVENTS_URL&&b_.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>b2(a)||e2(a))&&this.queueRequest(Date.now(),b)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const c=e6(b_.ACCESS_TOKEN),f=c?c.u:b_.ACCESS_TOKEN;let a=f!==this.eventData.tokenU;eO(this.anonId)||(this.anonId=eN(),a=!0);const b=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(b),d=(b-this.eventData.lastSuccess)/864e5;a=a||d>=1||d< -1||g.getDate()!==h.getDate()}else a=!0;if(!a)return this.processRequests();this.postEvent(b,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=b,this.eventData.tokenU=f)},e)}},b3=aS.postTurnstileEvent.bind(aS),aT=new class extends e7{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.EVENTS_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||(this.anonId||this.fetchEventData(),eO(this.anonId)||(this.anonId=eN()),this.postEvent(c,{skuToken:this.skuToken},b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b))}},b4=aT.postMapLoadEvent.bind(aT),aU=new class extends e7{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,b,f,c){if(!b_.API_URL||!b_.SESSION_PATH)return;const a=e4(b_.API_URL+b_.SESSION_PATH);a.params.push(`sku=${b||""}`),a.params.push(`access_token=${c||b_.ACCESS_TOKEN||""}`);const d={url:e5(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=fk(d,a=>{this.pendingRequest=null,f(a),this.saveEventData(),this.processRequests(c)})}getSessionAPI(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.SESSION_PATH&&b_.API_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||this.getSession(c,this.skuToken,b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b)}},b5=aU.getSessionAPI.bind(aU),e8=new Set,e9="mapbox-tiles";let fa,fb,fc=500,fd=50;function fe(){s.caches&&!fa&&(fa=s.caches.open(e9))}function ff(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let fg=1/0;const aV={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(aV);class fh extends Error{constructor(a,b,c){401===b&&e2(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const b6=bZ()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,b7=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(b6())&&!/^\w+:/.test(c))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return function(a,g){var c;const e=new s.AbortController,b=new s.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:b6(),signal:e.signal});let h=!1,i=!1;const f=(c=b.url).indexOf("sku=")>0&&e2(c);"json"===a.type&&b.headers.set("Accept","application/json");const d=(c,d,e)=>{if(i)return;if(c&&"SecurityError"!==c.message&&bY(c),d&&e)return j(d);const h=Date.now();s.fetch(b).then(b=>{if(b.ok){const c=f?b.clone():null;return j(b,c,h)}return g(new fh(b.statusText,b.status,a.url))}).catch(a=>{20!==a.code&&g(new Error(a.message))})},j=(c,d,e)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{i||(d&&e&&function(e,a,c){if(fe(),!fa)return;const d={status:a.status,statusText:a.statusText,headers:new s.Headers};a.headers.forEach((a,b)=>d.headers.set(b,a));const b=eT(a.headers.get("Cache-Control")||"");b["no-store"]||(b["max-age"]&&d.headers.set("Expires",new Date(c+1e3*b["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||function(a,b){if(void 0===fb)try{new Response(new ReadableStream),fb=!0}catch(c){fb=!1}fb?b(a.body):a.blob().then(b)}(a,a=>{const b=new s.Response(a,d);fe(),fa&&fa.then(a=>a.put(ff(e.url),b)).catch(a=>bY(a.message))}))}(b,d,e),h=!0,g(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{i||g(new Error(a.message))})};return f?function(b,a){if(fe(),!fa)return a(null);const c=ff(b.url);fa.then(b=>{b.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=eT(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);b.delete(c),e&&b.put(c,d.clone()),a(null,d,e)}).catch(a)}).catch(a)}(b,d):d(null,null),{cancel(){i=!0,h||e.abort()}}}(a,b);if(bZ()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return function(b,d){const a=new s.XMLHttpRequest;for(const c in a.open(b.method||"GET",b.url,!0),"arrayBuffer"===b.type&&(a.responseType="arraybuffer"),b.headers)a.setRequestHeader(c,b.headers[c]);return"json"===b.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===b.credentials,a.onerror=()=>{d(new Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let c=a.response;if("json"===b.type)try{c=JSON.parse(a.response)}catch(e){return d(e)}d(null,c,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else d(new fh(a.statusText,a.status,b.url))},a.send(b.body),{cancel:()=>a.abort()}}(a,b)},fi=function(a,b){return b7(bR(a,{type:"arrayBuffer"}),b)},fj=function(a,b){return b7(bR(a,{method:"POST"}),b)},fk=function(a,b){return b7(bR(a,{method:"GET"}),b)};function fl(b){const a=s.document.createElement("a");return a.href=b,a.protocol===s.document.location.protocol&&a.host===s.document.location.host}const fm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let b8,b9;b8=[],b9=0;const ca=function(a,c){if(b0.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),b9>=b_.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:a,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return b8.push(b),b}b9++;let d=!1;const e=()=>{if(!d)for(d=!0,b9--;b8.length&&b9{e(),b?c(b):a&&(s.createImageBitmap?function(a,c){const b=new s.Blob([new Uint8Array(a)],{type:"image/png"});s.createImageBitmap(b).then(a=>{c(null,a)}).catch(a=>{c(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(a,(a,b)=>c(a,b,d,f)):function(b,e){const a=new s.Image,c=s.URL;a.onload=()=>{e(null,a),c.revokeObjectURL(a.src),a.onload=null,s.requestAnimationFrame(()=>{a.src=fm})},a.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const d=new s.Blob([new Uint8Array(b)],{type:"image/png"});a.src=b.byteLength?c.createObjectURL(d):fm}(a,(a,b)=>c(a,b,d,f)))});return{cancel(){f.cancel(),e()}}};function fn(a,c,b){b[a]&& -1!==b[a].indexOf(c)||(b[a]=b[a]||[],b[a].push(c))}function fo(b,d,a){if(a&&a[b]){const c=a[b].indexOf(d);-1!==c&&a[b].splice(c,1)}}class aW{constructor(a,b={}){bR(this,b),this.type=a}}class cb extends aW{constructor(a,b={}){super("error",bR({error:a},b))}}class S{on(a,b){return this._listeners=this._listeners||{},fn(a,b,this._listeners),this}off(a,b){return fo(a,b,this._listeners),fo(a,b,this._oneTimeListeners),this}once(b,a){return a?(this._oneTimeListeners=this._oneTimeListeners||{},fn(b,a,this._oneTimeListeners),this):new Promise(a=>this.once(b,a))}fire(a,e){"string"==typeof a&&(a=new aW(a,e||{}));const b=a.type;if(this.listens(b)){a.target=this;const f=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const g of f)g.call(this,a);const h=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const c of h)fo(b,c,this._oneTimeListeners),c.call(this,a);const d=this._eventedParent;d&&(bR(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(a))}else a instanceof cb&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var b=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class cc{constructor(b,a,d,c){this.message=(b?`${b}: `:"")+d,c&&(this.identifier=c),null!=a&&a.__line__&&(this.line=a.__line__)}}function cd(a){const b=a.value;return b?[new cc(a.key,b,"constants have been deprecated as of v8")]:[]}function ce(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}function fp(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function fq(a){if(Array.isArray(a))return a.map(fq);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=fq(a[c]);return b}return fp(a)}class fr extends Error{constructor(b,a){super(a),this.message=a,this.key=b}}class fs{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new fs(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw new Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const cf={kind:"null"},f={kind:"number"},i={kind:"string"},h={kind:"boolean"},y={kind:"color"},K={kind:"object"},l={kind:"value"},cg={kind:"collator"},ch={kind:"formatted"},ci={kind:"resolvedImage"};function z(a,b){return{kind:"array",itemType:a,N:b}}function ft(a){if("array"===a.kind){const b=ft(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const fu=[cf,f,i,h,y,ch,K,z(l),ci];function fv(b,a){if("error"===a.kind)return null;if("array"===b.kind){if("array"===a.kind&&(0===a.N&&"value"===a.itemType.kind||!fv(b.itemType,a.itemType))&&("number"!=typeof b.N||b.N===a.N))return null}else{if(b.kind===a.kind)return null;if("value"===b.kind){for(const c of fu)if(!fv(c,a))return null}}return`Expected ${ft(b)} but found ${ft(a)} instead.`}function fw(b,a){return a.some(a=>a.kind===b.kind)}function fx(b,a){return a.some(a=>"null"===a?null===b:"array"===a?Array.isArray(b):"object"===a?b&&!Array.isArray(b)&&"object"==typeof b:a===typeof b)}function ah(b){var a={exports:{}};return b(a,a.exports),a.exports}var fy=ah(function(b,a){var c={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(b,c,a){return a<0?a+=1:a>1&&(a-=1),6*a<1?b+(c-b)*a*6:2*a<1?c:3*a<2?b+(c-b)*(2/3-a)*6:b}try{a.parseCSSColor=function(q){var a,b=q.replace(/ /g,"").toLowerCase();if(b in c)return c[b].slice();if("#"===b[0])return 4===b.length?(a=parseInt(b.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===b.length&&(a=parseInt(b.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var j=b.indexOf("("),p=b.indexOf(")");if(-1!==j&&p+1===b.length){var r=b.substr(0,j),h=b.substr(j+1,p-(j+1)).split(","),k=1;switch(r){case"rgba":if(4!==h.length)return null;k=f(h.pop());case"rgb":return 3!==h.length?null:[e(h[0]),e(h[1]),e(h[2]),k];case"hsla":if(4!==h.length)return null;k=f(h.pop());case"hsl":if(3!==h.length)return null;var m=(parseFloat(h[0])%360+360)%360/360,n=f(h[1]),i=f(h[2]),l=i<=.5?i*(n+1):i+n-i*n,o=2*i-l;return[d(255*g(o,l,m+1/3)),d(255*g(o,l,m)),d(255*g(o,l,m-1/3)),k];default:return null}}return null}}catch(h){}});class m{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(b){if(!b)return;if(b instanceof m)return b;if("string"!=typeof b)return;const a=fy.parseCSSColor(b);return a?new m(a[0]/255*a[3],a[1]/255*a[3],a[2]/255*a[3],a[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:b,g:c,b:d,a:a}=this;return 0===a?[0,0,0,0]:[255*b/a,255*c/a,255*d/a,a]}}m.black=new m(0,0,0,1),m.white=new m(1,1,1,1),m.transparent=new m(0,0,0,0),m.red=new m(1,0,0,1),m.blue=new m(0,0,1,1);class fz{constructor(b,a,c){this.sensitivity=b?a?"variant":"case":a?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class fA{constructor(a,b,c,d,e){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=e}}class fB{constructor(a){this.sections=a}static fromString(a){return new fB([new fA(a,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof fB?a:fB.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const b=["format"];for(const a of this.sections){if(a.image){b.push(["image",a.image.name]);continue}b.push(a.text);const c={};a.fontStack&&(c["text-font"]=["literal",a.fontStack.split(",")]),a.scale&&(c["font-scale"]=a.scale),a.textColor&&(c["text-color"]=["rgba"].concat(a.textColor.toArray())),b.push(c)}return b}}class cj{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new cj({name:a,available:!1}):null}serialize(){return["image",this.name]}}function fC(b,c,d,a){return"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof d&&d>=0&&d<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[b,c,d,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[b,c,d,a]:[b,c,d]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fD(a){if(null===a||"string"==typeof a||"boolean"==typeof a||"number"==typeof a||a instanceof m||a instanceof fz||a instanceof fB||a instanceof cj)return!0;if(Array.isArray(a)){for(const b of a)if(!fD(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!fD(a[c]))return!1;return!0}return!1}function fE(a){if(null===a)return cf;if("string"==typeof a)return i;if("boolean"==typeof a)return h;if("number"==typeof a)return f;if(a instanceof m)return y;if(a instanceof fz)return cg;if(a instanceof fB)return ch;if(a instanceof cj)return ci;if(Array.isArray(a)){const d=a.length;let b;for(const e of a){const c=fE(e);if(b){if(b===c)continue;b=l;break}b=c}return z(b||l,d)}return K}function fF(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof m||a instanceof fB||a instanceof cj?a.toString():JSON.stringify(a)}class ck{constructor(a,b){this.type=a,this.value=b}static parse(b,d){if(2!==b.length)return d.error(`'literal' expression requires exactly one argument, but found ${b.length-1} instead.`);if(!fD(b[1]))return d.error("invalid value");const e=b[1];let c=fE(e);const a=d.expectedType;return"array"===c.kind&&0===c.N&&a&&"array"===a.kind&&("number"!=typeof a.N||0===a.N)&&(c=a),new ck(c,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof m?["rgba"].concat(this.value.toArray()):this.value instanceof fB?this.value.serialize():this.value}}class fG{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const fH={string:i,number:f,boolean:h,object:K};class L{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");let e,b=1;const g=a[0];if("array"===g){let f,h;if(a.length>2){const d=a[1];if("string"!=typeof d||!(d in fH)||"object"===d)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=fH[d],b++}else f=l;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return c.error('The length argument to "array" must be a positive integer literal',2);h=a[2],b++}e=z(f,h)}else e=fH[g];const i=[];for(;ba.outputDefined())}serialize(){const a=this.type,c=[a.kind];if("array"===a.kind){const b=a.itemType;if("string"===b.kind||"number"===b.kind||"boolean"===b.kind){c.push(b.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&c.push(d)}}return c.concat(this.args.map(a=>a.serialize()))}}class cl{constructor(a){this.type=ch,this.sections=a}static parse(c,b){if(c.length<2)return b.error("Expected at least one argument.");const m=c[1];if(!Array.isArray(m)&&"object"==typeof m)return b.error("First argument must be an image or text section.");const d=[];let h=!1;for(let e=1;e<=c.length-1;++e){const a=c[e];if(h&&"object"==typeof a&&!Array.isArray(a)){h=!1;let n=null;if(a["font-scale"]&&!(n=b.parse(a["font-scale"],1,f)))return null;let o=null;if(a["text-font"]&&!(o=b.parse(a["text-font"],1,z(i))))return null;let p=null;if(a["text-color"]&&!(p=b.parse(a["text-color"],1,y)))return null;const j=d[d.length-1];j.scale=n,j.font=o,j.textColor=p}else{const k=b.parse(c[e],1,l);if(!k)return null;const g=k.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,d.push({content:k,scale:null,font:null,textColor:null})}}return new cl(d)}evaluate(a){return new fB(this.sections.map(b=>{const c=b.content.evaluate(a);return fE(c)===ci?new fA("",c,null,null,null):new fA(fF(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(b){for(const a of this.sections)b(a.content),a.scale&&b(a.scale),a.font&&b(a.font),a.textColor&&b(a.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const a of this.sections){c.push(a.content.serialize());const b={};a.scale&&(b["font-scale"]=a.scale.serialize()),a.font&&(b["text-font"]=a.font.serialize()),a.textColor&&(b["text-color"]=a.textColor.serialize()),c.push(b)}return c}}class cm{constructor(a){this.type=ci,this.input=a}static parse(b,a){if(2!==b.length)return a.error("Expected two arguments.");const c=a.parse(b[1],1,i);return c?new cm(c):a.error("No image name provided.")}evaluate(a){const c=this.input.evaluate(a),b=cj.fromString(c);return b&&a.availableImages&&(b.available=a.availableImages.indexOf(c)> -1),b}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const fI={"to-boolean":h,"to-color":y,"to-number":f,"to-string":i};class T{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");const d=a[0];if(("to-boolean"===d||"to-string"===d)&&2!==a.length)return c.error("Expected one argument.");const g=fI[d],e=[];for(let b=1;b4?`Invalid rbga value ${JSON.stringify(a)}: expected an array containing either three or four numeric values.`:fC(a[0],a[1],a[2],a[3])))return new m(a[0]/255,a[1]/255,a[2]/255,a[3])}throw new fG(c||`Could not parse color from value '${"string"==typeof a?a:String(JSON.stringify(a))}'`)}if("number"===this.type.kind){let d=null;for(const h of this.args){if(null===(d=h.evaluate(b)))return 0;const f=Number(d);if(!isNaN(f))return f}throw new fG(`Could not convert ${JSON.stringify(d)} to number.`)}return"formatted"===this.type.kind?fB.fromString(fF(this.args[0].evaluate(b))):"resolvedImage"===this.type.kind?cj.fromString(fF(this.args[0].evaluate(b))):fF(this.args[0].evaluate(b))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new cl([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new cm(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const fJ=["Unknown","Point","LineString","Polygon"];class fK{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?fJ[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=m.parse(a)),b}}class aX{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(f,c){const j=f[0],b=aX.definitions[j];if(!b)return c.error(`Unknown expression "${j}". If you wanted a literal array, use ["literal", [...]].`,0);const q=Array.isArray(b)?b[0]:b.type,m=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,h=m.filter(([a])=>!Array.isArray(a)||a.length===f.length-1);let e=null;for(const[a,r]of h){e=new f1(c.registry,c.path,null,c.scope);const d=[];let n=!1;for(let i=1;i{var a;return a=b,Array.isArray(a)?`(${a.map(ft).join(", ")})`:`(${ft(a.type)}...)`}).join(" | "),k=[];for(let l=1;l=b[2]||a[1]<=b[1]||a[3]>=b[3])}function fN(a,c){const d=(180+a[0])/360,e=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,b=Math.pow(2,c.z);return[Math.round(d*b*8192),Math.round(e*b*8192)]}function fO(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function fP(h,i){var d,b,e;let f=!1;for(let g=0,j=i.length;g(d=h)[1]!=(e=c[a+1])[1]>d[1]&&d[0]<(e[0]-b[0])*(d[1]-b[1])/(e[1]-b[1])+b[0]&&(f=!f)}}return f}function fQ(c,b){for(let a=0;a0&&h<0||g<0&&h>0}function fS(i,j,k){var a,b,c,d,g,h;for(const f of k)for(let e=0;eb[2]){const d=.5*c;let e=a[0]-b[0]>d?-c:b[0]-a[0]>d?c:0;0===e&&(e=a[0]-b[2]>d?-c:b[2]-a[0]>d?c:0),a[0]+=e}fL(f,a)}function fY(f,g,h,a){const i=8192*Math.pow(2,a.z),b=[8192*a.x,8192*a.y],c=[];for(const j of f)for(const d of j){const e=[d.x+b[0],d.y+b[1]];fX(e,g,h,i),c.push(e)}return c}function fZ(j,a,k,c){var b;const e=8192*Math.pow(2,c.z),f=[8192*c.x,8192*c.y],d=[];for(const l of j){const g=[];for(const h of l){const i=[h.x+f[0],h.y+f[1]];fL(a,i),g.push(i)}d.push(g)}if(a[2]-a[0]<=e/2)for(const m of((b=a)[0]=b[1]=1/0,b[2]=b[3]=-1/0,d))for(const n of m)fX(n,a,k,e);return d}class co{constructor(a,b){this.type=h,this.geojson=a,this.geometries=b}static parse(b,d){if(2!==b.length)return d.error(`'within' expression requires exactly one argument, but found ${b.length-1} instead.`);if(fD(b[1])){const a=b[1];if("FeatureCollection"===a.type)for(let c=0;c{b&&!f$(a)&&(b=!1)}),b}function f_(a){if(a instanceof aX&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!f_(a)&&(b=!1)}),b}function f0(a,b){if(a instanceof aX&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!f0(a,b)&&(c=!1)}),c}class cp{constructor(b,a){this.type=a.type,this.name=b,this.boundExpression=a}static parse(c,b){if(2!==c.length||"string"!=typeof c[1])return b.error("'var' expression requires exactly one string literal argument.");const a=c[1];return b.scope.has(a)?new cp(a,b.scope.get(a)):b.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class f1{constructor(b,a=[],c,d=new fs,e=[]){this.registry=b,this.path=a,this.key=a.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=e,this.expectedType=c}parse(a,b,d,e,c={}){return b?this.concat(b,d,e)._parse(a,c):this._parse(a,c)}_parse(a,f){function g(a,b,c){return"assert"===c?new L(b,[a]):"coerce"===c?new T(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[d];if(h){let b=h.parse(a,this);if(!b)return null;if(this.expectedType){const c=this.expectedType,e=b.type;if("string"!==c.kind&&"number"!==c.kind&&"boolean"!==c.kind&&"object"!==c.kind&&"array"!==c.kind||"value"!==e.kind){if("color"!==c.kind&&"formatted"!==c.kind&&"resolvedImage"!==c.kind||"value"!==e.kind&&"string"!==e.kind){if(this.checkSubtype(c,e))return null}else b=g(b,c,f.typeAnnotation||"coerce")}else b=g(b,c,f.typeAnnotation||"assert")}if(!(b instanceof ck)&&"resolvedImage"!==b.type.kind&&f2(b)){const i=new fK;try{b=new ck(b.type,b.evaluate(i))}catch(j){return this.error(j.message),null}}return b}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof a} instead.`)}concat(a,c,b){const d="number"==typeof a?this.path.concat(a):this.path,e=b?this.scope.concat(b):this.scope;return new f1(this.registry,d,c||null,e,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new fr(c,a))}checkSubtype(b,c){const a=fv(b,c);return a&&this.error(a),a}}function f2(a){if(a instanceof cp)return f2(a.boundExpression);if(a instanceof aX&&"error"===a.name||a instanceof cn||a instanceof co)return!1;const c=a instanceof T||a instanceof L;let b=!0;return a.eachChild(a=>{b=c?b&&f2(a):b&&a instanceof ck}),!!b&&f$(a)&&f0(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function f3(b,c){const g=b.length-1;let d,h,e=0,f=g,a=0;for(;e<=f;)if(d=b[a=Math.floor((e+f)/2)],h=b[a+1],d<=c){if(a===g||cc))throw new fG("Input is not a number.");f=a-1}return 0}class cq{constructor(a,b,c){for(const[d,e]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(e)}static parse(b,a){if(b.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if((b.length-1)%2!=0)return a.error("Expected an even number of arguments.");const i=a.parse(b[1],1,f);if(!i)return null;const d=[];let e=null;a.expectedType&&"value"!==a.expectedType.kind&&(e=a.expectedType);for(let c=1;c=g)return a.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',j);const h=a.parse(k,l,e);if(!h)return null;e=e||h.type,d.push([g,h])}return new cq(e,i,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const e=b.length;return d>=b[e-1]?c[e-1].evaluate(a):c[f3(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const b=["step",this.input.serialize()];for(let a=0;a0&&b.push(this.labels[a]),b.push(this.outputs[a].serialize());return b}}function aY(b,c,a){return b*(1-a)+c*a}var f4=Object.freeze({__proto__:null,number:aY,color:function(a,b,c){var d,e,f,g,h,i,j,k,l,n,o,p;return new m((d=a.r,e=b.r,d*(1-(f=c))+e*f),(g=a.g,h=b.g,g*(1-(i=c))+h*i),(j=a.b,k=b.b,j*(1-(l=c))+k*l),(n=a.a,o=b.a,n*(1-(p=c))+o*p))},array:function(a,b,c){return a.map((f,g)=>{var a,d,e;return a=f,d=b[g],a*(1-(e=c))+d*e})}});const f5=4/29,aZ=6/29,f6=3*aZ*aZ,f7=Math.PI/180,f8=180/Math.PI;function f9(a){return a>.008856451679035631?Math.pow(a,1/3):a/f6+f5}function ga(a){return a>aZ?a*a*a:f6*(a-f5)}function gb(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function gc(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function cr(a){const b=gc(a.r),c=gc(a.g),d=gc(a.b),f=f9((.4124564*b+.3575761*c+.1804375*d)/.95047),e=f9((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*e-16,a:500*(f-e),b:200*(e-f9((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function cs(b){let a=(b.l+16)/116,c=isNaN(b.a)?a:a+b.a/500,d=isNaN(b.b)?a:a-b.b/200;return a=1*ga(a),c=.95047*ga(c),d=1.08883*ga(d),new m(gb(3.2404542*c-1.5371385*a-.4985314*d),gb(-0.969266*c+1.8760108*a+.041556*d),gb(.0556434*c-.2040259*a+1.0572252*d),b.alpha)}const ct={forward:cr,reverse:cs,interpolate:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o;return{l:(d=a.l,e=b.l,d*(1-(f=c))+e*f),a:(g=a.a,h=b.a,g*(1-(i=c))+h*i),b:(j=a.b,k=b.b,j*(1-(l=c))+k*l),alpha:(m=a.alpha,n=b.alpha,m*(1-(o=c))+n*o)}}},cu={forward:function(d){const{l:e,a:a,b:b}=cr(d),c=Math.atan2(b,a)*f8;return{h:c<0?c+360:c,c:Math.sqrt(a*a+b*b),l:e,alpha:d.a}},reverse:function(a){const b=a.h*f7,c=a.c;return cs({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){var d,e,f,g,h,i,j,k,l;return{h:function(b,c,d){const a=c-b;return b+d*(a>180||a< -180?a-360*Math.round(a/360):a)}(a.h,b.h,c),c:(d=a.c,e=b.c,d*(1-(f=c))+e*f),l:(g=a.l,h=b.l,g*(1-(i=c))+h*i),alpha:(j=a.alpha,k=b.alpha,j*(1-(l=c))+k*l)}}};var gd=Object.freeze({__proto__:null,lab:ct,hcl:cu});class ai{constructor(a,b,c,d,e){for(const[f,g]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],e))this.labels.push(f),this.outputs.push(g)}static interpolationFactor(a,d,e,f){let b=0;if("exponential"===a.name)b=ge(d,a.base,e,f);else if("linear"===a.name)b=ge(d,1,e,f);else if("cubic-bezier"===a.name){const c=a.controlPoints;b=new eG(c[0],c[1],c[2],c[3]).solve(ge(d,1,e,f))}return b}static parse(g,a){let[h,b,i,...j]=g;if(!Array.isArray(b)||0===b.length)return a.error("Expected an interpolation type expression.",1);if("linear"===b[0])b={name:"linear"};else if("exponential"===b[0]){const n=b[1];if("number"!=typeof n)return a.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:n}}else{if("cubic-bezier"!==b[0])return a.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const k=b.slice(1);if(4!==k.length||k.some(a=>"number"!=typeof a||a<0||a>1))return a.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:k}}}if(g.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${g.length-1}.`);if((g.length-1)%2!=0)return a.error("Expected an even number of arguments.");if(!(i=a.parse(i,2,f)))return null;const e=[];let c=null;"interpolate-hcl"===h||"interpolate-lab"===h?c=y:a.expectedType&&"value"!==a.expectedType.kind&&(c=a.expectedType);for(let d=0;d=l)return a.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const m=a.parse(p,q,c);if(!m)return null;c=c||m.type,e.push([l,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new ai(c,h,b,i,e):a.error(`Type ${ft(c)} is not interpolatable.`)}evaluate(b){const a=this.labels,c=this.outputs;if(1===a.length)return c[0].evaluate(b);const d=this.input.evaluate(b);if(d<=a[0])return c[0].evaluate(b);const i=a.length;if(d>=a[i-1])return c[i-1].evaluate(b);const e=f3(a,d),f=ai.interpolationFactor(this.interpolation,d,a[e],a[e+1]),g=c[e].evaluate(b),h=c[e+1].evaluate(b);return"interpolate"===this.operator?f4[this.type.kind.toLowerCase()](g,h,f):"interpolate-hcl"===this.operator?cu.reverse(cu.interpolate(cu.forward(g),cu.forward(h),f)):ct.reverse(ct.interpolate(ct.forward(g),ct.forward(h),f))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let b;b="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const c=[this.operator,b,this.input.serialize()];for(let a=0;afv(b,a.type));return new cv(h?l:a,c)}evaluate(d){let b,a=null,c=0;for(const e of this.args){if(c++,(a=e.evaluate(d))&&a instanceof cj&&!a.available&&(b||(b=a),a=null,c===this.args.length))return b;if(null!==a)break}return a}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cw{constructor(b,a){this.type=a.type,this.bindings=[].concat(b),this.result=a}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,c){if(a.length<4)return c.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const e=[];for(let b=1;b=b.length)throw new fG(`Array index out of bounds: ${a} > ${b.length-1}.`);if(a!==Math.floor(a))throw new fG(`Array index must be an integer, but found ${a} instead.`);return b[a]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class cy{constructor(a,b){this.type=h,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);return c&&d?fw(c.type,[h,i,f,cf,l])?new cy(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`):null}evaluate(c){const b=this.needle.evaluate(c),a=this.haystack.evaluate(c);if(!a)return!1;if(!fx(b,["boolean","string","number","null"]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(b))} instead.`);if(!fx(a,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(a))} instead.`);return a.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class cz{constructor(a,b,c){this.type=f,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);if(!c||!d)return null;if(!fw(c.type,[h,i,f,cf,l]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`);if(4===a.length){const e=b.parse(a[3],3,f);return e?new cz(c,d,e):null}return new cz(c,d)}evaluate(c){const a=this.needle.evaluate(c),b=this.haystack.evaluate(c);if(!fx(a,["boolean","string","number","null"]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(a))} instead.`);if(!fx(b,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(b))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(c);return b.indexOf(a,d)}return b.indexOf(a)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class cA{constructor(a,b,c,d,e,f){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=e,this.otherwise=f}static parse(b,c){if(b.length<5)return c.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if(b.length%2!=1)return c.error("Expected an even number of arguments.");let g,d;c.expectedType&&"value"!==c.expectedType.kind&&(d=c.expectedType);const j={},k=[];for(let e=2;eNumber.MAX_SAFE_INTEGER)return f.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof a&&Math.floor(a)!==a)return f.error("Numeric branch labels must be integer values.");if(g){if(f.checkSubtype(g,fE(a)))return null}else g=fE(a);if(void 0!==j[String(a)])return f.error("Branch labels must be unique.");j[String(a)]=k.length}const m=c.parse(o,e,d);if(!m)return null;d=d||m.type,k.push(m)}const i=c.parse(b[1],1,l);if(!i)return null;const n=c.parse(b[b.length-1],b.length-1,d);return n?"value"!==i.type.kind&&c.concat(1).checkSubtype(g,i.type)?null:new cA(g,d,i,j,k,n):null}evaluate(a){const b=this.input.evaluate(a);return(fE(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const b=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),c=[],e={};for(const a of h){const f=e[this.cases[a]];void 0===f?(e[this.cases[a]]=c.length,c.push([this.cases[a],[a]])):c[f][1].push(a)}const g=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,d]of c)b.push(1===d.length?g(d[0]):d.map(g)),b.push(this.outputs[i].serialize());return b.push(this.otherwise.serialize()),b}}class cB{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const f=[];for(let d=1;da.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cC{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,c){if(a.length<=2||a.length>=5)return c.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const b=c.parse(a[1],1,l),d=c.parse(a[2],2,f);if(!b||!d)return null;if(!fw(b.type,[z(l),i,l]))return c.error(`Expected first argument to be of type array or string, but found ${ft(b.type)} instead`);if(4===a.length){const e=c.parse(a[3],3,f);return e?new cC(b.type,b,d,e):null}return new cC(b.type,b,d)}evaluate(b){const a=this.input.evaluate(b),c=this.beginIndex.evaluate(b);if(!fx(a,["string","array"]))throw new fG(`Expected first argument to be of type array or string, but found ${ft(fE(a))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(b);return a.slice(c,d)}return a.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function gf(b,a){return"=="===b||"!="===b?"boolean"===a.kind||"string"===a.kind||"number"===a.kind||"null"===a.kind||"value"===a.kind:"string"===a.kind||"number"===a.kind||"value"===a.kind}function cD(d,a,b,c){return 0===c.compare(a,b)}function A(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(a,b,c){this.type=h,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(f,c){if(3!==f.length&&4!==f.length)return c.error("Expected two or three arguments.");const g=f[0];let a=c.parse(f[1],1,l);if(!a)return null;if(!gf(g,a.type))return c.concat(1).error(`"${g}" comparisons are not supported for type '${ft(a.type)}'.`);let b=c.parse(f[2],2,l);if(!b)return null;if(!gf(g,b.type))return c.concat(2).error(`"${g}" comparisons are not supported for type '${ft(b.type)}'.`);if(a.type.kind!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error(`Cannot compare types '${ft(a.type)}' and '${ft(b.type)}'.`);d&&("value"===a.type.kind&&"value"!==b.type.kind?a=new L(b.type,[a]):"value"!==a.type.kind&&"value"===b.type.kind&&(b=new L(a.type,[b])));let h=null;if(4===f.length){if("string"!==a.type.kind&&"string"!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error("Cannot use collator to compare non-string types.");if(!(h=c.parse(f[3],3,cg)))return null}return new e(a,b,h)}evaluate(e){const f=this.lhs.evaluate(e),g=this.rhs.evaluate(e);if(d&&this.hasUntypedArgument){const h=fE(f),i=fE(g);if(h.kind!==i.kind||"string"!==h.kind&&"number"!==h.kind)throw new fG(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${h.kind}, ${i.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const j=fE(f),k=fE(g);if("string"!==j.kind||"string"!==k.kind)return b(e,f,g)}return this.collator?c(e,f,g,this.collator.evaluate(e)):b(e,f,g)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const cE=A("==",function(c,a,b){return a===b},cD),cF=A("!=",function(c,a,b){return a!==b},function(d,a,b,c){return!cD(0,a,b,c)}),cG=A("<",function(c,a,b){return ac.compare(a,b)}),cH=A(">",function(c,a,b){return a>b},function(d,a,b,c){return c.compare(a,b)>0}),cI=A("<=",function(c,a,b){return a<=b},function(d,a,b,c){return 0>=c.compare(a,b)}),cJ=A(">=",function(c,a,b){return a>=b},function(d,a,b,c){return c.compare(a,b)>=0});class cK{constructor(a,b,c,d,e){this.type=i,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=e}static parse(c,b){if(3!==c.length)return b.error("Expected two arguments.");const d=b.parse(c[1],1,f);if(!d)return null;const a=c[2];if("object"!=typeof a||Array.isArray(a))return b.error("NumberFormat options argument must be an object.");let e=null;if(a.locale&&!(e=b.parse(a.locale,1,i)))return null;let g=null;if(a.currency&&!(g=b.parse(a.currency,1,i)))return null;let h=null;if(a["min-fraction-digits"]&&!(h=b.parse(a["min-fraction-digits"],1,f)))return null;let j=null;return!a["max-fraction-digits"]||(j=b.parse(a["max-fraction-digits"],1,f))?new cK(d,e,g,h,j):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a]}}class cL{constructor(a){this.type=f,this.input=a}static parse(b,c){if(2!==b.length)return c.error(`Expected 1 argument, but found ${b.length-1} instead.`);const a=c.parse(b[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?c.error(`Expected argument of type string or array, but found ${ft(a.type)} instead.`):new cL(a):null}evaluate(b){const a=this.input.evaluate(b);if("string"==typeof a||Array.isArray(a))return a.length;throw new fG(`Expected value to be of type string or array, but found ${ft(fE(a))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const U={"==":cE,"!=":cF,">":cH,"<":cG,">=":cJ,"<=":cI,array:L,at:cx,boolean:L,case:cB,coalesce:cv,collator:cn,format:cl,image:cm,in:cy,"index-of":cz,interpolate:ai,"interpolate-hcl":ai,"interpolate-lab":ai,length:cL,let:cw,literal:ck,match:cA,number:L,"number-format":cK,object:L,slice:cC,step:cq,string:L,"to-boolean":T,"to-color":T,"to-number":T,"to-string":T,var:cp,within:co};function a$(b,[c,d,e,f]){c=c.evaluate(b),d=d.evaluate(b),e=e.evaluate(b);const a=f?f.evaluate(b):1,g=fC(c,d,e,a);if(g)throw new fG(g);return new m(c/255*a,d/255*a,e/255*a,a)}function gg(b,c){const a=c[b];return void 0===a?null:a}function x(a){return{type:a}}function gh(a){return{result:"success",value:a}}function gi(a){return{result:"error",value:a}}function gj(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function gk(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function gl(a){return!!a.expression&&a.expression.interpolated}function gm(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function gn(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function go(a){return a}function gp(a,e){const r="color"===e.type,g=a.stops&&"object"==typeof a.stops[0][0],s=g||!(g|| void 0!==a.property),b=a.type||(gl(e)?"exponential":"interval");if(r&&((a=ce({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],m.parse(a[1])])),a.default=m.parse(a.default?a.default:e.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!gd[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let f,j,t;if("exponential"===b)f=gt;else if("interval"===b)f=gs;else if("categorical"===b){for(const k of(f=gr,j=Object.create(null),a.stops))j[k[0]]=k[1];t=typeof a.stops[0][0]}else{if("identity"!==b)throw new Error(`Unknown function type "${b}"`);f=gu}if(g){const c={},l=[];for(let h=0;ha[0]),evaluate:({zoom:b},c)=>gt({stops:n,base:a.base},e,b).evaluate(b,c)}}if(s){const q="exponential"===b?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:ai.interpolationFactor.bind(void 0,q),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:b})=>f(a,e,b,j,t)}}return{kind:"source",evaluate(d,b){const c=b&&b.properties?b.properties[a.property]:void 0;return void 0===c?gq(a.default,e.default):f(a,e,c,j,t)}}}function gq(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function gr(b,c,a,d,e){return gq(typeof a===e?d[a]:void 0,b.default,c.default)}function gs(a,d,b){if("number"!==gm(b))return gq(a.default,d.default);const c=a.stops.length;if(1===c||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[c-1][0])return a.stops[c-1][1];const e=f3(a.stops.map(a=>a[0]),b);return a.stops[e][1]}function gt(a,e,b){const h=void 0!==a.base?a.base:1;if("number"!==gm(b))return gq(a.default,e.default);const d=a.stops.length;if(1===d||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[d-1][0])return a.stops[d-1][1];const c=f3(a.stops.map(a=>a[0]),b),i=function(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}(b,h,a.stops[c][0],a.stops[c+1][0]),f=a.stops[c][1],j=a.stops[c+1][1];let g=f4[e.type]||go;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=gd[a.colorSpace];g=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),i))}return"function"==typeof f.evaluate?{evaluate(...a){const b=f.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return g(b,c,i)}}:g(f,j,i)}function gu(c,b,a){return"color"===b.type?a=m.parse(a):"formatted"===b.type?a=fB.fromString(a.toString()):"resolvedImage"===b.type?a=cj.fromString(a.toString()):gm(a)===b.type||"enum"===b.type&&b.values[a]||(a=void 0),gq(a,c.default,b.default)}aX.register(U,{error:[{kind:"error"},[i],(a,[b])=>{throw new fG(b.evaluate(a))}],typeof:[i,[l],(a,[b])=>ft(fE(b.evaluate(a)))],"to-rgba":[z(f,4),[y],(a,[b])=>b.evaluate(a).toArray()],rgb:[y,[f,f,f],a$],rgba:[y,[f,f,f,f],a$],has:{type:h,overloads:[[[i],(a,[d])=>{var b,c;return b=d.evaluate(a),c=a.properties(),b in c}],[[i,K],(a,[b,c])=>b.evaluate(a) in c.evaluate(a)]]},get:{type:l,overloads:[[[i],(a,[b])=>gg(b.evaluate(a),a.properties())],[[i,K],(a,[b,c])=>gg(b.evaluate(a),c.evaluate(a))]]},"feature-state":[l,[i],(a,[b])=>gg(b.evaluate(a),a.featureState||{})],properties:[K,[],a=>a.properties()],"geometry-type":[i,[],a=>a.geometryType()],id:[l,[],a=>a.id()],zoom:[f,[],a=>a.globals.zoom],pitch:[f,[],a=>a.globals.pitch||0],"distance-from-center":[f,[],a=>a.distanceFromCenter()],"heatmap-density":[f,[],a=>a.globals.heatmapDensity||0],"line-progress":[f,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[f,[],a=>a.globals.skyRadialProgress||0],accumulated:[l,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated],"+":[f,x(f),(b,c)=>{let a=0;for(const d of c)a+=d.evaluate(b);return a}],"*":[f,x(f),(b,c)=>{let a=1;for(const d of c)a*=d.evaluate(b);return a}],"-":{type:f,overloads:[[[f,f],(a,[b,c])=>b.evaluate(a)-c.evaluate(a)],[[f],(a,[b])=>-b.evaluate(a)]]},"/":[f,[f,f],(a,[b,c])=>b.evaluate(a)/c.evaluate(a)],"%":[f,[f,f],(a,[b,c])=>b.evaluate(a)%c.evaluate(a)],ln2:[f,[],()=>Math.LN2],pi:[f,[],()=>Math.PI],e:[f,[],()=>Math.E],"^":[f,[f,f],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a))],sqrt:[f,[f],(a,[b])=>Math.sqrt(b.evaluate(a))],log10:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10],ln:[f,[f],(a,[b])=>Math.log(b.evaluate(a))],log2:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2],sin:[f,[f],(a,[b])=>Math.sin(b.evaluate(a))],cos:[f,[f],(a,[b])=>Math.cos(b.evaluate(a))],tan:[f,[f],(a,[b])=>Math.tan(b.evaluate(a))],asin:[f,[f],(a,[b])=>Math.asin(b.evaluate(a))],acos:[f,[f],(a,[b])=>Math.acos(b.evaluate(a))],atan:[f,[f],(a,[b])=>Math.atan(b.evaluate(a))],min:[f,x(f),(b,a)=>Math.min(...a.map(a=>a.evaluate(b)))],max:[f,x(f),(b,a)=>Math.max(...a.map(a=>a.evaluate(b)))],abs:[f,[f],(a,[b])=>Math.abs(b.evaluate(a))],round:[f,[f],(b,[c])=>{const a=c.evaluate(b);return a<0?-Math.round(-a):Math.round(a)}],floor:[f,[f],(a,[b])=>Math.floor(b.evaluate(a))],ceil:[f,[f],(a,[b])=>Math.ceil(b.evaluate(a))],"filter-==":[h,[i,l],(a,[b,c])=>a.properties()[b.value]===c.value],"filter-id-==":[h,[l],(a,[b])=>a.id()===b.value],"filter-type-==":[h,[i],(a,[b])=>a.geometryType()===b.value],"filter-<":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a{const a=c.id(),b=d.value;return typeof a==typeof b&&a":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>b}],"filter-id->":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>b}],"filter-<=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<=b}],"filter-id-<=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<=b}],"filter->=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>=b}],"filter-id->=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>=b}],"filter-has":[h,[l],(a,[b])=>b.value in a.properties()],"filter-has-id":[h,[],a=>null!==a.id()&& void 0!==a.id()],"filter-type-in":[h,[z(i)],(a,[b])=>b.value.indexOf(a.geometryType())>=0],"filter-id-in":[h,[z(l)],(a,[b])=>b.value.indexOf(a.id())>=0],"filter-in-small":[h,[i,z(l)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0],"filter-in-large":[h,[i,z(l)],(b,[c,a])=>(function(d,e,b,c){for(;b<=c;){const a=b+c>>1;if(e[a]===d)return!0;e[a]>d?c=a-1:b=a+1}return!1})(b.properties()[c.value],a.value,0,a.value.length-1)],all:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0}]]},any:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)||c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1}]]},"!":[h,[h],(a,[b])=>!b.evaluate(a)],"is-supported-script":[h,[i],(a,[c])=>{const b=a.globals&&a.globals.isSupportedScript;return!b||b(c.evaluate(a))}],upcase:[i,[i],(a,[b])=>b.evaluate(a).toUpperCase()],downcase:[i,[i],(a,[b])=>b.evaluate(a).toLowerCase()],concat:[i,x(l),(b,a)=>a.map(a=>fF(a.evaluate(b))).join("")],"resolved-locale":[i,[cg],(a,[b])=>b.evaluate(a).resolvedLocale()]});class cM{constructor(c,b){var a;this.expression=c,this._warningHistory={},this._evaluator=new fK,this._defaultValue=b?"color"===(a=b).type&&gn(a.default)?new m(0,0,0,0):"color"===a.type?m.parse(a.default)||null:void 0===a.default?null:a.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,e,f,g,h){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=e||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=g||null,this._evaluator.featureDistanceData=h||null,this.expression.evaluate(this._evaluator)}evaluate(c,d,e,f,g,h,i,j){this._evaluator.globals=c,this._evaluator.feature=d||null,this._evaluator.featureState=e||null,this._evaluator.canonical=f,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=i||null,this._evaluator.featureDistanceData=j||null;try{const a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new fG(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(a)} instead.`);return a}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,"undefined"!=typeof console&&console.warn(b.message)),this._defaultValue}}}function gv(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in U}function cN(d,a){const b=new f1(U,[],a?function(a){const b={color:y,string:i,number:f,enum:i,boolean:h,formatted:ch,resolvedImage:ci};return"array"===a.type?z(b[a.value]||l,a.length):b[a.type]}(a):void 0),c=b.parse(d,void 0,void 0,void 0,a&&"string"===a.type?{typeAnnotation:"coerce"}:void 0);return c?gh(new cM(c,a)):gi(b.errors)}class cO{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!f_(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}}class cP{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!f_(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}interpolationFactor(a,b,c){return this.interpolationType?ai.interpolationFactor(this.interpolationType,a,b,c):0}}function gw(b,c){if("error"===(b=cN(b,c)).result)return b;const d=b.value.expression,e=f$(d);if(!e&&!gj(c))return gi([new fr("","data expressions not supported")]);const f=f0(d,["zoom","pitch","distance-from-center"]);if(!f&&!gk(c))return gi([new fr("","zoom expressions not supported")]);const a=gx(d);return a||f?a instanceof fr?gi([a]):a instanceof ai&&!gl(c)?gi([new fr("",'"interpolate" expressions cannot be used with this property')]):gh(a?new cP(e?"camera":"composite",b.value,a.labels,a instanceof ai?a.interpolation:void 0):new cO(e?"constant":"source",b.value)):gi([new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class cQ{constructor(a,b){this._parameters=a,this._specification=b,ce(this,gp(this._parameters,this._specification))}static deserialize(a){return new cQ(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function gx(a){let b=null;if(a instanceof cw)b=gx(a.result);else if(a instanceof cv){for(const c of a.args)if(b=gx(c))break}else(a instanceof cq||a instanceof ai)&&a.input instanceof aX&&"zoom"===a.input.name&&(b=a);return b instanceof fr||a.eachChild(c=>{const a=gx(c);a instanceof fr?b=a:!b&&a?b=new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):b&&a&&b!==a&&(b=new fr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),b}function cR(c){const d=c.key,a=c.value,b=c.valueSpec||{},f=c.objectElementValidators||{},l=c.style,m=c.styleSpec;let g=[];const k=gm(a);if("object"!==k)return[new cc(d,a,`object expected, ${k} found`)];for(const e in a){const j=e.split(".")[0],n=b[j]||b["*"];let h;if(f[j])h=f[j];else if(b[j])h=gR;else if(f["*"])h=f["*"];else{if(!b["*"]){g.push(new cc(d,a[e],`unknown property "${e}"`));continue}h=gR}g=g.concat(h({key:(d?`${d}.`:d)+e,value:a[e],valueSpec:n,style:l,styleSpec:m,object:a,objectKey:e},a))}for(const i in b)f[i]||b[i].required&& void 0===b[i].default&& void 0===a[i]&&g.push(new cc(d,a,`missing required property "${i}"`));return g}function cS(c){const b=c.value,a=c.valueSpec,i=c.style,h=c.styleSpec,e=c.key,j=c.arrayElementValidator||gR;if("array"!==gm(b))return[new cc(e,b,`array expected, ${gm(b)} found`)];if(a.length&&b.length!==a.length)return[new cc(e,b,`array length ${a.length} expected, length ${b.length} found`)];if(a["min-length"]&&b.lengthg)return[new cc(e,a,`${a} is greater than the maximum value ${g}`)]}return[]}function cU(a){const f=a.valueSpec,c=fp(a.value.type);let g,h,i,j={};const d="categorical"!==c&& void 0===a.value.property,e="array"===gm(a.value.stops)&&"array"===gm(a.value.stops[0])&&"object"===gm(a.value.stops[0][0]),b=cR({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(a){if("identity"===c)return[new cc(a.key,a.value,'identity function may not have a "stops" property')];let b=[];const d=a.value;return b=b.concat(cS({key:a.key,value:d,valueSpec:a.valueSpec,style:a.style,styleSpec:a.styleSpec,arrayElementValidator:k})),"array"===gm(d)&&0===d.length&&b.push(new cc(a.key,d,"array must have at least one stop")),b},default:function(a){return gR({key:a.key,value:a.value,valueSpec:f,style:a.style,styleSpec:a.styleSpec})}}});return"identity"===c&&d&&b.push(new cc(a.key,a.value,'missing required property "property"')),"identity"===c||a.value.stops||b.push(new cc(a.key,a.value,'missing required property "stops"')),"exponential"===c&&a.valueSpec.expression&&!gl(a.valueSpec)&&b.push(new cc(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(d||gj(a.valueSpec)?d&&!gk(a.valueSpec)&&b.push(new cc(a.key,a.value,"zoom functions not supported")):b.push(new cc(a.key,a.value,"property functions not supported"))),("categorical"===c||e)&& void 0===a.value.property&&b.push(new cc(a.key,a.value,'"property" property is required')),b;function k(c){let d=[];const a=c.value,b=c.key;if("array"!==gm(a))return[new cc(b,a,`array expected, ${gm(a)} found`)];if(2!==a.length)return[new cc(b,a,`array length 2 expected, length ${a.length} found`)];if(e){if("object"!==gm(a[0]))return[new cc(b,a,`object expected, ${gm(a[0])} found`)];if(void 0===a[0].zoom)return[new cc(b,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new cc(b,a,"object stop key must have value")];if(i&&i>fp(a[0].zoom))return[new cc(b,a[0].zoom,"stop zoom values must appear in ascending order")];fp(a[0].zoom)!==i&&(i=fp(a[0].zoom),h=void 0,j={}),d=d.concat(cR({key:`${b}[0]`,value:a[0],valueSpec:{zoom:{}},style:c.style,styleSpec:c.styleSpec,objectElementValidators:{zoom:cT,value:l}}))}else d=d.concat(l({key:`${b}[0]`,value:a[0],valueSpec:{},style:c.style,styleSpec:c.styleSpec},a));return gv(fq(a[1]))?d.concat([new cc(`${b}[1]`,a[1],"expressions are not allowed in function stops.")]):d.concat(gR({key:`${b}[1]`,value:a[1],valueSpec:f,style:c.style,styleSpec:c.styleSpec}))}function l(a,k){const b=gm(a.value),d=fp(a.value),e=null!==a.value?a.value:k;if(g){if(b!==g)return[new cc(a.key,e,`${b} stop domain type must match previous stop domain type ${g}`)]}else g=b;if("number"!==b&&"string"!==b&&"boolean"!==b)return[new cc(a.key,e,"stop domain value must be a number, string, or boolean")];if("number"!==b&&"categorical"!==c){let i=`number expected, ${b} found`;return gj(f)&& void 0===c&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new cc(a.key,e,i)]}return"categorical"!==c||"number"!==b||isFinite(d)&&Math.floor(d)===d?"categorical"!==c&&"number"===b&& void 0!==h&&dnew cc(`${a.key}${b.key}`,a.value,b.message));const b=c.value.expression||c.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!b.outputDefined())return[new cc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===a.expressionContext&&"layout"===a.propertyType&&!f_(b))return[new cc(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===a.expressionContext)return gz(b,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!f0(b,["zoom","feature-state"]))return[new cc(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===a.expressionContext&&!f$(b))return[new cc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function gz(b,a){const c=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const d of a.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return b instanceof aX&&c.has(b.name)?[new cc(a.key,a.value,`["${b.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`)]:(b.eachChild(b=>{e.push(...gz(b,a))}),e)}function cV(c){const e=c.key,a=c.value,b=c.valueSpec,d=[];return Array.isArray(b.values)?-1===b.values.indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${b.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(b.values).indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(a)} found`)),d}function gA(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!gA(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function gB(a,k="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};gA(a)||(a=gI(a));const c=a;let d=!0;try{d=function(a){if(!gE(a))return a;let b=fq(a);return gD(b),b=gC(b)}(c)}catch(l){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(b,c,a){var d=a(3454);!function(c,a){b.exports=a()}(this,function(){"use strict";var c,e,b;function a(g,a){if(c){if(e){var f="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+c+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",d={};c(d),b=a(d),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(b.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else e=a}else c=a}return a(["exports"],function(a){"use strict";var bq="2.7.0",eG=H;function H(a,c,d,b){this.cx=3*a,this.bx=3*(d-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*c,this.by=3*(b-c)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=b,this.p2x=d,this.p2y=b}H.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},H.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},H.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},H.prototype.solveCurveX=function(c,e){var b,d,a,f,g;for(void 0===e&&(e=1e-6),a=c,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(a)-c)Math.abs(h))break;a-=f/h}if((a=c)<(b=0))return b;if(a>(d=1))return d;for(;bf?b=a:d=a,a=.5*(d-b)+b}return a},H.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var aF=aG;function aG(a,b){this.x=a,this.y=b}aG.prototype={clone:function(){return new aG(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(b,a){var c=Math.cos(b),d=Math.sin(b),e=a.y+d*(this.x-a.x)+c*(this.y-a.y);return this.x=a.x+c*(this.x-a.x)-d*(this.y-a.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},aG.convert=function(a){return a instanceof aG?a:Array.isArray(a)?new aG(a[0],a[1]):a};var s="undefined"!=typeof self?self:{},I="undefined"!=typeof Float32Array?Float32Array:Array;function aH(){var a=new I(9);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function aI(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function aJ(a,b,c){var h=b[0],i=b[1],j=b[2],k=b[3],l=b[4],m=b[5],n=b[6],o=b[7],p=b[8],q=b[9],r=b[10],s=b[11],t=b[12],u=b[13],v=b[14],w=b[15],d=c[0],e=c[1],f=c[2],g=c[3];return a[0]=d*h+e*l+f*p+g*t,a[1]=d*i+e*m+f*q+g*u,a[2]=d*j+e*n+f*r+g*v,a[3]=d*k+e*o+f*s+g*w,a[4]=(d=c[4])*h+(e=c[5])*l+(f=c[6])*p+(g=c[7])*t,a[5]=d*i+e*m+f*q+g*u,a[6]=d*j+e*n+f*r+g*v,a[7]=d*k+e*o+f*s+g*w,a[8]=(d=c[8])*h+(e=c[9])*l+(f=c[10])*p+(g=c[11])*t,a[9]=d*i+e*m+f*q+g*u,a[10]=d*j+e*n+f*r+g*v,a[11]=d*k+e*o+f*s+g*w,a[12]=(d=c[12])*h+(e=c[13])*l+(f=c[14])*p+(g=c[15])*t,a[13]=d*i+e*m+f*q+g*u,a[14]=d*j+e*n+f*r+g*v,a[15]=d*k+e*o+f*s+g*w,a}function br(b,a,f){var r,g,h,i,j,k,l,m,n,o,p,q,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[1],h=a[2],i=a[3],j=a[4],k=a[5],l=a[6],m=a[7],n=a[8],o=a[9],p=a[10],q=a[11],b[0]=r=a[0],b[1]=g,b[2]=h,b[3]=i,b[4]=j,b[5]=k,b[6]=l,b[7]=m,b[8]=n,b[9]=o,b[10]=p,b[11]=q,b[12]=r*c+j*d+n*e+a[12],b[13]=g*c+k*d+o*e+a[13],b[14]=h*c+l*d+p*e+a[14],b[15]=i*c+m*d+q*e+a[15]),b}function bs(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function bt(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*d+j*c,a[5]=g*d+k*c,a[6]=h*d+l*c,a[7]=i*d+m*c,a[8]=j*d-f*c,a[9]=k*d-g*c,a[10]=l*d-h*c,a[11]=m*d-i*c,a}function bu(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d-j*c,a[1]=g*d-k*c,a[2]=h*d-l*c,a[3]=i*d-m*c,a[8]=f*c+j*d,a[9]=g*c+k*d,a[10]=h*c+l*d,a[11]=i*c+m*d,a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)});var bv=aJ;function aK(){var a=new I(3);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function eH(b){var a=new I(3);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a}function aL(a){return Math.hypot(a[0],a[1],a[2])}function Q(b,c,d){var a=new I(3);return a[0]=b,a[1]=c,a[2]=d,a}function bw(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function aM(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function aN(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function eI(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function bx(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function by(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function bz(c,a){var d=a[0],e=a[1],f=a[2],b=d*d+e*e+f*f;return b>0&&(b=1/Math.sqrt(b)),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function bA(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function bB(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function bC(b,g,a){var c=g[0],d=g[1],e=g[2],f=a[3]*c+a[7]*d+a[11]*e+a[15];return b[0]=(a[0]*c+a[4]*d+a[8]*e+a[12])/(f=f||1),b[1]=(a[1]*c+a[5]*d+a[9]*e+a[13])/f,b[2]=(a[2]*c+a[6]*d+a[10]*e+a[14])/f,b}function bD(a,h,b){var c=b[0],d=b[1],e=b[2],i=h[0],j=h[1],k=h[2],l=d*k-e*j,f=e*i-c*k,g=c*j-d*i,p=d*g-e*f,n=e*l-c*g,o=c*f-d*l,m=2*b[3];return f*=m,g*=m,n*=2,o*=2,a[0]=i+(l*=m)+(p*=2),a[1]=j+f+n,a[2]=k+g+o,a}var J,bE=aM;function bF(b,c,a){var d=c[0],e=c[1],f=c[2],g=c[3];return b[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*g,b[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*g,b[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*g,b[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*g,b}function aO(){var a=new I(4);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function bG(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function bH(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+i*c,a[1]=g*d+h*c,a[2]=h*d-g*c,a[3]=i*d-f*c,a}function eJ(a,b){return a[0]===b[0]&&a[1]===b[1]}aK(),J=new I(4),I!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0,J[3]=0),aK(),Q(1,0,0),Q(0,1,0),aO(),aO(),aH(),ll=new I(2),I!=Float32Array&&(ll[0]=0,ll[1]=0);const aP=Math.PI/180,eK=180/Math.PI;function bI(a){return a*aP}function bJ(a){return a*eK}const eL=[[0,0],[1,0],[1,1],[0,1]];function bK(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function aQ(a,b,c,d){const e=new eG(a,b,c,d);return function(a){return e.solve(a)}}const bL=aQ(.25,.1,.25,1);function bM(a,b,c){return Math.min(c,Math.max(b,a))}function bN(b,c,a){return(a=bM((a-b)/(c-b),0,1))*a*(3-2*a)}function bO(e,a,c){const b=c-a,d=((e-a)%b+b)%b+a;return d===a?c:d}function bP(a,c,b){if(!a.length)return b(null,[]);let d=a.length;const e=new Array(a.length);let f=null;a.forEach((a,g)=>{c(a,(a,c)=>{a&&(f=a),e[g]=c,0== --d&&b(f,e)})})}function bQ(a){const b=[];for(const c in a)b.push(a[c]);return b}function bR(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}let eM=1;function bS(){return eM++}function eN(){return function b(a){return a?(a^16*Math.random()>>a/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,b)}()}function bT(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function eO(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function bU(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function bV(a,b){return -1!==a.indexOf(b,a.length-b.length)}function eP(a,d,e){const c={};for(const b in a)c[b]=d.call(e||this,a[b],b,a);return c}function bW(a,d,e){const c={};for(const b in a)d.call(e||this,a[b],b,a)&&(c[b]=a[b]);return c}function bX(a){return Array.isArray(a)?a.map(bX):"object"==typeof a&&a?eP(a,bX):a}const eQ={};function bY(a){eQ[a]||("undefined"!=typeof console&&console.warn(a),eQ[a]=!0)}function eR(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function eS(a){let e=0;for(let b,c,d=0,f=a.length,g=f-1;d@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,c,d,e)=>{const b=d||e;return a[c]=!b||b.toLowerCase(),""}),a["max-age"]){const b=parseInt(a["max-age"],10);isNaN(b)?delete a["max-age"]:a["max-age"]=b}return a}let eU,af,eV,eW=null;function eX(b){if(null==eW){const a=b.navigator?b.navigator.userAgent:null;eW=!!b.safari||!(!a||!(/\b(iPad|iPhone|iPod)\b/.test(a)||a.match("Safari")&&!a.match("Chrome")))}return eW}function eY(b){try{const a=s[b];return a.setItem("_mapbox_test_",1),a.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const b$={now:()=>void 0!==eV?eV:s.performance.now(),setNow(a){eV=a},restoreNow(){eV=void 0},frame(a){const b=s.requestAnimationFrame(a);return{cancel:()=>s.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=s.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(eU||(eU=s.document.createElement("a")),eU.href=a,eU.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==af&&(af=s.matchMedia("(prefers-reduced-motion: reduce)")),af.matches)}};let R;const b_={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==R){const aR=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R=null!=d.env.API_URL_REGEX?new RegExp(d.env.API_URL_REGEX):aR}catch(eZ){R=aR}}return R},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},b0={supported:!1,testSupport:function(a){!e_&&ag&&(e0?e1(a):e$=a)}};let e$,ag,e_=!1,e0=!1;function e1(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,ag),a.isContextLost())return;b0.supported=!0}catch(c){}a.deleteTexture(b),e_=!0}s.document&&((ag=s.document.createElement("img")).onload=function(){e$&&e1(e$),e$=null,e0=!0},ag.onerror=function(){e_=!0,e$=null},ag.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const b1="NO_ACCESS_TOKEN";function b2(a){return 0===a.indexOf("mapbox:")}function e2(a){return b_.API_URL_REGEX.test(a)}const e3=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function e4(b){const a=b.match(e3);if(!a)throw new Error("Unable to parse URL object");return{protocol:a[1],authority:a[2],path:a[3]||"/",params:a[4]?a[4].split("&"):[]}}function e5(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function e6(b){if(!b)return null;const a=b.split(".");if(!a||3!==a.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(a[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class e7{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(c){const a=e6(b_.ACCESS_TOKEN);let b="";return b=a&&a.u?s.btoa(encodeURIComponent(a.u).replace(/%([0-9A-F]{2})/g,(b,a)=>String.fromCharCode(Number("0x"+a)))):b_.ACCESS_TOKEN||"",c?`mapbox.eventData.${c}:${b}`:`mapbox.eventData:${b}`}fetchEventData(){const c=eY("localStorage"),d=this.getStorageKey(),e=this.getStorageKey("uuid");if(c)try{const a=s.localStorage.getItem(d);a&&(this.eventData=JSON.parse(a));const b=s.localStorage.getItem(e);b&&(this.anonId=b)}catch(f){bY("Unable to read from LocalStorage")}}saveEventData(){const a=eY("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{s.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){bY("Unable to write to LocalStorage")}}processRequests(a){}postEvent(d,a,h,e){if(!b_.EVENTS_URL)return;const b=e4(b_.EVENTS_URL);b.params.push(`access_token=${e||b_.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(d).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:bq,skuId:"01",userId:this.anonId},f=a?bR(c,a):c,g={url:e5(b),headers:{"Content-Type":"text/plain"},body:JSON.stringify([f])};this.pendingRequest=fj(g,a=>{this.pendingRequest=null,h(a),this.saveEventData(),this.processRequests(e)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const aS=new class extends e7{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){b_.EVENTS_URL&&b_.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>b2(a)||e2(a))&&this.queueRequest(Date.now(),b)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const c=e6(b_.ACCESS_TOKEN),f=c?c.u:b_.ACCESS_TOKEN;let a=f!==this.eventData.tokenU;eO(this.anonId)||(this.anonId=eN(),a=!0);const b=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(b),d=(b-this.eventData.lastSuccess)/864e5;a=a||d>=1||d< -1||g.getDate()!==h.getDate()}else a=!0;if(!a)return this.processRequests();this.postEvent(b,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=b,this.eventData.tokenU=f)},e)}},b3=aS.postTurnstileEvent.bind(aS),aT=new class extends e7{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.EVENTS_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||(this.anonId||this.fetchEventData(),eO(this.anonId)||(this.anonId=eN()),this.postEvent(c,{skuToken:this.skuToken},b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b))}},b4=aT.postMapLoadEvent.bind(aT),aU=new class extends e7{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,b,f,c){if(!b_.API_URL||!b_.SESSION_PATH)return;const a=e4(b_.API_URL+b_.SESSION_PATH);a.params.push(`sku=${b||""}`),a.params.push(`access_token=${c||b_.ACCESS_TOKEN||""}`);const d={url:e5(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=fk(d,a=>{this.pendingRequest=null,f(a),this.saveEventData(),this.processRequests(c)})}getSessionAPI(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.SESSION_PATH&&b_.API_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||this.getSession(c,this.skuToken,b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b)}},b5=aU.getSessionAPI.bind(aU),e8=new Set,e9="mapbox-tiles";let fa,fb,fc=500,fd=50;function fe(){s.caches&&!fa&&(fa=s.caches.open(e9))}function ff(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let fg=1/0;const aV={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(aV);class fh extends Error{constructor(a,b,c){401===b&&e2(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const b6=bZ()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,b7=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(b6())&&!/^\w+:/.test(c))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return function(a,g){var c;const e=new s.AbortController,b=new s.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:b6(),signal:e.signal});let h=!1,i=!1;const f=(c=b.url).indexOf("sku=")>0&&e2(c);"json"===a.type&&b.headers.set("Accept","application/json");const d=(c,d,e)=>{if(i)return;if(c&&"SecurityError"!==c.message&&bY(c),d&&e)return j(d);const h=Date.now();s.fetch(b).then(b=>{if(b.ok){const c=f?b.clone():null;return j(b,c,h)}return g(new fh(b.statusText,b.status,a.url))}).catch(a=>{20!==a.code&&g(new Error(a.message))})},j=(c,d,e)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{i||(d&&e&&function(e,a,c){if(fe(),!fa)return;const d={status:a.status,statusText:a.statusText,headers:new s.Headers};a.headers.forEach((a,b)=>d.headers.set(b,a));const b=eT(a.headers.get("Cache-Control")||"");b["no-store"]||(b["max-age"]&&d.headers.set("Expires",new Date(c+1e3*b["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||function(a,b){if(void 0===fb)try{new Response(new ReadableStream),fb=!0}catch(c){fb=!1}fb?b(a.body):a.blob().then(b)}(a,a=>{const b=new s.Response(a,d);fe(),fa&&fa.then(a=>a.put(ff(e.url),b)).catch(a=>bY(a.message))}))}(b,d,e),h=!0,g(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{i||g(new Error(a.message))})};return f?function(b,a){if(fe(),!fa)return a(null);const c=ff(b.url);fa.then(b=>{b.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=eT(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);b.delete(c),e&&b.put(c,d.clone()),a(null,d,e)}).catch(a)}).catch(a)}(b,d):d(null,null),{cancel(){i=!0,h||e.abort()}}}(a,b);if(bZ()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return function(b,d){const a=new s.XMLHttpRequest;for(const c in a.open(b.method||"GET",b.url,!0),"arrayBuffer"===b.type&&(a.responseType="arraybuffer"),b.headers)a.setRequestHeader(c,b.headers[c]);return"json"===b.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===b.credentials,a.onerror=()=>{d(new Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let c=a.response;if("json"===b.type)try{c=JSON.parse(a.response)}catch(e){return d(e)}d(null,c,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else d(new fh(a.statusText,a.status,b.url))},a.send(b.body),{cancel:()=>a.abort()}}(a,b)},fi=function(a,b){return b7(bR(a,{type:"arrayBuffer"}),b)},fj=function(a,b){return b7(bR(a,{method:"POST"}),b)},fk=function(a,b){return b7(bR(a,{method:"GET"}),b)};function fl(b){const a=s.document.createElement("a");return a.href=b,a.protocol===s.document.location.protocol&&a.host===s.document.location.host}const fm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let b8,b9;b8=[],b9=0;const ca=function(a,c){if(b0.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),b9>=b_.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:a,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return b8.push(b),b}b9++;let d=!1;const e=()=>{if(!d)for(d=!0,b9--;b8.length&&b9{e(),b?c(b):a&&(s.createImageBitmap?function(a,c){const b=new s.Blob([new Uint8Array(a)],{type:"image/png"});s.createImageBitmap(b).then(a=>{c(null,a)}).catch(a=>{c(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(a,(a,b)=>c(a,b,d,f)):function(b,e){const a=new s.Image,c=s.URL;a.onload=()=>{e(null,a),c.revokeObjectURL(a.src),a.onload=null,s.requestAnimationFrame(()=>{a.src=fm})},a.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const d=new s.Blob([new Uint8Array(b)],{type:"image/png"});a.src=b.byteLength?c.createObjectURL(d):fm}(a,(a,b)=>c(a,b,d,f)))});return{cancel(){f.cancel(),e()}}};function fn(a,c,b){b[a]&& -1!==b[a].indexOf(c)||(b[a]=b[a]||[],b[a].push(c))}function fo(b,d,a){if(a&&a[b]){const c=a[b].indexOf(d);-1!==c&&a[b].splice(c,1)}}class aW{constructor(a,b={}){bR(this,b),this.type=a}}class cb extends aW{constructor(a,b={}){super("error",bR({error:a},b))}}class S{on(a,b){return this._listeners=this._listeners||{},fn(a,b,this._listeners),this}off(a,b){return fo(a,b,this._listeners),fo(a,b,this._oneTimeListeners),this}once(b,a){return a?(this._oneTimeListeners=this._oneTimeListeners||{},fn(b,a,this._oneTimeListeners),this):new Promise(a=>this.once(b,a))}fire(a,e){"string"==typeof a&&(a=new aW(a,e||{}));const b=a.type;if(this.listens(b)){a.target=this;const f=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const g of f)g.call(this,a);const h=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const c of h)fo(b,c,this._oneTimeListeners),c.call(this,a);const d=this._eventedParent;d&&(bR(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(a))}else a instanceof cb&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var b=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class cc{constructor(b,a,d,c){this.message=(b?`${b}: `:"")+d,c&&(this.identifier=c),null!=a&&a.__line__&&(this.line=a.__line__)}}function cd(a){const b=a.value;return b?[new cc(a.key,b,"constants have been deprecated as of v8")]:[]}function ce(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}function fp(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function fq(a){if(Array.isArray(a))return a.map(fq);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=fq(a[c]);return b}return fp(a)}class fr extends Error{constructor(b,a){super(a),this.message=a,this.key=b}}class fs{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new fs(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw new Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const cf={kind:"null"},f={kind:"number"},i={kind:"string"},h={kind:"boolean"},y={kind:"color"},K={kind:"object"},l={kind:"value"},cg={kind:"collator"},ch={kind:"formatted"},ci={kind:"resolvedImage"};function z(a,b){return{kind:"array",itemType:a,N:b}}function ft(a){if("array"===a.kind){const b=ft(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const fu=[cf,f,i,h,y,ch,K,z(l),ci];function fv(b,a){if("error"===a.kind)return null;if("array"===b.kind){if("array"===a.kind&&(0===a.N&&"value"===a.itemType.kind||!fv(b.itemType,a.itemType))&&("number"!=typeof b.N||b.N===a.N))return null}else{if(b.kind===a.kind)return null;if("value"===b.kind){for(const c of fu)if(!fv(c,a))return null}}return`Expected ${ft(b)} but found ${ft(a)} instead.`}function fw(b,a){return a.some(a=>a.kind===b.kind)}function fx(b,a){return a.some(a=>"null"===a?null===b:"array"===a?Array.isArray(b):"object"===a?b&&!Array.isArray(b)&&"object"==typeof b:a===typeof b)}function ah(b){var a={exports:{}};return b(a,a.exports),a.exports}var fy=ah(function(b,a){var c={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(b,c,a){return a<0?a+=1:a>1&&(a-=1),6*a<1?b+(c-b)*a*6:2*a<1?c:3*a<2?b+(c-b)*(2/3-a)*6:b}try{a.parseCSSColor=function(q){var a,b=q.replace(/ /g,"").toLowerCase();if(b in c)return c[b].slice();if("#"===b[0])return 4===b.length?(a=parseInt(b.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===b.length&&(a=parseInt(b.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var j=b.indexOf("("),p=b.indexOf(")");if(-1!==j&&p+1===b.length){var r=b.substr(0,j),h=b.substr(j+1,p-(j+1)).split(","),l=1;switch(r){case"rgba":case"hsla":if(4!==h.length)return null;l=f(h.pop());case"rgb":return 3!==h.length?null:[e(h[0]),e(h[1]),e(h[2]),l];case"hsl":if(3!==h.length)return null;var m=(parseFloat(h[0])%360+360)%360/360,n=f(h[1]),i=f(h[2]),k=i<=.5?i*(n+1):i+n-i*n,o=2*i-k;return[d(255*g(o,k,m+1/3)),d(255*g(o,k,m)),d(255*g(o,k,m-1/3)),l];default:return null}}return null}}catch(h){}});class m{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(b){if(!b)return;if(b instanceof m)return b;if("string"!=typeof b)return;const a=fy.parseCSSColor(b);return a?new m(a[0]/255*a[3],a[1]/255*a[3],a[2]/255*a[3],a[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:b,g:c,b:d,a:a}=this;return 0===a?[0,0,0,0]:[255*b/a,255*c/a,255*d/a,a]}}m.black=new m(0,0,0,1),m.white=new m(1,1,1,1),m.transparent=new m(0,0,0,0),m.red=new m(1,0,0,1),m.blue=new m(0,0,1,1);class fz{constructor(b,a,c){this.sensitivity=b?a?"variant":"case":a?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class fA{constructor(a,b,c,d,e){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=e}}class fB{constructor(a){this.sections=a}static fromString(a){return new fB([new fA(a,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof fB?a:fB.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const b=["format"];for(const a of this.sections){if(a.image){b.push(["image",a.image.name]);continue}b.push(a.text);const c={};a.fontStack&&(c["text-font"]=["literal",a.fontStack.split(",")]),a.scale&&(c["font-scale"]=a.scale),a.textColor&&(c["text-color"]=["rgba"].concat(a.textColor.toArray())),b.push(c)}return b}}class cj{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new cj({name:a,available:!1}):null}serialize(){return["image",this.name]}}function fC(b,c,d,a){return"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof d&&d>=0&&d<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[b,c,d,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[b,c,d,a]:[b,c,d]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fD(a){if(null===a||"string"==typeof a||"boolean"==typeof a||"number"==typeof a||a instanceof m||a instanceof fz||a instanceof fB||a instanceof cj)return!0;if(Array.isArray(a)){for(const b of a)if(!fD(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!fD(a[c]))return!1;return!0}return!1}function fE(a){if(null===a)return cf;if("string"==typeof a)return i;if("boolean"==typeof a)return h;if("number"==typeof a)return f;if(a instanceof m)return y;if(a instanceof fz)return cg;if(a instanceof fB)return ch;if(a instanceof cj)return ci;if(Array.isArray(a)){const d=a.length;let b;for(const e of a){const c=fE(e);if(b){if(b===c)continue;b=l;break}b=c}return z(b||l,d)}return K}function fF(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof m||a instanceof fB||a instanceof cj?a.toString():JSON.stringify(a)}class ck{constructor(a,b){this.type=a,this.value=b}static parse(b,d){if(2!==b.length)return d.error(`'literal' expression requires exactly one argument, but found ${b.length-1} instead.`);if(!fD(b[1]))return d.error("invalid value");const e=b[1];let c=fE(e);const a=d.expectedType;return"array"===c.kind&&0===c.N&&a&&"array"===a.kind&&("number"!=typeof a.N||0===a.N)&&(c=a),new ck(c,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof m?["rgba"].concat(this.value.toArray()):this.value instanceof fB?this.value.serialize():this.value}}class fG{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const fH={string:i,number:f,boolean:h,object:K};class L{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");let e,b=1;const g=a[0];if("array"===g){let f,h;if(a.length>2){const d=a[1];if("string"!=typeof d||!(d in fH)||"object"===d)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=fH[d],b++}else f=l;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return c.error('The length argument to "array" must be a positive integer literal',2);h=a[2],b++}e=z(f,h)}else e=fH[g];const i=[];for(;ba.outputDefined())}serialize(){const a=this.type,c=[a.kind];if("array"===a.kind){const b=a.itemType;if("string"===b.kind||"number"===b.kind||"boolean"===b.kind){c.push(b.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&c.push(d)}}return c.concat(this.args.map(a=>a.serialize()))}}class cl{constructor(a){this.type=ch,this.sections=a}static parse(c,b){if(c.length<2)return b.error("Expected at least one argument.");const m=c[1];if(!Array.isArray(m)&&"object"==typeof m)return b.error("First argument must be an image or text section.");const d=[];let h=!1;for(let e=1;e<=c.length-1;++e){const a=c[e];if(h&&"object"==typeof a&&!Array.isArray(a)){h=!1;let n=null;if(a["font-scale"]&&!(n=b.parse(a["font-scale"],1,f)))return null;let o=null;if(a["text-font"]&&!(o=b.parse(a["text-font"],1,z(i))))return null;let p=null;if(a["text-color"]&&!(p=b.parse(a["text-color"],1,y)))return null;const j=d[d.length-1];j.scale=n,j.font=o,j.textColor=p}else{const k=b.parse(c[e],1,l);if(!k)return null;const g=k.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,d.push({content:k,scale:null,font:null,textColor:null})}}return new cl(d)}evaluate(a){return new fB(this.sections.map(b=>{const c=b.content.evaluate(a);return fE(c)===ci?new fA("",c,null,null,null):new fA(fF(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(b){for(const a of this.sections)b(a.content),a.scale&&b(a.scale),a.font&&b(a.font),a.textColor&&b(a.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const a of this.sections){c.push(a.content.serialize());const b={};a.scale&&(b["font-scale"]=a.scale.serialize()),a.font&&(b["text-font"]=a.font.serialize()),a.textColor&&(b["text-color"]=a.textColor.serialize()),c.push(b)}return c}}class cm{constructor(a){this.type=ci,this.input=a}static parse(b,a){if(2!==b.length)return a.error("Expected two arguments.");const c=a.parse(b[1],1,i);return c?new cm(c):a.error("No image name provided.")}evaluate(a){const c=this.input.evaluate(a),b=cj.fromString(c);return b&&a.availableImages&&(b.available=a.availableImages.indexOf(c)> -1),b}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const fI={"to-boolean":h,"to-color":y,"to-number":f,"to-string":i};class T{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");const d=a[0];if(("to-boolean"===d||"to-string"===d)&&2!==a.length)return c.error("Expected one argument.");const g=fI[d],e=[];for(let b=1;b4?`Invalid rbga value ${JSON.stringify(a)}: expected an array containing either three or four numeric values.`:fC(a[0],a[1],a[2],a[3])))return new m(a[0]/255,a[1]/255,a[2]/255,a[3])}throw new fG(c||`Could not parse color from value '${"string"==typeof a?a:String(JSON.stringify(a))}'`)}if("number"===this.type.kind){let d=null;for(const h of this.args){if(null===(d=h.evaluate(b)))return 0;const f=Number(d);if(!isNaN(f))return f}throw new fG(`Could not convert ${JSON.stringify(d)} to number.`)}return"formatted"===this.type.kind?fB.fromString(fF(this.args[0].evaluate(b))):"resolvedImage"===this.type.kind?cj.fromString(fF(this.args[0].evaluate(b))):fF(this.args[0].evaluate(b))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new cl([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new cm(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const fJ=["Unknown","Point","LineString","Polygon"];class fK{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?fJ[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=m.parse(a)),b}}class aX{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(f,c){const j=f[0],b=aX.definitions[j];if(!b)return c.error(`Unknown expression "${j}". If you wanted a literal array, use ["literal", [...]].`,0);const q=Array.isArray(b)?b[0]:b.type,m=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,h=m.filter(([a])=>!Array.isArray(a)||a.length===f.length-1);let e=null;for(const[a,r]of h){e=new f1(c.registry,c.path,null,c.scope);const d=[];let n=!1;for(let i=1;i{var a;return a=b,Array.isArray(a)?`(${a.map(ft).join(", ")})`:`(${ft(a.type)}...)`}).join(" | "),k=[];for(let l=1;l=b[2]||a[1]<=b[1]||a[3]>=b[3])}function fN(a,c){const d=(180+a[0])/360,e=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,b=Math.pow(2,c.z);return[Math.round(d*b*8192),Math.round(e*b*8192)]}function fO(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function fP(h,i){var d,b,e;let f=!1;for(let g=0,j=i.length;g(d=h)[1]!=(e=c[a+1])[1]>d[1]&&d[0]<(e[0]-b[0])*(d[1]-b[1])/(e[1]-b[1])+b[0]&&(f=!f)}}return f}function fQ(c,b){for(let a=0;a0&&h<0||g<0&&h>0}function fS(i,j,k){var a,b,c,d,g,h;for(const f of k)for(let e=0;eb[2]){const d=.5*c;let e=a[0]-b[0]>d?-c:b[0]-a[0]>d?c:0;0===e&&(e=a[0]-b[2]>d?-c:b[2]-a[0]>d?c:0),a[0]+=e}fL(f,a)}function fY(f,g,h,a){const i=8192*Math.pow(2,a.z),b=[8192*a.x,8192*a.y],c=[];for(const j of f)for(const d of j){const e=[d.x+b[0],d.y+b[1]];fX(e,g,h,i),c.push(e)}return c}function fZ(j,a,k,c){var b;const e=8192*Math.pow(2,c.z),f=[8192*c.x,8192*c.y],d=[];for(const l of j){const g=[];for(const h of l){const i=[h.x+f[0],h.y+f[1]];fL(a,i),g.push(i)}d.push(g)}if(a[2]-a[0]<=e/2)for(const m of((b=a)[0]=b[1]=1/0,b[2]=b[3]=-1/0,d))for(const n of m)fX(n,a,k,e);return d}class co{constructor(a,b){this.type=h,this.geojson=a,this.geometries=b}static parse(b,d){if(2!==b.length)return d.error(`'within' expression requires exactly one argument, but found ${b.length-1} instead.`);if(fD(b[1])){const a=b[1];if("FeatureCollection"===a.type)for(let c=0;c{b&&!f$(a)&&(b=!1)}),b}function f_(a){if(a instanceof aX&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!f_(a)&&(b=!1)}),b}function f0(a,b){if(a instanceof aX&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!f0(a,b)&&(c=!1)}),c}class cp{constructor(b,a){this.type=a.type,this.name=b,this.boundExpression=a}static parse(c,b){if(2!==c.length||"string"!=typeof c[1])return b.error("'var' expression requires exactly one string literal argument.");const a=c[1];return b.scope.has(a)?new cp(a,b.scope.get(a)):b.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class f1{constructor(b,a=[],c,d=new fs,e=[]){this.registry=b,this.path=a,this.key=a.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=e,this.expectedType=c}parse(a,b,d,e,c={}){return b?this.concat(b,d,e)._parse(a,c):this._parse(a,c)}_parse(a,f){function g(a,b,c){return"assert"===c?new L(b,[a]):"coerce"===c?new T(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[d];if(h){let b=h.parse(a,this);if(!b)return null;if(this.expectedType){const c=this.expectedType,e=b.type;if("string"!==c.kind&&"number"!==c.kind&&"boolean"!==c.kind&&"object"!==c.kind&&"array"!==c.kind||"value"!==e.kind){if("color"!==c.kind&&"formatted"!==c.kind&&"resolvedImage"!==c.kind||"value"!==e.kind&&"string"!==e.kind){if(this.checkSubtype(c,e))return null}else b=g(b,c,f.typeAnnotation||"coerce")}else b=g(b,c,f.typeAnnotation||"assert")}if(!(b instanceof ck)&&"resolvedImage"!==b.type.kind&&f2(b)){const i=new fK;try{b=new ck(b.type,b.evaluate(i))}catch(j){return this.error(j.message),null}}return b}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof a} instead.`)}concat(a,c,b){const d="number"==typeof a?this.path.concat(a):this.path,e=b?this.scope.concat(b):this.scope;return new f1(this.registry,d,c||null,e,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new fr(c,a))}checkSubtype(b,c){const a=fv(b,c);return a&&this.error(a),a}}function f2(a){if(a instanceof cp)return f2(a.boundExpression);if(a instanceof aX&&"error"===a.name||a instanceof cn||a instanceof co)return!1;const c=a instanceof T||a instanceof L;let b=!0;return a.eachChild(a=>{b=c?b&&f2(a):b&&a instanceof ck}),!!b&&f$(a)&&f0(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function f3(b,c){const g=b.length-1;let d,h,e=0,f=g,a=0;for(;e<=f;)if(d=b[a=Math.floor((e+f)/2)],h=b[a+1],d<=c){if(a===g||cc))throw new fG("Input is not a number.");f=a-1}return 0}class cq{constructor(a,b,c){for(const[d,e]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(e)}static parse(b,a){if(b.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if((b.length-1)%2!=0)return a.error("Expected an even number of arguments.");const i=a.parse(b[1],1,f);if(!i)return null;const d=[];let e=null;a.expectedType&&"value"!==a.expectedType.kind&&(e=a.expectedType);for(let c=1;c=g)return a.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',j);const h=a.parse(k,l,e);if(!h)return null;e=e||h.type,d.push([g,h])}return new cq(e,i,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const e=b.length;return d>=b[e-1]?c[e-1].evaluate(a):c[f3(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const b=["step",this.input.serialize()];for(let a=0;a0&&b.push(this.labels[a]),b.push(this.outputs[a].serialize());return b}}function aY(b,c,a){return b*(1-a)+c*a}var f4=Object.freeze({__proto__:null,number:aY,color:function(a,b,c){var d,e,f,g,h,i,j,k,l,n,o,p;return new m((d=a.r,e=b.r,d*(1-(f=c))+e*f),(g=a.g,h=b.g,g*(1-(i=c))+h*i),(j=a.b,k=b.b,j*(1-(l=c))+k*l),(n=a.a,o=b.a,n*(1-(p=c))+o*p))},array:function(a,b,c){return a.map((f,g)=>{var a,d,e;return a=f,d=b[g],a*(1-(e=c))+d*e})}});const f5=4/29,aZ=6/29,f6=3*aZ*aZ,f7=Math.PI/180,f8=180/Math.PI;function f9(a){return a>.008856451679035631?Math.pow(a,1/3):a/f6+f5}function ga(a){return a>aZ?a*a*a:f6*(a-f5)}function gb(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function gc(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function cr(a){const b=gc(a.r),c=gc(a.g),d=gc(a.b),f=f9((.4124564*b+.3575761*c+.1804375*d)/.95047),e=f9((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*e-16,a:500*(f-e),b:200*(e-f9((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function cs(b){let a=(b.l+16)/116,c=isNaN(b.a)?a:a+b.a/500,d=isNaN(b.b)?a:a-b.b/200;return a=1*ga(a),c=.95047*ga(c),d=1.08883*ga(d),new m(gb(3.2404542*c-1.5371385*a-.4985314*d),gb(-0.969266*c+1.8760108*a+.041556*d),gb(.0556434*c-.2040259*a+1.0572252*d),b.alpha)}const ct={forward:cr,reverse:cs,interpolate:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o;return{l:(d=a.l,e=b.l,d*(1-(f=c))+e*f),a:(g=a.a,h=b.a,g*(1-(i=c))+h*i),b:(j=a.b,k=b.b,j*(1-(l=c))+k*l),alpha:(m=a.alpha,n=b.alpha,m*(1-(o=c))+n*o)}}},cu={forward:function(d){const{l:e,a:a,b:b}=cr(d),c=Math.atan2(b,a)*f8;return{h:c<0?c+360:c,c:Math.sqrt(a*a+b*b),l:e,alpha:d.a}},reverse:function(a){const b=a.h*f7,c=a.c;return cs({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){var d,e,f,g,h,i,j,k,l;return{h:function(b,c,d){const a=c-b;return b+d*(a>180||a< -180?a-360*Math.round(a/360):a)}(a.h,b.h,c),c:(d=a.c,e=b.c,d*(1-(f=c))+e*f),l:(g=a.l,h=b.l,g*(1-(i=c))+h*i),alpha:(j=a.alpha,k=b.alpha,j*(1-(l=c))+k*l)}}};var gd=Object.freeze({__proto__:null,lab:ct,hcl:cu});class ai{constructor(a,b,c,d,e){for(const[f,g]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],e))this.labels.push(f),this.outputs.push(g)}static interpolationFactor(a,d,e,f){let b=0;if("exponential"===a.name)b=ge(d,a.base,e,f);else if("linear"===a.name)b=ge(d,1,e,f);else if("cubic-bezier"===a.name){const c=a.controlPoints;b=new eG(c[0],c[1],c[2],c[3]).solve(ge(d,1,e,f))}return b}static parse(g,a){let[h,b,i,...j]=g;if(!Array.isArray(b)||0===b.length)return a.error("Expected an interpolation type expression.",1);if("linear"===b[0])b={name:"linear"};else if("exponential"===b[0]){const n=b[1];if("number"!=typeof n)return a.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:n}}else{if("cubic-bezier"!==b[0])return a.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const k=b.slice(1);if(4!==k.length||k.some(a=>"number"!=typeof a||a<0||a>1))return a.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:k}}}if(g.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${g.length-1}.`);if((g.length-1)%2!=0)return a.error("Expected an even number of arguments.");if(!(i=a.parse(i,2,f)))return null;const e=[];let c=null;"interpolate-hcl"===h||"interpolate-lab"===h?c=y:a.expectedType&&"value"!==a.expectedType.kind&&(c=a.expectedType);for(let d=0;d=l)return a.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const m=a.parse(p,q,c);if(!m)return null;c=c||m.type,e.push([l,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new ai(c,h,b,i,e):a.error(`Type ${ft(c)} is not interpolatable.`)}evaluate(b){const a=this.labels,c=this.outputs;if(1===a.length)return c[0].evaluate(b);const d=this.input.evaluate(b);if(d<=a[0])return c[0].evaluate(b);const i=a.length;if(d>=a[i-1])return c[i-1].evaluate(b);const e=f3(a,d),f=ai.interpolationFactor(this.interpolation,d,a[e],a[e+1]),g=c[e].evaluate(b),h=c[e+1].evaluate(b);return"interpolate"===this.operator?f4[this.type.kind.toLowerCase()](g,h,f):"interpolate-hcl"===this.operator?cu.reverse(cu.interpolate(cu.forward(g),cu.forward(h),f)):ct.reverse(ct.interpolate(ct.forward(g),ct.forward(h),f))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let b;b="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const c=[this.operator,b,this.input.serialize()];for(let a=0;afv(b,a.type));return new cv(h?l:a,c)}evaluate(d){let b,a=null,c=0;for(const e of this.args){if(c++,(a=e.evaluate(d))&&a instanceof cj&&!a.available&&(b||(b=a),a=null,c===this.args.length))return b;if(null!==a)break}return a}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cw{constructor(b,a){this.type=a.type,this.bindings=[].concat(b),this.result=a}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,c){if(a.length<4)return c.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const e=[];for(let b=1;b=b.length)throw new fG(`Array index out of bounds: ${a} > ${b.length-1}.`);if(a!==Math.floor(a))throw new fG(`Array index must be an integer, but found ${a} instead.`);return b[a]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class cy{constructor(a,b){this.type=h,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);return c&&d?fw(c.type,[h,i,f,cf,l])?new cy(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`):null}evaluate(c){const b=this.needle.evaluate(c),a=this.haystack.evaluate(c);if(!a)return!1;if(!fx(b,["boolean","string","number","null"]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(b))} instead.`);if(!fx(a,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(a))} instead.`);return a.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class cz{constructor(a,b,c){this.type=f,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);if(!c||!d)return null;if(!fw(c.type,[h,i,f,cf,l]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`);if(4===a.length){const e=b.parse(a[3],3,f);return e?new cz(c,d,e):null}return new cz(c,d)}evaluate(c){const a=this.needle.evaluate(c),b=this.haystack.evaluate(c);if(!fx(a,["boolean","string","number","null"]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(a))} instead.`);if(!fx(b,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(b))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(c);return b.indexOf(a,d)}return b.indexOf(a)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class cA{constructor(a,b,c,d,e,f){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=e,this.otherwise=f}static parse(b,c){if(b.length<5)return c.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if(b.length%2!=1)return c.error("Expected an even number of arguments.");let g,d;c.expectedType&&"value"!==c.expectedType.kind&&(d=c.expectedType);const j={},k=[];for(let e=2;eNumber.MAX_SAFE_INTEGER)return f.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof a&&Math.floor(a)!==a)return f.error("Numeric branch labels must be integer values.");if(g){if(f.checkSubtype(g,fE(a)))return null}else g=fE(a);if(void 0!==j[String(a)])return f.error("Branch labels must be unique.");j[String(a)]=k.length}const m=c.parse(o,e,d);if(!m)return null;d=d||m.type,k.push(m)}const i=c.parse(b[1],1,l);if(!i)return null;const n=c.parse(b[b.length-1],b.length-1,d);return n?"value"!==i.type.kind&&c.concat(1).checkSubtype(g,i.type)?null:new cA(g,d,i,j,k,n):null}evaluate(a){const b=this.input.evaluate(a);return(fE(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const b=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),c=[],e={};for(const a of h){const f=e[this.cases[a]];void 0===f?(e[this.cases[a]]=c.length,c.push([this.cases[a],[a]])):c[f][1].push(a)}const g=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,d]of c)b.push(1===d.length?g(d[0]):d.map(g)),b.push(this.outputs[i].serialize());return b.push(this.otherwise.serialize()),b}}class cB{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const f=[];for(let d=1;da.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cC{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,c){if(a.length<=2||a.length>=5)return c.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const b=c.parse(a[1],1,l),d=c.parse(a[2],2,f);if(!b||!d)return null;if(!fw(b.type,[z(l),i,l]))return c.error(`Expected first argument to be of type array or string, but found ${ft(b.type)} instead`);if(4===a.length){const e=c.parse(a[3],3,f);return e?new cC(b.type,b,d,e):null}return new cC(b.type,b,d)}evaluate(b){const a=this.input.evaluate(b),c=this.beginIndex.evaluate(b);if(!fx(a,["string","array"]))throw new fG(`Expected first argument to be of type array or string, but found ${ft(fE(a))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(b);return a.slice(c,d)}return a.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function gf(b,a){return"=="===b||"!="===b?"boolean"===a.kind||"string"===a.kind||"number"===a.kind||"null"===a.kind||"value"===a.kind:"string"===a.kind||"number"===a.kind||"value"===a.kind}function cD(d,a,b,c){return 0===c.compare(a,b)}function A(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(a,b,c){this.type=h,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(f,c){if(3!==f.length&&4!==f.length)return c.error("Expected two or three arguments.");const g=f[0];let a=c.parse(f[1],1,l);if(!a)return null;if(!gf(g,a.type))return c.concat(1).error(`"${g}" comparisons are not supported for type '${ft(a.type)}'.`);let b=c.parse(f[2],2,l);if(!b)return null;if(!gf(g,b.type))return c.concat(2).error(`"${g}" comparisons are not supported for type '${ft(b.type)}'.`);if(a.type.kind!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error(`Cannot compare types '${ft(a.type)}' and '${ft(b.type)}'.`);d&&("value"===a.type.kind&&"value"!==b.type.kind?a=new L(b.type,[a]):"value"!==a.type.kind&&"value"===b.type.kind&&(b=new L(a.type,[b])));let h=null;if(4===f.length){if("string"!==a.type.kind&&"string"!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error("Cannot use collator to compare non-string types.");if(!(h=c.parse(f[3],3,cg)))return null}return new e(a,b,h)}evaluate(e){const f=this.lhs.evaluate(e),g=this.rhs.evaluate(e);if(d&&this.hasUntypedArgument){const h=fE(f),i=fE(g);if(h.kind!==i.kind||"string"!==h.kind&&"number"!==h.kind)throw new fG(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${h.kind}, ${i.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const j=fE(f),k=fE(g);if("string"!==j.kind||"string"!==k.kind)return b(e,f,g)}return this.collator?c(e,f,g,this.collator.evaluate(e)):b(e,f,g)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const cE=A("==",function(c,a,b){return a===b},cD),cF=A("!=",function(c,a,b){return a!==b},function(d,a,b,c){return!cD(0,a,b,c)}),cG=A("<",function(c,a,b){return ac.compare(a,b)}),cH=A(">",function(c,a,b){return a>b},function(d,a,b,c){return c.compare(a,b)>0}),cI=A("<=",function(c,a,b){return a<=b},function(d,a,b,c){return 0>=c.compare(a,b)}),cJ=A(">=",function(c,a,b){return a>=b},function(d,a,b,c){return c.compare(a,b)>=0});class cK{constructor(a,b,c,d,e){this.type=i,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=e}static parse(c,b){if(3!==c.length)return b.error("Expected two arguments.");const d=b.parse(c[1],1,f);if(!d)return null;const a=c[2];if("object"!=typeof a||Array.isArray(a))return b.error("NumberFormat options argument must be an object.");let e=null;if(a.locale&&!(e=b.parse(a.locale,1,i)))return null;let g=null;if(a.currency&&!(g=b.parse(a.currency,1,i)))return null;let h=null;if(a["min-fraction-digits"]&&!(h=b.parse(a["min-fraction-digits"],1,f)))return null;let j=null;return!a["max-fraction-digits"]||(j=b.parse(a["max-fraction-digits"],1,f))?new cK(d,e,g,h,j):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a]}}class cL{constructor(a){this.type=f,this.input=a}static parse(b,c){if(2!==b.length)return c.error(`Expected 1 argument, but found ${b.length-1} instead.`);const a=c.parse(b[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?c.error(`Expected argument of type string or array, but found ${ft(a.type)} instead.`):new cL(a):null}evaluate(b){const a=this.input.evaluate(b);if("string"==typeof a||Array.isArray(a))return a.length;throw new fG(`Expected value to be of type string or array, but found ${ft(fE(a))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const U={"==":cE,"!=":cF,">":cH,"<":cG,">=":cJ,"<=":cI,array:L,at:cx,boolean:L,case:cB,coalesce:cv,collator:cn,format:cl,image:cm,in:cy,"index-of":cz,interpolate:ai,"interpolate-hcl":ai,"interpolate-lab":ai,length:cL,let:cw,literal:ck,match:cA,number:L,"number-format":cK,object:L,slice:cC,step:cq,string:L,"to-boolean":T,"to-color":T,"to-number":T,"to-string":T,var:cp,within:co};function a$(b,[c,d,e,f]){c=c.evaluate(b),d=d.evaluate(b),e=e.evaluate(b);const a=f?f.evaluate(b):1,g=fC(c,d,e,a);if(g)throw new fG(g);return new m(c/255*a,d/255*a,e/255*a,a)}function gg(b,c){const a=c[b];return void 0===a?null:a}function x(a){return{type:a}}function gh(a){return{result:"success",value:a}}function gi(a){return{result:"error",value:a}}function gj(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function gk(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function gl(a){return!!a.expression&&a.expression.interpolated}function gm(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function gn(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function go(a){return a}function gp(a,e){const r="color"===e.type,g=a.stops&&"object"==typeof a.stops[0][0],s=g||!(g|| void 0!==a.property),b=a.type||(gl(e)?"exponential":"interval");if(r&&((a=ce({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],m.parse(a[1])])),a.default=m.parse(a.default?a.default:e.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!gd[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let f,j,t;if("exponential"===b)f=gt;else if("interval"===b)f=gs;else if("categorical"===b){for(const k of(f=gr,j=Object.create(null),a.stops))j[k[0]]=k[1];t=typeof a.stops[0][0]}else{if("identity"!==b)throw new Error(`Unknown function type "${b}"`);f=gu}if(g){const c={},l=[];for(let h=0;ha[0]),evaluate:({zoom:b},c)=>gt({stops:n,base:a.base},e,b).evaluate(b,c)}}if(s){const q="exponential"===b?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:ai.interpolationFactor.bind(void 0,q),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:b})=>f(a,e,b,j,t)}}return{kind:"source",evaluate(d,b){const c=b&&b.properties?b.properties[a.property]:void 0;return void 0===c?gq(a.default,e.default):f(a,e,c,j,t)}}}function gq(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function gr(b,c,a,d,e){return gq(typeof a===e?d[a]:void 0,b.default,c.default)}function gs(a,d,b){if("number"!==gm(b))return gq(a.default,d.default);const c=a.stops.length;if(1===c||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[c-1][0])return a.stops[c-1][1];const e=f3(a.stops.map(a=>a[0]),b);return a.stops[e][1]}function gt(a,e,b){const h=void 0!==a.base?a.base:1;if("number"!==gm(b))return gq(a.default,e.default);const d=a.stops.length;if(1===d||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[d-1][0])return a.stops[d-1][1];const c=f3(a.stops.map(a=>a[0]),b),i=function(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}(b,h,a.stops[c][0],a.stops[c+1][0]),f=a.stops[c][1],j=a.stops[c+1][1];let g=f4[e.type]||go;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=gd[a.colorSpace];g=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),i))}return"function"==typeof f.evaluate?{evaluate(...a){const b=f.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return g(b,c,i)}}:g(f,j,i)}function gu(c,b,a){return"color"===b.type?a=m.parse(a):"formatted"===b.type?a=fB.fromString(a.toString()):"resolvedImage"===b.type?a=cj.fromString(a.toString()):gm(a)===b.type||"enum"===b.type&&b.values[a]||(a=void 0),gq(a,c.default,b.default)}aX.register(U,{error:[{kind:"error"},[i],(a,[b])=>{throw new fG(b.evaluate(a))}],typeof:[i,[l],(a,[b])=>ft(fE(b.evaluate(a)))],"to-rgba":[z(f,4),[y],(a,[b])=>b.evaluate(a).toArray()],rgb:[y,[f,f,f],a$],rgba:[y,[f,f,f,f],a$],has:{type:h,overloads:[[[i],(a,[d])=>{var b,c;return b=d.evaluate(a),c=a.properties(),b in c}],[[i,K],(a,[b,c])=>b.evaluate(a) in c.evaluate(a)]]},get:{type:l,overloads:[[[i],(a,[b])=>gg(b.evaluate(a),a.properties())],[[i,K],(a,[b,c])=>gg(b.evaluate(a),c.evaluate(a))]]},"feature-state":[l,[i],(a,[b])=>gg(b.evaluate(a),a.featureState||{})],properties:[K,[],a=>a.properties()],"geometry-type":[i,[],a=>a.geometryType()],id:[l,[],a=>a.id()],zoom:[f,[],a=>a.globals.zoom],pitch:[f,[],a=>a.globals.pitch||0],"distance-from-center":[f,[],a=>a.distanceFromCenter()],"heatmap-density":[f,[],a=>a.globals.heatmapDensity||0],"line-progress":[f,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[f,[],a=>a.globals.skyRadialProgress||0],accumulated:[l,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated],"+":[f,x(f),(b,c)=>{let a=0;for(const d of c)a+=d.evaluate(b);return a}],"*":[f,x(f),(b,c)=>{let a=1;for(const d of c)a*=d.evaluate(b);return a}],"-":{type:f,overloads:[[[f,f],(a,[b,c])=>b.evaluate(a)-c.evaluate(a)],[[f],(a,[b])=>-b.evaluate(a)]]},"/":[f,[f,f],(a,[b,c])=>b.evaluate(a)/c.evaluate(a)],"%":[f,[f,f],(a,[b,c])=>b.evaluate(a)%c.evaluate(a)],ln2:[f,[],()=>Math.LN2],pi:[f,[],()=>Math.PI],e:[f,[],()=>Math.E],"^":[f,[f,f],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a))],sqrt:[f,[f],(a,[b])=>Math.sqrt(b.evaluate(a))],log10:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10],ln:[f,[f],(a,[b])=>Math.log(b.evaluate(a))],log2:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2],sin:[f,[f],(a,[b])=>Math.sin(b.evaluate(a))],cos:[f,[f],(a,[b])=>Math.cos(b.evaluate(a))],tan:[f,[f],(a,[b])=>Math.tan(b.evaluate(a))],asin:[f,[f],(a,[b])=>Math.asin(b.evaluate(a))],acos:[f,[f],(a,[b])=>Math.acos(b.evaluate(a))],atan:[f,[f],(a,[b])=>Math.atan(b.evaluate(a))],min:[f,x(f),(b,a)=>Math.min(...a.map(a=>a.evaluate(b)))],max:[f,x(f),(b,a)=>Math.max(...a.map(a=>a.evaluate(b)))],abs:[f,[f],(a,[b])=>Math.abs(b.evaluate(a))],round:[f,[f],(b,[c])=>{const a=c.evaluate(b);return a<0?-Math.round(-a):Math.round(a)}],floor:[f,[f],(a,[b])=>Math.floor(b.evaluate(a))],ceil:[f,[f],(a,[b])=>Math.ceil(b.evaluate(a))],"filter-==":[h,[i,l],(a,[b,c])=>a.properties()[b.value]===c.value],"filter-id-==":[h,[l],(a,[b])=>a.id()===b.value],"filter-type-==":[h,[i],(a,[b])=>a.geometryType()===b.value],"filter-<":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a{const a=c.id(),b=d.value;return typeof a==typeof b&&a":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>b}],"filter-id->":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>b}],"filter-<=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<=b}],"filter-id-<=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<=b}],"filter->=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>=b}],"filter-id->=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>=b}],"filter-has":[h,[l],(a,[b])=>b.value in a.properties()],"filter-has-id":[h,[],a=>null!==a.id()&& void 0!==a.id()],"filter-type-in":[h,[z(i)],(a,[b])=>b.value.indexOf(a.geometryType())>=0],"filter-id-in":[h,[z(l)],(a,[b])=>b.value.indexOf(a.id())>=0],"filter-in-small":[h,[i,z(l)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0],"filter-in-large":[h,[i,z(l)],(b,[c,a])=>(function(d,e,b,c){for(;b<=c;){const a=b+c>>1;if(e[a]===d)return!0;e[a]>d?c=a-1:b=a+1}return!1})(b.properties()[c.value],a.value,0,a.value.length-1)],all:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0}]]},any:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)||c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1}]]},"!":[h,[h],(a,[b])=>!b.evaluate(a)],"is-supported-script":[h,[i],(a,[c])=>{const b=a.globals&&a.globals.isSupportedScript;return!b||b(c.evaluate(a))}],upcase:[i,[i],(a,[b])=>b.evaluate(a).toUpperCase()],downcase:[i,[i],(a,[b])=>b.evaluate(a).toLowerCase()],concat:[i,x(l),(b,a)=>a.map(a=>fF(a.evaluate(b))).join("")],"resolved-locale":[i,[cg],(a,[b])=>b.evaluate(a).resolvedLocale()]});class cM{constructor(c,b){var a;this.expression=c,this._warningHistory={},this._evaluator=new fK,this._defaultValue=b?"color"===(a=b).type&&gn(a.default)?new m(0,0,0,0):"color"===a.type?m.parse(a.default)||null:void 0===a.default?null:a.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,e,f,g,h){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=e||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=g||null,this._evaluator.featureDistanceData=h||null,this.expression.evaluate(this._evaluator)}evaluate(c,d,e,f,g,h,i,j){this._evaluator.globals=c,this._evaluator.feature=d||null,this._evaluator.featureState=e||null,this._evaluator.canonical=f,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=i||null,this._evaluator.featureDistanceData=j||null;try{const a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new fG(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(a)} instead.`);return a}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,"undefined"!=typeof console&&console.warn(b.message)),this._defaultValue}}}function gv(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in U}function cN(d,a){const b=new f1(U,[],a?function(a){const b={color:y,string:i,number:f,enum:i,boolean:h,formatted:ch,resolvedImage:ci};return"array"===a.type?z(b[a.value]||l,a.length):b[a.type]}(a):void 0),c=b.parse(d,void 0,void 0,void 0,a&&"string"===a.type?{typeAnnotation:"coerce"}:void 0);return c?gh(new cM(c,a)):gi(b.errors)}class cO{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!f_(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}}class cP{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!f_(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}interpolationFactor(a,b,c){return this.interpolationType?ai.interpolationFactor(this.interpolationType,a,b,c):0}}function gw(b,c){if("error"===(b=cN(b,c)).result)return b;const d=b.value.expression,e=f$(d);if(!e&&!gj(c))return gi([new fr("","data expressions not supported")]);const f=f0(d,["zoom","pitch","distance-from-center"]);if(!f&&!gk(c))return gi([new fr("","zoom expressions not supported")]);const a=gx(d);return a||f?a instanceof fr?gi([a]):a instanceof ai&&!gl(c)?gi([new fr("",'"interpolate" expressions cannot be used with this property')]):gh(a?new cP(e?"camera":"composite",b.value,a.labels,a instanceof ai?a.interpolation:void 0):new cO(e?"constant":"source",b.value)):gi([new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class cQ{constructor(a,b){this._parameters=a,this._specification=b,ce(this,gp(this._parameters,this._specification))}static deserialize(a){return new cQ(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function gx(a){let b=null;if(a instanceof cw)b=gx(a.result);else if(a instanceof cv){for(const c of a.args)if(b=gx(c))break}else(a instanceof cq||a instanceof ai)&&a.input instanceof aX&&"zoom"===a.input.name&&(b=a);return b instanceof fr||a.eachChild(c=>{const a=gx(c);a instanceof fr?b=a:!b&&a?b=new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):b&&a&&b!==a&&(b=new fr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),b}function cR(c){const d=c.key,a=c.value,b=c.valueSpec||{},f=c.objectElementValidators||{},l=c.style,m=c.styleSpec;let g=[];const k=gm(a);if("object"!==k)return[new cc(d,a,`object expected, ${k} found`)];for(const e in a){const j=e.split(".")[0],n=b[j]||b["*"];let h;if(f[j])h=f[j];else if(b[j])h=gR;else if(f["*"])h=f["*"];else{if(!b["*"]){g.push(new cc(d,a[e],`unknown property "${e}"`));continue}h=gR}g=g.concat(h({key:(d?`${d}.`:d)+e,value:a[e],valueSpec:n,style:l,styleSpec:m,object:a,objectKey:e},a))}for(const i in b)f[i]||b[i].required&& void 0===b[i].default&& void 0===a[i]&&g.push(new cc(d,a,`missing required property "${i}"`));return g}function cS(c){const b=c.value,a=c.valueSpec,i=c.style,h=c.styleSpec,e=c.key,j=c.arrayElementValidator||gR;if("array"!==gm(b))return[new cc(e,b,`array expected, ${gm(b)} found`)];if(a.length&&b.length!==a.length)return[new cc(e,b,`array length ${a.length} expected, length ${b.length} found`)];if(a["min-length"]&&b.lengthg)return[new cc(e,a,`${a} is greater than the maximum value ${g}`)]}return[]}function cU(a){const f=a.valueSpec,c=fp(a.value.type);let g,h,i,j={};const d="categorical"!==c&& void 0===a.value.property,e="array"===gm(a.value.stops)&&"array"===gm(a.value.stops[0])&&"object"===gm(a.value.stops[0][0]),b=cR({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(a){if("identity"===c)return[new cc(a.key,a.value,'identity function may not have a "stops" property')];let b=[];const d=a.value;return b=b.concat(cS({key:a.key,value:d,valueSpec:a.valueSpec,style:a.style,styleSpec:a.styleSpec,arrayElementValidator:k})),"array"===gm(d)&&0===d.length&&b.push(new cc(a.key,d,"array must have at least one stop")),b},default:function(a){return gR({key:a.key,value:a.value,valueSpec:f,style:a.style,styleSpec:a.styleSpec})}}});return"identity"===c&&d&&b.push(new cc(a.key,a.value,'missing required property "property"')),"identity"===c||a.value.stops||b.push(new cc(a.key,a.value,'missing required property "stops"')),"exponential"===c&&a.valueSpec.expression&&!gl(a.valueSpec)&&b.push(new cc(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(d||gj(a.valueSpec)?d&&!gk(a.valueSpec)&&b.push(new cc(a.key,a.value,"zoom functions not supported")):b.push(new cc(a.key,a.value,"property functions not supported"))),("categorical"===c||e)&& void 0===a.value.property&&b.push(new cc(a.key,a.value,'"property" property is required')),b;function k(c){let d=[];const a=c.value,b=c.key;if("array"!==gm(a))return[new cc(b,a,`array expected, ${gm(a)} found`)];if(2!==a.length)return[new cc(b,a,`array length 2 expected, length ${a.length} found`)];if(e){if("object"!==gm(a[0]))return[new cc(b,a,`object expected, ${gm(a[0])} found`)];if(void 0===a[0].zoom)return[new cc(b,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new cc(b,a,"object stop key must have value")];if(i&&i>fp(a[0].zoom))return[new cc(b,a[0].zoom,"stop zoom values must appear in ascending order")];fp(a[0].zoom)!==i&&(i=fp(a[0].zoom),h=void 0,j={}),d=d.concat(cR({key:`${b}[0]`,value:a[0],valueSpec:{zoom:{}},style:c.style,styleSpec:c.styleSpec,objectElementValidators:{zoom:cT,value:l}}))}else d=d.concat(l({key:`${b}[0]`,value:a[0],valueSpec:{},style:c.style,styleSpec:c.styleSpec},a));return gv(fq(a[1]))?d.concat([new cc(`${b}[1]`,a[1],"expressions are not allowed in function stops.")]):d.concat(gR({key:`${b}[1]`,value:a[1],valueSpec:f,style:c.style,styleSpec:c.styleSpec}))}function l(a,k){const b=gm(a.value),d=fp(a.value),e=null!==a.value?a.value:k;if(g){if(b!==g)return[new cc(a.key,e,`${b} stop domain type must match previous stop domain type ${g}`)]}else g=b;if("number"!==b&&"string"!==b&&"boolean"!==b)return[new cc(a.key,e,"stop domain value must be a number, string, or boolean")];if("number"!==b&&"categorical"!==c){let i=`number expected, ${b} found`;return gj(f)&& void 0===c&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new cc(a.key,e,i)]}return"categorical"!==c||"number"!==b||isFinite(d)&&Math.floor(d)===d?"categorical"!==c&&"number"===b&& void 0!==h&&dnew cc(`${a.key}${b.key}`,a.value,b.message));const b=c.value.expression||c.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!b.outputDefined())return[new cc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===a.expressionContext&&"layout"===a.propertyType&&!f_(b))return[new cc(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===a.expressionContext)return gz(b,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!f0(b,["zoom","feature-state"]))return[new cc(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===a.expressionContext&&!f$(b))return[new cc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function gz(b,a){const c=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const d of a.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return b instanceof aX&&c.has(b.name)?[new cc(a.key,a.value,`["${b.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`)]:(b.eachChild(b=>{e.push(...gz(b,a))}),e)}function cV(c){const e=c.key,a=c.value,b=c.valueSpec,d=[];return Array.isArray(b.values)?-1===b.values.indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${b.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(b.values).indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(a)} found`)),d}function gA(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!gA(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function gB(a,k="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};gA(a)||(a=gI(a));const c=a;let d=!0;try{d=function(a){if(!gE(a))return a;let b=fq(a);return gD(b),b=gC(b)}(c)}catch(l){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.js index 63849f978001..8a32dc8d5ff9 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/if_else7/output.js @@ -1,2 +1 @@ -if ("bar" === foo); -else other(); +"bar" === foo || other(); From 82d70811c7b0c40b382ac529a741e54a626e10f5 Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 19:44:50 +0800 Subject: [PATCH 20/27] merge with last default --- .../src/compress/optimize/switches.rs | 41 ++++++++++++++++++- .../tests/fixture/issues/2257/full/output.js | 1 - .../pages/index-cb36c1bf7f830e3c/output.js | 3 -- .../tests/projects/output/react-17.0.2.js | 1 - .../tests/projects/output/react-dom-17.0.2.js | 33 ++++++--------- .../switch/gut_entire_switch/output.js | 1 + .../switch/gut_entire_switch_2/output.js | 2 +- .../compress/switch/issue_441_1/output.js | 1 + .../compress/switch/issue_441_2/output.js | 1 + 9 files changed, 55 insertions(+), 29 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 358512c2c621..629475938f05 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -194,16 +194,53 @@ where last += has_side_effect + 1 } + let default = cases.iter().position(|case| case.test.is_none()); + // if default is before empty cases, we must ensure empty case is preserved - if last < cases.len() && !cases.iter().take(last).any(|case| case.test.is_none()) { + if last < cases.len() && default.map(|idx| idx >= last).unwrap_or(true) { self.changed = true; report_change!("switches: Removing empty cases at the end"); cases.drain(last..); } + + if let Some(default) = default { + let end = cases + .iter() + .skip(default) + .position(|case| !case.cons.is_empty()) + .unwrap_or(0) + + default; + + if end != cases.len() - 1 { + return; + } + let start = cases.iter().enumerate().rposition(|(idx, case)| { + case.test + .as_deref() + .map(|test| test.may_have_side_effects()) + .unwrap_or(false) + || (idx != end && !case.cons.is_empty()) + }); + + let start = start.map(|s| s + 1).unwrap_or(0); + + if start <= default { + if start < end { + cases[start].cons = cases[end].cons.take(); + cases.drain((start + 1)..); + cases[start].test = None; + } + } else { + if start <= end { + cases[start].cons = cases[end].cons.take(); + cases.drain(start..); + } + } + } } /// If a case ends with break but content is same with the another case - /// without break evaluation order, except the break statement, we merge + /// without break case order, except the break statement, we merge /// them. fn merge_cases_with_same_cons(&mut self, cases: &mut Vec) { let boundary: Vec = cases 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 2d425cab2844..15d76fac1fb5 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 @@ -13232,7 +13232,6 @@ return null !== (b = 1 !== b.nodeType || c.toLowerCase() !== b.nodeName.toLowerCase() ? null : b) && (a.stateNode = b, !0); case 6: return null !== (b = "" === a.pendingProps || 3 !== b.nodeType ? null : b) && (a.stateNode = b, !0); - case 13: default: return !1; } 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 6a4ff95abb38..600a0b42697d 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 @@ -3619,9 +3619,6 @@ case 'urn:mpeg:dash:utc:direct:2012': attributes.method = 'DIRECT', attributes.value = Date.parse(attributes.value); break; - case 'urn:mpeg:dash:utc:http-ntp:2014': - case 'urn:mpeg:dash:utc:ntp:2014': - case 'urn:mpeg:dash:utc:sntp:2014': default: throw new Error(errors.UNSUPPORTED_UTC_TIMING_SCHEME); } diff --git a/crates/swc_ecma_minifier/tests/projects/output/react-17.0.2.js b/crates/swc_ecma_minifier/tests/projects/output/react-17.0.2.js index 33a3b87b34cd..84552ed0e7e3 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/react-17.0.2.js +++ b/crates/swc_ecma_minifier/tests/projects/output/react-17.0.2.js @@ -833,7 +833,6 @@ case 4: timeout = 10000; break; - case 3: default: timeout = 5000; } diff --git a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js index 82be1216c301..493b5286881a 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js +++ b/crates/swc_ecma_minifier/tests/projects/output/react-dom-17.0.2.js @@ -337,10 +337,10 @@ } } } - var _assign = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign, REACT_ELEMENT_TYPE = 0xeac7, REACT_PORTAL_TYPE = 0xeaca, REACT_FRAGMENT_TYPE = 0xeacb, REACT_STRICT_MODE_TYPE = 0xeacc, REACT_PROFILER_TYPE = 0xead2, REACT_PROVIDER_TYPE = 0xeacd, REACT_CONTEXT_TYPE = 0xeace, REACT_FORWARD_REF_TYPE = 0xead0, REACT_SUSPENSE_TYPE = 0xead1, REACT_SUSPENSE_LIST_TYPE = 0xead8, REACT_MEMO_TYPE = 0xead3, REACT_LAZY_TYPE = 0xead4, REACT_BLOCK_TYPE = 0xead9, REACT_SCOPE_TYPE = 0xead7, REACT_OPAQUE_ID_TYPE = 0xeae0, REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1, REACT_OFFSCREEN_TYPE = 0xeae2, REACT_LEGACY_HIDDEN_TYPE = 0xeae3; + var _assign = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign, REACT_ELEMENT_TYPE = 0xeac7, REACT_PORTAL_TYPE = 0xeaca, REACT_FRAGMENT_TYPE = 0xeacb, REACT_STRICT_MODE_TYPE = 0xeacc, REACT_PROFILER_TYPE = 0xead2, REACT_PROVIDER_TYPE = 0xeacd, REACT_CONTEXT_TYPE = 0xeace, REACT_FORWARD_REF_TYPE = 0xead0, REACT_SUSPENSE_TYPE = 0xead1, REACT_SUSPENSE_LIST_TYPE = 0xead8, REACT_MEMO_TYPE = 0xead3, REACT_LAZY_TYPE = 0xead4, REACT_BLOCK_TYPE = 0xead9, REACT_OPAQUE_ID_TYPE = 0xeae0, REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1, REACT_OFFSCREEN_TYPE = 0xeae2, REACT_LEGACY_HIDDEN_TYPE = 0xeae3; if ('function' == typeof Symbol && Symbol.for) { var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor('react.element'), REACT_PORTAL_TYPE = symbolFor('react.portal'), REACT_FRAGMENT_TYPE = symbolFor('react.fragment'), REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'), REACT_PROFILER_TYPE = symbolFor('react.profiler'), REACT_PROVIDER_TYPE = symbolFor('react.provider'), REACT_CONTEXT_TYPE = symbolFor('react.context'), REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'), REACT_SUSPENSE_TYPE = symbolFor('react.suspense'), REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'), REACT_MEMO_TYPE = symbolFor('react.memo'), REACT_LAZY_TYPE = symbolFor('react.lazy'), REACT_BLOCK_TYPE = symbolFor('react.block'), symbolFor('react.server.block'), symbolFor('react.fundamental'), REACT_SCOPE_TYPE = symbolFor('react.scope'), REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'), REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'), REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'), REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); + REACT_ELEMENT_TYPE = symbolFor('react.element'), REACT_PORTAL_TYPE = symbolFor('react.portal'), REACT_FRAGMENT_TYPE = symbolFor('react.fragment'), REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode'), REACT_PROFILER_TYPE = symbolFor('react.profiler'), REACT_PROVIDER_TYPE = symbolFor('react.provider'), REACT_CONTEXT_TYPE = symbolFor('react.context'), REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref'), REACT_SUSPENSE_TYPE = symbolFor('react.suspense'), REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list'), REACT_MEMO_TYPE = symbolFor('react.memo'), REACT_LAZY_TYPE = symbolFor('react.lazy'), REACT_BLOCK_TYPE = symbolFor('react.block'), symbolFor('react.server.block'), symbolFor('react.fundamental'), symbolFor('react.scope'), REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'), REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode'), REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen'), REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); } var MAYBE_ITERATOR_SYMBOL = 'function' == typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { @@ -3247,7 +3247,6 @@ case 1: listenerWrapper = dispatchUserBlockingUpdate; break; - case 2: default: listenerWrapper = dispatchEvent; } @@ -4900,21 +4899,16 @@ return placeSingleChild(function(returnFiber, currentFirstChild, element, lanes) { for(var key = element.key, child = currentFirstChild; null !== child;){ if (child.key === key) { - switch(child.tag){ - case 7: - if (element.type === REACT_FRAGMENT_TYPE) { - deleteRemainingChildren(returnFiber, child.sibling); - var existing = useFiber(child, element.props.children); - return existing.return = returnFiber, existing._debugSource = element._source, existing._debugOwner = element._owner, existing; - } - break; - case 22: - default: - if (child.elementType === element.type || isCompatibleFamilyForHotReloading(child, element)) { - deleteRemainingChildren(returnFiber, child.sibling); - var _existing3 = useFiber(child, element.props); - return _existing3.ref = coerceRef(returnFiber, child, element), _existing3.return = returnFiber, _existing3._debugSource = element._source, _existing3._debugOwner = element._owner, _existing3; - } + if (7 === child.tag) { + if (element.type === REACT_FRAGMENT_TYPE) { + deleteRemainingChildren(returnFiber, child.sibling); + var existing = useFiber(child, element.props.children); + return existing.return = returnFiber, existing._debugSource = element._source, existing._debugOwner = element._owner, existing; + } + } else if (child.elementType === element.type || isCompatibleFamilyForHotReloading(child, element)) { + deleteRemainingChildren(returnFiber, child.sibling); + var _existing3 = useFiber(child, element.props); + return _existing3.ref = coerceRef(returnFiber, child, element), _existing3.return = returnFiber, _existing3._debugSource = element._source, _existing3._debugOwner = element._owner, _existing3; } deleteRemainingChildren(returnFiber, child); break; @@ -5172,7 +5166,6 @@ var instance6, text = fiber.pendingProps, textInstance = (instance6 = nextInstance, '' === text || 3 !== instance6.nodeType ? null : instance6); if (null !== textInstance) return fiber.stateNode = textInstance, !0; return !1; - case 13: default: return !1; } @@ -7745,7 +7738,6 @@ case 4: parent1 = parentStateNode.containerInfo, isContainer = !0; break; - case 20: default: throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue."); } @@ -8988,7 +8980,6 @@ return createFiberFromOffscreen(pendingProps, mode, lanes, key); case REACT_LEGACY_HIDDEN_TYPE: return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); - case REACT_SCOPE_TYPE: default: if ('object' == typeof type && null !== type) switch(type.$$typeof){ case REACT_PROVIDER_TYPE: diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js index 5669eec47340..5cf989a75381 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch/output.js @@ -1 +1,2 @@ +id(123); console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.js index 5cf989a75381..7f8744952643 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/gut_entire_switch_2/output.js @@ -1,2 +1,2 @@ -id(123); +if (1 === id(123)) "no side effect"; console.log("PASS"); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_441_1/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_441_1/output.js index 859e262ec7fb..3f2d878e6904 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_441_1/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_441_1/output.js @@ -1 +1,2 @@ +foo; qux(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_441_2/output.js b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_441_2/output.js index 859e262ec7fb..3f2d878e6904 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_441_2/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/switch/issue_441_2/output.js @@ -1 +1,2 @@ +foo; qux(); From 3a5bd7f37310c59e58756b35dfc788c0e2b2751b Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 21:02:47 +0800 Subject: [PATCH 21/27] add test --- .../non-const/analysis-snapshot.rust-debug | 80 +++++++++++++++++++ .../simple/switch/merge/non-const/input.js | 11 +++ .../simple/switch/merge/non-const/output.js | 11 +++ .../{ => simple}/analysis-snapshot.rust-debug | 0 .../simple/switch/merge/{ => simple}/input.js | 0 .../switch/merge/{ => simple}/output.js | 0 6 files changed, 102 insertions(+) create mode 100644 crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/analysis-snapshot.rust-debug create mode 100644 crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/input.js create mode 100644 crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/output.js rename crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/{ => simple}/analysis-snapshot.rust-debug (100%) rename crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/{ => simple}/input.js (100%) rename crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/{ => simple}/output.js (100%) diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/analysis-snapshot.rust-debug new file mode 100644 index 000000000000..462f13101462 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/analysis-snapshot.rust-debug @@ -0,0 +1,80 @@ +TestSnapshot { + vars: [ + ( + ( + Atom('a' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 2, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 2, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: false, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: false, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: true, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ( + ( + Atom('console' type=inline), + #1, + ), + VarUsageInfo { + inline_prevented: false, + ref_count: 3, + cond_init: false, + declared: false, + declared_count: 0, + declared_as_fn_param: false, + declared_as_fn_expr: false, + assign_count: 0, + mutation_by_call_count: 0, + usage_count: 3, + reassigned_with_assignment: false, + reassigned_with_var_decl: false, + mutated: false, + has_property_access: true, + has_property_mutation: false, + accessed_props: {}, + exported: false, + used_above_decl: true, + is_fn_local: true, + used_by_nested_fn: false, + executed_multiple_time: false, + used_in_cond: true, + var_kind: None, + var_initialized: false, + declared_as_catch_param: false, + no_side_effect_for_member_access: false, + used_as_callee: false, + used_as_arg: false, + pure_fn: false, + infects: [], + }, + ), + ], +} diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/input.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/input.js new file mode 100644 index 000000000000..c819d2ce088b --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/input.js @@ -0,0 +1,11 @@ +switch (a) { + case 1: + console.log(1); + break; + case 2: + console.log(2); + break; + case a(): + case 3: + console.log(1); +} diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/output.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/output.js new file mode 100644 index 000000000000..c819d2ce088b --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/output.js @@ -0,0 +1,11 @@ +switch (a) { + case 1: + console.log(1); + break; + case 2: + console.log(2); + break; + case a(): + case 3: + console.log(1); +} diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/simple/analysis-snapshot.rust-debug similarity index 100% rename from crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/analysis-snapshot.rust-debug rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/simple/analysis-snapshot.rust-debug diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/input.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/simple/input.js similarity index 100% rename from crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/input.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/simple/input.js diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/output.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/simple/output.js similarity index 100% rename from crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/output.js rename to crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/simple/output.js From cf6fe072e690b0657d13fed9bfaee3a1f94f848b Mon Sep 17 00:00:00 2001 From: austaras Date: Wed, 20 Apr 2022 21:33:51 +0800 Subject: [PATCH 22/27] fix merge equal --- .../src/compress/optimize/switches.rs | 36 +++++++++---------- .../8a28b14e.d8fbda268ed281a1/output.js | 14 ++++---- .../simple/switch/merge/non-const/output.js | 2 +- .../2c796e83-0724e2af5f19128a/output.js | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 629475938f05..77e199ca607a 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -243,18 +243,6 @@ where /// without break case order, except the break statement, we merge /// them. fn merge_cases_with_same_cons(&mut self, cases: &mut Vec) { - let boundary: Vec = cases - .iter() - .enumerate() - .map(|(idx, case)| { - case.test - .as_deref() - .map(|test| is_primitive(test).is_none()) - .unwrap_or(false) - || !(case.cons.is_empty() || case.cons.terminates() || idx == cases.len() - 1) - }) - .collect(); - let mut i = 0; let len = cases.len(); @@ -264,16 +252,29 @@ where i += 1; continue; } - - let mut cannot_cross = false; + let mut block_start = i + 1; + let mut cannot_cross_block = false; for j in (i + 1)..len { - // TODO: default - cannot_cross |= boundary[j]; + cannot_cross_block |= cases[j] + .test + .as_deref() + .map(|test| is_primitive(test).is_none()) + .unwrap_or(false) + || !(cases[j].cons.is_empty() + || cases[j].cons.terminates() + || j == cases.len() - 1); + if cases[j].cons.is_empty() { continue; } + if cannot_cross_block && block_start != i + 1 { + break; + } + + block_start = j + 1; + // first case with a body and don't cross non-primitive branch let found = if j != len - 1 { cases[i].cons.eq_ignore_span(&cases[j].cons) @@ -296,9 +297,6 @@ where cases[(i + 1)..=j].rotate_right(len); i += len; } - if cannot_cross { - break; - } } i += 1; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js index 4423ed8b24e6..37e57b5229c3 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 @@ -2445,11 +2445,6 @@ switch(cType){ case 0: case 1: - case 13: - case 14: - case 16: - case 17: - case 15: lastArabic = !1; case 4: case 3: @@ -2459,7 +2454,6 @@ case 7: return lastArabic = !0, hasUBAT_AL = !0, 1; case 8: - case 18: return 4; case 9: if (ix < 1 || ix + 1 >= types.length || 2 != (wType = classes[ix - 1]) && 3 != wType || 2 != (nType = types[ix + 1]) && 3 != nType) return 4; @@ -2485,6 +2479,14 @@ return lastArabic = !1, hasUBAT_B = !0, dir; case 6: return hasUBAT_S = !0, 4; + case 13: + case 14: + case 16: + case 17: + case 15: + lastArabic = !1; + case 18: + return 4; } } function _getCharacterType(ch) { diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/output.js b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/output.js index c819d2ce088b..f3ef1bdd8ffe 100644 --- a/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/simple/switch/merge/non-const/output.js @@ -1,4 +1,4 @@ -switch (a) { +switch(a){ case 1: console.log(1); break; 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 1d5a17c86f1a..49288085f593 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js @@ -1,4 +1,4 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(b,c,a){var d=a(3454);!function(c,a){b.exports=a()}(this,function(){"use strict";var c,e,b;function a(g,a){if(c){if(e){var f="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+c+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",d={};c(d),b=a(d),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(b.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else e=a}else c=a}return a(["exports"],function(a){"use strict";var bq="2.7.0",eG=H;function H(a,c,d,b){this.cx=3*a,this.bx=3*(d-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*c,this.by=3*(b-c)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=b,this.p2x=d,this.p2y=b}H.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},H.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},H.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},H.prototype.solveCurveX=function(c,e){var b,d,a,f,g;for(void 0===e&&(e=1e-6),a=c,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(a)-c)Math.abs(h))break;a-=f/h}if((a=c)<(b=0))return b;if(a>(d=1))return d;for(;bf?b=a:d=a,a=.5*(d-b)+b}return a},H.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var aF=aG;function aG(a,b){this.x=a,this.y=b}aG.prototype={clone:function(){return new aG(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(b,a){var c=Math.cos(b),d=Math.sin(b),e=a.y+d*(this.x-a.x)+c*(this.y-a.y);return this.x=a.x+c*(this.x-a.x)-d*(this.y-a.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},aG.convert=function(a){return a instanceof aG?a:Array.isArray(a)?new aG(a[0],a[1]):a};var s="undefined"!=typeof self?self:{},I="undefined"!=typeof Float32Array?Float32Array:Array;function aH(){var a=new I(9);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function aI(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function aJ(a,b,c){var h=b[0],i=b[1],j=b[2],k=b[3],l=b[4],m=b[5],n=b[6],o=b[7],p=b[8],q=b[9],r=b[10],s=b[11],t=b[12],u=b[13],v=b[14],w=b[15],d=c[0],e=c[1],f=c[2],g=c[3];return a[0]=d*h+e*l+f*p+g*t,a[1]=d*i+e*m+f*q+g*u,a[2]=d*j+e*n+f*r+g*v,a[3]=d*k+e*o+f*s+g*w,a[4]=(d=c[4])*h+(e=c[5])*l+(f=c[6])*p+(g=c[7])*t,a[5]=d*i+e*m+f*q+g*u,a[6]=d*j+e*n+f*r+g*v,a[7]=d*k+e*o+f*s+g*w,a[8]=(d=c[8])*h+(e=c[9])*l+(f=c[10])*p+(g=c[11])*t,a[9]=d*i+e*m+f*q+g*u,a[10]=d*j+e*n+f*r+g*v,a[11]=d*k+e*o+f*s+g*w,a[12]=(d=c[12])*h+(e=c[13])*l+(f=c[14])*p+(g=c[15])*t,a[13]=d*i+e*m+f*q+g*u,a[14]=d*j+e*n+f*r+g*v,a[15]=d*k+e*o+f*s+g*w,a}function br(b,a,f){var r,g,h,i,j,k,l,m,n,o,p,q,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[1],h=a[2],i=a[3],j=a[4],k=a[5],l=a[6],m=a[7],n=a[8],o=a[9],p=a[10],q=a[11],b[0]=r=a[0],b[1]=g,b[2]=h,b[3]=i,b[4]=j,b[5]=k,b[6]=l,b[7]=m,b[8]=n,b[9]=o,b[10]=p,b[11]=q,b[12]=r*c+j*d+n*e+a[12],b[13]=g*c+k*d+o*e+a[13],b[14]=h*c+l*d+p*e+a[14],b[15]=i*c+m*d+q*e+a[15]),b}function bs(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function bt(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*d+j*c,a[5]=g*d+k*c,a[6]=h*d+l*c,a[7]=i*d+m*c,a[8]=j*d-f*c,a[9]=k*d-g*c,a[10]=l*d-h*c,a[11]=m*d-i*c,a}function bu(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d-j*c,a[1]=g*d-k*c,a[2]=h*d-l*c,a[3]=i*d-m*c,a[8]=f*c+j*d,a[9]=g*c+k*d,a[10]=h*c+l*d,a[11]=i*c+m*d,a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)});var bv=aJ;function aK(){var a=new I(3);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function eH(b){var a=new I(3);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a}function aL(a){return Math.hypot(a[0],a[1],a[2])}function Q(b,c,d){var a=new I(3);return a[0]=b,a[1]=c,a[2]=d,a}function bw(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function aM(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function aN(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function eI(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function bx(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function by(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function bz(c,a){var d=a[0],e=a[1],f=a[2],b=d*d+e*e+f*f;return b>0&&(b=1/Math.sqrt(b)),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function bA(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function bB(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function bC(b,g,a){var c=g[0],d=g[1],e=g[2],f=a[3]*c+a[7]*d+a[11]*e+a[15];return b[0]=(a[0]*c+a[4]*d+a[8]*e+a[12])/(f=f||1),b[1]=(a[1]*c+a[5]*d+a[9]*e+a[13])/f,b[2]=(a[2]*c+a[6]*d+a[10]*e+a[14])/f,b}function bD(a,h,b){var c=b[0],d=b[1],e=b[2],i=h[0],j=h[1],k=h[2],l=d*k-e*j,f=e*i-c*k,g=c*j-d*i,p=d*g-e*f,n=e*l-c*g,o=c*f-d*l,m=2*b[3];return f*=m,g*=m,n*=2,o*=2,a[0]=i+(l*=m)+(p*=2),a[1]=j+f+n,a[2]=k+g+o,a}var J,bE=aM;function bF(b,c,a){var d=c[0],e=c[1],f=c[2],g=c[3];return b[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*g,b[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*g,b[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*g,b[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*g,b}function aO(){var a=new I(4);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function bG(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function bH(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+i*c,a[1]=g*d+h*c,a[2]=h*d-g*c,a[3]=i*d-f*c,a}function eJ(a,b){return a[0]===b[0]&&a[1]===b[1]}aK(),J=new I(4),I!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0,J[3]=0),aK(),Q(1,0,0),Q(0,1,0),aO(),aO(),aH(),ll=new I(2),I!=Float32Array&&(ll[0]=0,ll[1]=0);const aP=Math.PI/180,eK=180/Math.PI;function bI(a){return a*aP}function bJ(a){return a*eK}const eL=[[0,0],[1,0],[1,1],[0,1]];function bK(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function aQ(a,b,c,d){const e=new eG(a,b,c,d);return function(a){return e.solve(a)}}const bL=aQ(.25,.1,.25,1);function bM(a,b,c){return Math.min(c,Math.max(b,a))}function bN(b,c,a){return(a=bM((a-b)/(c-b),0,1))*a*(3-2*a)}function bO(e,a,c){const b=c-a,d=((e-a)%b+b)%b+a;return d===a?c:d}function bP(a,c,b){if(!a.length)return b(null,[]);let d=a.length;const e=new Array(a.length);let f=null;a.forEach((a,g)=>{c(a,(a,c)=>{a&&(f=a),e[g]=c,0== --d&&b(f,e)})})}function bQ(a){const b=[];for(const c in a)b.push(a[c]);return b}function bR(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}let eM=1;function bS(){return eM++}function eN(){return function b(a){return a?(a^16*Math.random()>>a/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,b)}()}function bT(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function eO(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function bU(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function bV(a,b){return -1!==a.indexOf(b,a.length-b.length)}function eP(a,d,e){const c={};for(const b in a)c[b]=d.call(e||this,a[b],b,a);return c}function bW(a,d,e){const c={};for(const b in a)d.call(e||this,a[b],b,a)&&(c[b]=a[b]);return c}function bX(a){return Array.isArray(a)?a.map(bX):"object"==typeof a&&a?eP(a,bX):a}const eQ={};function bY(a){eQ[a]||("undefined"!=typeof console&&console.warn(a),eQ[a]=!0)}function eR(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function eS(a){let e=0;for(let b,c,d=0,f=a.length,g=f-1;d@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,c,d,e)=>{const b=d||e;return a[c]=!b||b.toLowerCase(),""}),a["max-age"]){const b=parseInt(a["max-age"],10);isNaN(b)?delete a["max-age"]:a["max-age"]=b}return a}let eU,af,eV,eW=null;function eX(b){if(null==eW){const a=b.navigator?b.navigator.userAgent:null;eW=!!b.safari||!(!a||!(/\b(iPad|iPhone|iPod)\b/.test(a)||a.match("Safari")&&!a.match("Chrome")))}return eW}function eY(b){try{const a=s[b];return a.setItem("_mapbox_test_",1),a.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const b$={now:()=>void 0!==eV?eV:s.performance.now(),setNow(a){eV=a},restoreNow(){eV=void 0},frame(a){const b=s.requestAnimationFrame(a);return{cancel:()=>s.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=s.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(eU||(eU=s.document.createElement("a")),eU.href=a,eU.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==af&&(af=s.matchMedia("(prefers-reduced-motion: reduce)")),af.matches)}};let R;const b_={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==R){const aR=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R=null!=d.env.API_URL_REGEX?new RegExp(d.env.API_URL_REGEX):aR}catch(eZ){R=aR}}return R},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},b0={supported:!1,testSupport:function(a){!e_&&ag&&(e0?e1(a):e$=a)}};let e$,ag,e_=!1,e0=!1;function e1(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,ag),a.isContextLost())return;b0.supported=!0}catch(c){}a.deleteTexture(b),e_=!0}s.document&&((ag=s.document.createElement("img")).onload=function(){e$&&e1(e$),e$=null,e0=!0},ag.onerror=function(){e_=!0,e$=null},ag.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const b1="NO_ACCESS_TOKEN";function b2(a){return 0===a.indexOf("mapbox:")}function e2(a){return b_.API_URL_REGEX.test(a)}const e3=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function e4(b){const a=b.match(e3);if(!a)throw new Error("Unable to parse URL object");return{protocol:a[1],authority:a[2],path:a[3]||"/",params:a[4]?a[4].split("&"):[]}}function e5(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function e6(b){if(!b)return null;const a=b.split(".");if(!a||3!==a.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(a[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class e7{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(c){const a=e6(b_.ACCESS_TOKEN);let b="";return b=a&&a.u?s.btoa(encodeURIComponent(a.u).replace(/%([0-9A-F]{2})/g,(b,a)=>String.fromCharCode(Number("0x"+a)))):b_.ACCESS_TOKEN||"",c?`mapbox.eventData.${c}:${b}`:`mapbox.eventData:${b}`}fetchEventData(){const c=eY("localStorage"),d=this.getStorageKey(),e=this.getStorageKey("uuid");if(c)try{const a=s.localStorage.getItem(d);a&&(this.eventData=JSON.parse(a));const b=s.localStorage.getItem(e);b&&(this.anonId=b)}catch(f){bY("Unable to read from LocalStorage")}}saveEventData(){const a=eY("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{s.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){bY("Unable to write to LocalStorage")}}processRequests(a){}postEvent(d,a,h,e){if(!b_.EVENTS_URL)return;const b=e4(b_.EVENTS_URL);b.params.push(`access_token=${e||b_.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(d).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:bq,skuId:"01",userId:this.anonId},f=a?bR(c,a):c,g={url:e5(b),headers:{"Content-Type":"text/plain"},body:JSON.stringify([f])};this.pendingRequest=fj(g,a=>{this.pendingRequest=null,h(a),this.saveEventData(),this.processRequests(e)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const aS=new class extends e7{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){b_.EVENTS_URL&&b_.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>b2(a)||e2(a))&&this.queueRequest(Date.now(),b)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const c=e6(b_.ACCESS_TOKEN),f=c?c.u:b_.ACCESS_TOKEN;let a=f!==this.eventData.tokenU;eO(this.anonId)||(this.anonId=eN(),a=!0);const b=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(b),d=(b-this.eventData.lastSuccess)/864e5;a=a||d>=1||d< -1||g.getDate()!==h.getDate()}else a=!0;if(!a)return this.processRequests();this.postEvent(b,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=b,this.eventData.tokenU=f)},e)}},b3=aS.postTurnstileEvent.bind(aS),aT=new class extends e7{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.EVENTS_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||(this.anonId||this.fetchEventData(),eO(this.anonId)||(this.anonId=eN()),this.postEvent(c,{skuToken:this.skuToken},b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b))}},b4=aT.postMapLoadEvent.bind(aT),aU=new class extends e7{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,b,f,c){if(!b_.API_URL||!b_.SESSION_PATH)return;const a=e4(b_.API_URL+b_.SESSION_PATH);a.params.push(`sku=${b||""}`),a.params.push(`access_token=${c||b_.ACCESS_TOKEN||""}`);const d={url:e5(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=fk(d,a=>{this.pendingRequest=null,f(a),this.saveEventData(),this.processRequests(c)})}getSessionAPI(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.SESSION_PATH&&b_.API_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||this.getSession(c,this.skuToken,b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b)}},b5=aU.getSessionAPI.bind(aU),e8=new Set,e9="mapbox-tiles";let fa,fb,fc=500,fd=50;function fe(){s.caches&&!fa&&(fa=s.caches.open(e9))}function ff(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let fg=1/0;const aV={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(aV);class fh extends Error{constructor(a,b,c){401===b&&e2(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const b6=bZ()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,b7=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(b6())&&!/^\w+:/.test(c))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return function(a,g){var c;const e=new s.AbortController,b=new s.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:b6(),signal:e.signal});let h=!1,i=!1;const f=(c=b.url).indexOf("sku=")>0&&e2(c);"json"===a.type&&b.headers.set("Accept","application/json");const d=(c,d,e)=>{if(i)return;if(c&&"SecurityError"!==c.message&&bY(c),d&&e)return j(d);const h=Date.now();s.fetch(b).then(b=>{if(b.ok){const c=f?b.clone():null;return j(b,c,h)}return g(new fh(b.statusText,b.status,a.url))}).catch(a=>{20!==a.code&&g(new Error(a.message))})},j=(c,d,e)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{i||(d&&e&&function(e,a,c){if(fe(),!fa)return;const d={status:a.status,statusText:a.statusText,headers:new s.Headers};a.headers.forEach((a,b)=>d.headers.set(b,a));const b=eT(a.headers.get("Cache-Control")||"");b["no-store"]||(b["max-age"]&&d.headers.set("Expires",new Date(c+1e3*b["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||function(a,b){if(void 0===fb)try{new Response(new ReadableStream),fb=!0}catch(c){fb=!1}fb?b(a.body):a.blob().then(b)}(a,a=>{const b=new s.Response(a,d);fe(),fa&&fa.then(a=>a.put(ff(e.url),b)).catch(a=>bY(a.message))}))}(b,d,e),h=!0,g(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{i||g(new Error(a.message))})};return f?function(b,a){if(fe(),!fa)return a(null);const c=ff(b.url);fa.then(b=>{b.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=eT(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);b.delete(c),e&&b.put(c,d.clone()),a(null,d,e)}).catch(a)}).catch(a)}(b,d):d(null,null),{cancel(){i=!0,h||e.abort()}}}(a,b);if(bZ()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return function(b,d){const a=new s.XMLHttpRequest;for(const c in a.open(b.method||"GET",b.url,!0),"arrayBuffer"===b.type&&(a.responseType="arraybuffer"),b.headers)a.setRequestHeader(c,b.headers[c]);return"json"===b.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===b.credentials,a.onerror=()=>{d(new Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let c=a.response;if("json"===b.type)try{c=JSON.parse(a.response)}catch(e){return d(e)}d(null,c,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else d(new fh(a.statusText,a.status,b.url))},a.send(b.body),{cancel:()=>a.abort()}}(a,b)},fi=function(a,b){return b7(bR(a,{type:"arrayBuffer"}),b)},fj=function(a,b){return b7(bR(a,{method:"POST"}),b)},fk=function(a,b){return b7(bR(a,{method:"GET"}),b)};function fl(b){const a=s.document.createElement("a");return a.href=b,a.protocol===s.document.location.protocol&&a.host===s.document.location.host}const fm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let b8,b9;b8=[],b9=0;const ca=function(a,c){if(b0.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),b9>=b_.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:a,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return b8.push(b),b}b9++;let d=!1;const e=()=>{if(!d)for(d=!0,b9--;b8.length&&b9{e(),b?c(b):a&&(s.createImageBitmap?function(a,c){const b=new s.Blob([new Uint8Array(a)],{type:"image/png"});s.createImageBitmap(b).then(a=>{c(null,a)}).catch(a=>{c(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(a,(a,b)=>c(a,b,d,f)):function(b,e){const a=new s.Image,c=s.URL;a.onload=()=>{e(null,a),c.revokeObjectURL(a.src),a.onload=null,s.requestAnimationFrame(()=>{a.src=fm})},a.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const d=new s.Blob([new Uint8Array(b)],{type:"image/png"});a.src=b.byteLength?c.createObjectURL(d):fm}(a,(a,b)=>c(a,b,d,f)))});return{cancel(){f.cancel(),e()}}};function fn(a,c,b){b[a]&& -1!==b[a].indexOf(c)||(b[a]=b[a]||[],b[a].push(c))}function fo(b,d,a){if(a&&a[b]){const c=a[b].indexOf(d);-1!==c&&a[b].splice(c,1)}}class aW{constructor(a,b={}){bR(this,b),this.type=a}}class cb extends aW{constructor(a,b={}){super("error",bR({error:a},b))}}class S{on(a,b){return this._listeners=this._listeners||{},fn(a,b,this._listeners),this}off(a,b){return fo(a,b,this._listeners),fo(a,b,this._oneTimeListeners),this}once(b,a){return a?(this._oneTimeListeners=this._oneTimeListeners||{},fn(b,a,this._oneTimeListeners),this):new Promise(a=>this.once(b,a))}fire(a,e){"string"==typeof a&&(a=new aW(a,e||{}));const b=a.type;if(this.listens(b)){a.target=this;const f=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const g of f)g.call(this,a);const h=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const c of h)fo(b,c,this._oneTimeListeners),c.call(this,a);const d=this._eventedParent;d&&(bR(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(a))}else a instanceof cb&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var b=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class cc{constructor(b,a,d,c){this.message=(b?`${b}: `:"")+d,c&&(this.identifier=c),null!=a&&a.__line__&&(this.line=a.__line__)}}function cd(a){const b=a.value;return b?[new cc(a.key,b,"constants have been deprecated as of v8")]:[]}function ce(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}function fp(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function fq(a){if(Array.isArray(a))return a.map(fq);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=fq(a[c]);return b}return fp(a)}class fr extends Error{constructor(b,a){super(a),this.message=a,this.key=b}}class fs{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new fs(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw new Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const cf={kind:"null"},f={kind:"number"},i={kind:"string"},h={kind:"boolean"},y={kind:"color"},K={kind:"object"},l={kind:"value"},cg={kind:"collator"},ch={kind:"formatted"},ci={kind:"resolvedImage"};function z(a,b){return{kind:"array",itemType:a,N:b}}function ft(a){if("array"===a.kind){const b=ft(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const fu=[cf,f,i,h,y,ch,K,z(l),ci];function fv(b,a){if("error"===a.kind)return null;if("array"===b.kind){if("array"===a.kind&&(0===a.N&&"value"===a.itemType.kind||!fv(b.itemType,a.itemType))&&("number"!=typeof b.N||b.N===a.N))return null}else{if(b.kind===a.kind)return null;if("value"===b.kind){for(const c of fu)if(!fv(c,a))return null}}return`Expected ${ft(b)} but found ${ft(a)} instead.`}function fw(b,a){return a.some(a=>a.kind===b.kind)}function fx(b,a){return a.some(a=>"null"===a?null===b:"array"===a?Array.isArray(b):"object"===a?b&&!Array.isArray(b)&&"object"==typeof b:a===typeof b)}function ah(b){var a={exports:{}};return b(a,a.exports),a.exports}var fy=ah(function(b,a){var c={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(b,c,a){return a<0?a+=1:a>1&&(a-=1),6*a<1?b+(c-b)*a*6:2*a<1?c:3*a<2?b+(c-b)*(2/3-a)*6:b}try{a.parseCSSColor=function(q){var a,b=q.replace(/ /g,"").toLowerCase();if(b in c)return c[b].slice();if("#"===b[0])return 4===b.length?(a=parseInt(b.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===b.length&&(a=parseInt(b.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var j=b.indexOf("("),p=b.indexOf(")");if(-1!==j&&p+1===b.length){var r=b.substr(0,j),h=b.substr(j+1,p-(j+1)).split(","),l=1;switch(r){case"rgba":case"hsla":if(4!==h.length)return null;l=f(h.pop());case"rgb":return 3!==h.length?null:[e(h[0]),e(h[1]),e(h[2]),l];case"hsl":if(3!==h.length)return null;var m=(parseFloat(h[0])%360+360)%360/360,n=f(h[1]),i=f(h[2]),k=i<=.5?i*(n+1):i+n-i*n,o=2*i-k;return[d(255*g(o,k,m+1/3)),d(255*g(o,k,m)),d(255*g(o,k,m-1/3)),l];default:return null}}return null}}catch(h){}});class m{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(b){if(!b)return;if(b instanceof m)return b;if("string"!=typeof b)return;const a=fy.parseCSSColor(b);return a?new m(a[0]/255*a[3],a[1]/255*a[3],a[2]/255*a[3],a[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:b,g:c,b:d,a:a}=this;return 0===a?[0,0,0,0]:[255*b/a,255*c/a,255*d/a,a]}}m.black=new m(0,0,0,1),m.white=new m(1,1,1,1),m.transparent=new m(0,0,0,0),m.red=new m(1,0,0,1),m.blue=new m(0,0,1,1);class fz{constructor(b,a,c){this.sensitivity=b?a?"variant":"case":a?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class fA{constructor(a,b,c,d,e){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=e}}class fB{constructor(a){this.sections=a}static fromString(a){return new fB([new fA(a,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof fB?a:fB.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const b=["format"];for(const a of this.sections){if(a.image){b.push(["image",a.image.name]);continue}b.push(a.text);const c={};a.fontStack&&(c["text-font"]=["literal",a.fontStack.split(",")]),a.scale&&(c["font-scale"]=a.scale),a.textColor&&(c["text-color"]=["rgba"].concat(a.textColor.toArray())),b.push(c)}return b}}class cj{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new cj({name:a,available:!1}):null}serialize(){return["image",this.name]}}function fC(b,c,d,a){return"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof d&&d>=0&&d<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[b,c,d,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[b,c,d,a]:[b,c,d]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fD(a){if(null===a||"string"==typeof a||"boolean"==typeof a||"number"==typeof a||a instanceof m||a instanceof fz||a instanceof fB||a instanceof cj)return!0;if(Array.isArray(a)){for(const b of a)if(!fD(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!fD(a[c]))return!1;return!0}return!1}function fE(a){if(null===a)return cf;if("string"==typeof a)return i;if("boolean"==typeof a)return h;if("number"==typeof a)return f;if(a instanceof m)return y;if(a instanceof fz)return cg;if(a instanceof fB)return ch;if(a instanceof cj)return ci;if(Array.isArray(a)){const d=a.length;let b;for(const e of a){const c=fE(e);if(b){if(b===c)continue;b=l;break}b=c}return z(b||l,d)}return K}function fF(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof m||a instanceof fB||a instanceof cj?a.toString():JSON.stringify(a)}class ck{constructor(a,b){this.type=a,this.value=b}static parse(b,d){if(2!==b.length)return d.error(`'literal' expression requires exactly one argument, but found ${b.length-1} instead.`);if(!fD(b[1]))return d.error("invalid value");const e=b[1];let c=fE(e);const a=d.expectedType;return"array"===c.kind&&0===c.N&&a&&"array"===a.kind&&("number"!=typeof a.N||0===a.N)&&(c=a),new ck(c,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof m?["rgba"].concat(this.value.toArray()):this.value instanceof fB?this.value.serialize():this.value}}class fG{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const fH={string:i,number:f,boolean:h,object:K};class L{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");let e,b=1;const g=a[0];if("array"===g){let f,h;if(a.length>2){const d=a[1];if("string"!=typeof d||!(d in fH)||"object"===d)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=fH[d],b++}else f=l;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return c.error('The length argument to "array" must be a positive integer literal',2);h=a[2],b++}e=z(f,h)}else e=fH[g];const i=[];for(;ba.outputDefined())}serialize(){const a=this.type,c=[a.kind];if("array"===a.kind){const b=a.itemType;if("string"===b.kind||"number"===b.kind||"boolean"===b.kind){c.push(b.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&c.push(d)}}return c.concat(this.args.map(a=>a.serialize()))}}class cl{constructor(a){this.type=ch,this.sections=a}static parse(c,b){if(c.length<2)return b.error("Expected at least one argument.");const m=c[1];if(!Array.isArray(m)&&"object"==typeof m)return b.error("First argument must be an image or text section.");const d=[];let h=!1;for(let e=1;e<=c.length-1;++e){const a=c[e];if(h&&"object"==typeof a&&!Array.isArray(a)){h=!1;let n=null;if(a["font-scale"]&&!(n=b.parse(a["font-scale"],1,f)))return null;let o=null;if(a["text-font"]&&!(o=b.parse(a["text-font"],1,z(i))))return null;let p=null;if(a["text-color"]&&!(p=b.parse(a["text-color"],1,y)))return null;const j=d[d.length-1];j.scale=n,j.font=o,j.textColor=p}else{const k=b.parse(c[e],1,l);if(!k)return null;const g=k.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,d.push({content:k,scale:null,font:null,textColor:null})}}return new cl(d)}evaluate(a){return new fB(this.sections.map(b=>{const c=b.content.evaluate(a);return fE(c)===ci?new fA("",c,null,null,null):new fA(fF(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(b){for(const a of this.sections)b(a.content),a.scale&&b(a.scale),a.font&&b(a.font),a.textColor&&b(a.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const a of this.sections){c.push(a.content.serialize());const b={};a.scale&&(b["font-scale"]=a.scale.serialize()),a.font&&(b["text-font"]=a.font.serialize()),a.textColor&&(b["text-color"]=a.textColor.serialize()),c.push(b)}return c}}class cm{constructor(a){this.type=ci,this.input=a}static parse(b,a){if(2!==b.length)return a.error("Expected two arguments.");const c=a.parse(b[1],1,i);return c?new cm(c):a.error("No image name provided.")}evaluate(a){const c=this.input.evaluate(a),b=cj.fromString(c);return b&&a.availableImages&&(b.available=a.availableImages.indexOf(c)> -1),b}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const fI={"to-boolean":h,"to-color":y,"to-number":f,"to-string":i};class T{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");const d=a[0];if(("to-boolean"===d||"to-string"===d)&&2!==a.length)return c.error("Expected one argument.");const g=fI[d],e=[];for(let b=1;b4?`Invalid rbga value ${JSON.stringify(a)}: expected an array containing either three or four numeric values.`:fC(a[0],a[1],a[2],a[3])))return new m(a[0]/255,a[1]/255,a[2]/255,a[3])}throw new fG(c||`Could not parse color from value '${"string"==typeof a?a:String(JSON.stringify(a))}'`)}if("number"===this.type.kind){let d=null;for(const h of this.args){if(null===(d=h.evaluate(b)))return 0;const f=Number(d);if(!isNaN(f))return f}throw new fG(`Could not convert ${JSON.stringify(d)} to number.`)}return"formatted"===this.type.kind?fB.fromString(fF(this.args[0].evaluate(b))):"resolvedImage"===this.type.kind?cj.fromString(fF(this.args[0].evaluate(b))):fF(this.args[0].evaluate(b))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new cl([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new cm(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const fJ=["Unknown","Point","LineString","Polygon"];class fK{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?fJ[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=m.parse(a)),b}}class aX{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(f,c){const j=f[0],b=aX.definitions[j];if(!b)return c.error(`Unknown expression "${j}". If you wanted a literal array, use ["literal", [...]].`,0);const q=Array.isArray(b)?b[0]:b.type,m=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,h=m.filter(([a])=>!Array.isArray(a)||a.length===f.length-1);let e=null;for(const[a,r]of h){e=new f1(c.registry,c.path,null,c.scope);const d=[];let n=!1;for(let i=1;i{var a;return a=b,Array.isArray(a)?`(${a.map(ft).join(", ")})`:`(${ft(a.type)}...)`}).join(" | "),k=[];for(let l=1;l=b[2]||a[1]<=b[1]||a[3]>=b[3])}function fN(a,c){const d=(180+a[0])/360,e=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,b=Math.pow(2,c.z);return[Math.round(d*b*8192),Math.round(e*b*8192)]}function fO(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function fP(h,i){var d,b,e;let f=!1;for(let g=0,j=i.length;g(d=h)[1]!=(e=c[a+1])[1]>d[1]&&d[0]<(e[0]-b[0])*(d[1]-b[1])/(e[1]-b[1])+b[0]&&(f=!f)}}return f}function fQ(c,b){for(let a=0;a0&&h<0||g<0&&h>0}function fS(i,j,k){var a,b,c,d,g,h;for(const f of k)for(let e=0;eb[2]){const d=.5*c;let e=a[0]-b[0]>d?-c:b[0]-a[0]>d?c:0;0===e&&(e=a[0]-b[2]>d?-c:b[2]-a[0]>d?c:0),a[0]+=e}fL(f,a)}function fY(f,g,h,a){const i=8192*Math.pow(2,a.z),b=[8192*a.x,8192*a.y],c=[];for(const j of f)for(const d of j){const e=[d.x+b[0],d.y+b[1]];fX(e,g,h,i),c.push(e)}return c}function fZ(j,a,k,c){var b;const e=8192*Math.pow(2,c.z),f=[8192*c.x,8192*c.y],d=[];for(const l of j){const g=[];for(const h of l){const i=[h.x+f[0],h.y+f[1]];fL(a,i),g.push(i)}d.push(g)}if(a[2]-a[0]<=e/2)for(const m of((b=a)[0]=b[1]=1/0,b[2]=b[3]=-1/0,d))for(const n of m)fX(n,a,k,e);return d}class co{constructor(a,b){this.type=h,this.geojson=a,this.geometries=b}static parse(b,d){if(2!==b.length)return d.error(`'within' expression requires exactly one argument, but found ${b.length-1} instead.`);if(fD(b[1])){const a=b[1];if("FeatureCollection"===a.type)for(let c=0;c{b&&!f$(a)&&(b=!1)}),b}function f_(a){if(a instanceof aX&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!f_(a)&&(b=!1)}),b}function f0(a,b){if(a instanceof aX&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!f0(a,b)&&(c=!1)}),c}class cp{constructor(b,a){this.type=a.type,this.name=b,this.boundExpression=a}static parse(c,b){if(2!==c.length||"string"!=typeof c[1])return b.error("'var' expression requires exactly one string literal argument.");const a=c[1];return b.scope.has(a)?new cp(a,b.scope.get(a)):b.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class f1{constructor(b,a=[],c,d=new fs,e=[]){this.registry=b,this.path=a,this.key=a.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=e,this.expectedType=c}parse(a,b,d,e,c={}){return b?this.concat(b,d,e)._parse(a,c):this._parse(a,c)}_parse(a,f){function g(a,b,c){return"assert"===c?new L(b,[a]):"coerce"===c?new T(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[d];if(h){let b=h.parse(a,this);if(!b)return null;if(this.expectedType){const c=this.expectedType,e=b.type;if("string"!==c.kind&&"number"!==c.kind&&"boolean"!==c.kind&&"object"!==c.kind&&"array"!==c.kind||"value"!==e.kind){if("color"!==c.kind&&"formatted"!==c.kind&&"resolvedImage"!==c.kind||"value"!==e.kind&&"string"!==e.kind){if(this.checkSubtype(c,e))return null}else b=g(b,c,f.typeAnnotation||"coerce")}else b=g(b,c,f.typeAnnotation||"assert")}if(!(b instanceof ck)&&"resolvedImage"!==b.type.kind&&f2(b)){const i=new fK;try{b=new ck(b.type,b.evaluate(i))}catch(j){return this.error(j.message),null}}return b}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof a} instead.`)}concat(a,c,b){const d="number"==typeof a?this.path.concat(a):this.path,e=b?this.scope.concat(b):this.scope;return new f1(this.registry,d,c||null,e,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new fr(c,a))}checkSubtype(b,c){const a=fv(b,c);return a&&this.error(a),a}}function f2(a){if(a instanceof cp)return f2(a.boundExpression);if(a instanceof aX&&"error"===a.name||a instanceof cn||a instanceof co)return!1;const c=a instanceof T||a instanceof L;let b=!0;return a.eachChild(a=>{b=c?b&&f2(a):b&&a instanceof ck}),!!b&&f$(a)&&f0(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function f3(b,c){const g=b.length-1;let d,h,e=0,f=g,a=0;for(;e<=f;)if(d=b[a=Math.floor((e+f)/2)],h=b[a+1],d<=c){if(a===g||cc))throw new fG("Input is not a number.");f=a-1}return 0}class cq{constructor(a,b,c){for(const[d,e]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(e)}static parse(b,a){if(b.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if((b.length-1)%2!=0)return a.error("Expected an even number of arguments.");const i=a.parse(b[1],1,f);if(!i)return null;const d=[];let e=null;a.expectedType&&"value"!==a.expectedType.kind&&(e=a.expectedType);for(let c=1;c=g)return a.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',j);const h=a.parse(k,l,e);if(!h)return null;e=e||h.type,d.push([g,h])}return new cq(e,i,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const e=b.length;return d>=b[e-1]?c[e-1].evaluate(a):c[f3(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const b=["step",this.input.serialize()];for(let a=0;a0&&b.push(this.labels[a]),b.push(this.outputs[a].serialize());return b}}function aY(b,c,a){return b*(1-a)+c*a}var f4=Object.freeze({__proto__:null,number:aY,color:function(a,b,c){var d,e,f,g,h,i,j,k,l,n,o,p;return new m((d=a.r,e=b.r,d*(1-(f=c))+e*f),(g=a.g,h=b.g,g*(1-(i=c))+h*i),(j=a.b,k=b.b,j*(1-(l=c))+k*l),(n=a.a,o=b.a,n*(1-(p=c))+o*p))},array:function(a,b,c){return a.map((f,g)=>{var a,d,e;return a=f,d=b[g],a*(1-(e=c))+d*e})}});const f5=4/29,aZ=6/29,f6=3*aZ*aZ,f7=Math.PI/180,f8=180/Math.PI;function f9(a){return a>.008856451679035631?Math.pow(a,1/3):a/f6+f5}function ga(a){return a>aZ?a*a*a:f6*(a-f5)}function gb(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function gc(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function cr(a){const b=gc(a.r),c=gc(a.g),d=gc(a.b),f=f9((.4124564*b+.3575761*c+.1804375*d)/.95047),e=f9((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*e-16,a:500*(f-e),b:200*(e-f9((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function cs(b){let a=(b.l+16)/116,c=isNaN(b.a)?a:a+b.a/500,d=isNaN(b.b)?a:a-b.b/200;return a=1*ga(a),c=.95047*ga(c),d=1.08883*ga(d),new m(gb(3.2404542*c-1.5371385*a-.4985314*d),gb(-0.969266*c+1.8760108*a+.041556*d),gb(.0556434*c-.2040259*a+1.0572252*d),b.alpha)}const ct={forward:cr,reverse:cs,interpolate:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o;return{l:(d=a.l,e=b.l,d*(1-(f=c))+e*f),a:(g=a.a,h=b.a,g*(1-(i=c))+h*i),b:(j=a.b,k=b.b,j*(1-(l=c))+k*l),alpha:(m=a.alpha,n=b.alpha,m*(1-(o=c))+n*o)}}},cu={forward:function(d){const{l:e,a:a,b:b}=cr(d),c=Math.atan2(b,a)*f8;return{h:c<0?c+360:c,c:Math.sqrt(a*a+b*b),l:e,alpha:d.a}},reverse:function(a){const b=a.h*f7,c=a.c;return cs({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){var d,e,f,g,h,i,j,k,l;return{h:function(b,c,d){const a=c-b;return b+d*(a>180||a< -180?a-360*Math.round(a/360):a)}(a.h,b.h,c),c:(d=a.c,e=b.c,d*(1-(f=c))+e*f),l:(g=a.l,h=b.l,g*(1-(i=c))+h*i),alpha:(j=a.alpha,k=b.alpha,j*(1-(l=c))+k*l)}}};var gd=Object.freeze({__proto__:null,lab:ct,hcl:cu});class ai{constructor(a,b,c,d,e){for(const[f,g]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],e))this.labels.push(f),this.outputs.push(g)}static interpolationFactor(a,d,e,f){let b=0;if("exponential"===a.name)b=ge(d,a.base,e,f);else if("linear"===a.name)b=ge(d,1,e,f);else if("cubic-bezier"===a.name){const c=a.controlPoints;b=new eG(c[0],c[1],c[2],c[3]).solve(ge(d,1,e,f))}return b}static parse(g,a){let[h,b,i,...j]=g;if(!Array.isArray(b)||0===b.length)return a.error("Expected an interpolation type expression.",1);if("linear"===b[0])b={name:"linear"};else if("exponential"===b[0]){const n=b[1];if("number"!=typeof n)return a.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:n}}else{if("cubic-bezier"!==b[0])return a.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const k=b.slice(1);if(4!==k.length||k.some(a=>"number"!=typeof a||a<0||a>1))return a.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:k}}}if(g.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${g.length-1}.`);if((g.length-1)%2!=0)return a.error("Expected an even number of arguments.");if(!(i=a.parse(i,2,f)))return null;const e=[];let c=null;"interpolate-hcl"===h||"interpolate-lab"===h?c=y:a.expectedType&&"value"!==a.expectedType.kind&&(c=a.expectedType);for(let d=0;d=l)return a.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const m=a.parse(p,q,c);if(!m)return null;c=c||m.type,e.push([l,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new ai(c,h,b,i,e):a.error(`Type ${ft(c)} is not interpolatable.`)}evaluate(b){const a=this.labels,c=this.outputs;if(1===a.length)return c[0].evaluate(b);const d=this.input.evaluate(b);if(d<=a[0])return c[0].evaluate(b);const i=a.length;if(d>=a[i-1])return c[i-1].evaluate(b);const e=f3(a,d),f=ai.interpolationFactor(this.interpolation,d,a[e],a[e+1]),g=c[e].evaluate(b),h=c[e+1].evaluate(b);return"interpolate"===this.operator?f4[this.type.kind.toLowerCase()](g,h,f):"interpolate-hcl"===this.operator?cu.reverse(cu.interpolate(cu.forward(g),cu.forward(h),f)):ct.reverse(ct.interpolate(ct.forward(g),ct.forward(h),f))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let b;b="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const c=[this.operator,b,this.input.serialize()];for(let a=0;afv(b,a.type));return new cv(h?l:a,c)}evaluate(d){let b,a=null,c=0;for(const e of this.args){if(c++,(a=e.evaluate(d))&&a instanceof cj&&!a.available&&(b||(b=a),a=null,c===this.args.length))return b;if(null!==a)break}return a}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cw{constructor(b,a){this.type=a.type,this.bindings=[].concat(b),this.result=a}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,c){if(a.length<4)return c.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const e=[];for(let b=1;b=b.length)throw new fG(`Array index out of bounds: ${a} > ${b.length-1}.`);if(a!==Math.floor(a))throw new fG(`Array index must be an integer, but found ${a} instead.`);return b[a]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class cy{constructor(a,b){this.type=h,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);return c&&d?fw(c.type,[h,i,f,cf,l])?new cy(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`):null}evaluate(c){const b=this.needle.evaluate(c),a=this.haystack.evaluate(c);if(!a)return!1;if(!fx(b,["boolean","string","number","null"]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(b))} instead.`);if(!fx(a,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(a))} instead.`);return a.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class cz{constructor(a,b,c){this.type=f,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);if(!c||!d)return null;if(!fw(c.type,[h,i,f,cf,l]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`);if(4===a.length){const e=b.parse(a[3],3,f);return e?new cz(c,d,e):null}return new cz(c,d)}evaluate(c){const a=this.needle.evaluate(c),b=this.haystack.evaluate(c);if(!fx(a,["boolean","string","number","null"]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(a))} instead.`);if(!fx(b,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(b))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(c);return b.indexOf(a,d)}return b.indexOf(a)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class cA{constructor(a,b,c,d,e,f){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=e,this.otherwise=f}static parse(b,c){if(b.length<5)return c.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if(b.length%2!=1)return c.error("Expected an even number of arguments.");let g,d;c.expectedType&&"value"!==c.expectedType.kind&&(d=c.expectedType);const j={},k=[];for(let e=2;eNumber.MAX_SAFE_INTEGER)return f.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof a&&Math.floor(a)!==a)return f.error("Numeric branch labels must be integer values.");if(g){if(f.checkSubtype(g,fE(a)))return null}else g=fE(a);if(void 0!==j[String(a)])return f.error("Branch labels must be unique.");j[String(a)]=k.length}const m=c.parse(o,e,d);if(!m)return null;d=d||m.type,k.push(m)}const i=c.parse(b[1],1,l);if(!i)return null;const n=c.parse(b[b.length-1],b.length-1,d);return n?"value"!==i.type.kind&&c.concat(1).checkSubtype(g,i.type)?null:new cA(g,d,i,j,k,n):null}evaluate(a){const b=this.input.evaluate(a);return(fE(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const b=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),c=[],e={};for(const a of h){const f=e[this.cases[a]];void 0===f?(e[this.cases[a]]=c.length,c.push([this.cases[a],[a]])):c[f][1].push(a)}const g=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,d]of c)b.push(1===d.length?g(d[0]):d.map(g)),b.push(this.outputs[i].serialize());return b.push(this.otherwise.serialize()),b}}class cB{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const f=[];for(let d=1;da.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cC{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,c){if(a.length<=2||a.length>=5)return c.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const b=c.parse(a[1],1,l),d=c.parse(a[2],2,f);if(!b||!d)return null;if(!fw(b.type,[z(l),i,l]))return c.error(`Expected first argument to be of type array or string, but found ${ft(b.type)} instead`);if(4===a.length){const e=c.parse(a[3],3,f);return e?new cC(b.type,b,d,e):null}return new cC(b.type,b,d)}evaluate(b){const a=this.input.evaluate(b),c=this.beginIndex.evaluate(b);if(!fx(a,["string","array"]))throw new fG(`Expected first argument to be of type array or string, but found ${ft(fE(a))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(b);return a.slice(c,d)}return a.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function gf(b,a){return"=="===b||"!="===b?"boolean"===a.kind||"string"===a.kind||"number"===a.kind||"null"===a.kind||"value"===a.kind:"string"===a.kind||"number"===a.kind||"value"===a.kind}function cD(d,a,b,c){return 0===c.compare(a,b)}function A(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(a,b,c){this.type=h,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(f,c){if(3!==f.length&&4!==f.length)return c.error("Expected two or three arguments.");const g=f[0];let a=c.parse(f[1],1,l);if(!a)return null;if(!gf(g,a.type))return c.concat(1).error(`"${g}" comparisons are not supported for type '${ft(a.type)}'.`);let b=c.parse(f[2],2,l);if(!b)return null;if(!gf(g,b.type))return c.concat(2).error(`"${g}" comparisons are not supported for type '${ft(b.type)}'.`);if(a.type.kind!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error(`Cannot compare types '${ft(a.type)}' and '${ft(b.type)}'.`);d&&("value"===a.type.kind&&"value"!==b.type.kind?a=new L(b.type,[a]):"value"!==a.type.kind&&"value"===b.type.kind&&(b=new L(a.type,[b])));let h=null;if(4===f.length){if("string"!==a.type.kind&&"string"!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error("Cannot use collator to compare non-string types.");if(!(h=c.parse(f[3],3,cg)))return null}return new e(a,b,h)}evaluate(e){const f=this.lhs.evaluate(e),g=this.rhs.evaluate(e);if(d&&this.hasUntypedArgument){const h=fE(f),i=fE(g);if(h.kind!==i.kind||"string"!==h.kind&&"number"!==h.kind)throw new fG(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${h.kind}, ${i.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const j=fE(f),k=fE(g);if("string"!==j.kind||"string"!==k.kind)return b(e,f,g)}return this.collator?c(e,f,g,this.collator.evaluate(e)):b(e,f,g)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const cE=A("==",function(c,a,b){return a===b},cD),cF=A("!=",function(c,a,b){return a!==b},function(d,a,b,c){return!cD(0,a,b,c)}),cG=A("<",function(c,a,b){return ac.compare(a,b)}),cH=A(">",function(c,a,b){return a>b},function(d,a,b,c){return c.compare(a,b)>0}),cI=A("<=",function(c,a,b){return a<=b},function(d,a,b,c){return 0>=c.compare(a,b)}),cJ=A(">=",function(c,a,b){return a>=b},function(d,a,b,c){return c.compare(a,b)>=0});class cK{constructor(a,b,c,d,e){this.type=i,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=e}static parse(c,b){if(3!==c.length)return b.error("Expected two arguments.");const d=b.parse(c[1],1,f);if(!d)return null;const a=c[2];if("object"!=typeof a||Array.isArray(a))return b.error("NumberFormat options argument must be an object.");let e=null;if(a.locale&&!(e=b.parse(a.locale,1,i)))return null;let g=null;if(a.currency&&!(g=b.parse(a.currency,1,i)))return null;let h=null;if(a["min-fraction-digits"]&&!(h=b.parse(a["min-fraction-digits"],1,f)))return null;let j=null;return!a["max-fraction-digits"]||(j=b.parse(a["max-fraction-digits"],1,f))?new cK(d,e,g,h,j):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a]}}class cL{constructor(a){this.type=f,this.input=a}static parse(b,c){if(2!==b.length)return c.error(`Expected 1 argument, but found ${b.length-1} instead.`);const a=c.parse(b[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?c.error(`Expected argument of type string or array, but found ${ft(a.type)} instead.`):new cL(a):null}evaluate(b){const a=this.input.evaluate(b);if("string"==typeof a||Array.isArray(a))return a.length;throw new fG(`Expected value to be of type string or array, but found ${ft(fE(a))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const U={"==":cE,"!=":cF,">":cH,"<":cG,">=":cJ,"<=":cI,array:L,at:cx,boolean:L,case:cB,coalesce:cv,collator:cn,format:cl,image:cm,in:cy,"index-of":cz,interpolate:ai,"interpolate-hcl":ai,"interpolate-lab":ai,length:cL,let:cw,literal:ck,match:cA,number:L,"number-format":cK,object:L,slice:cC,step:cq,string:L,"to-boolean":T,"to-color":T,"to-number":T,"to-string":T,var:cp,within:co};function a$(b,[c,d,e,f]){c=c.evaluate(b),d=d.evaluate(b),e=e.evaluate(b);const a=f?f.evaluate(b):1,g=fC(c,d,e,a);if(g)throw new fG(g);return new m(c/255*a,d/255*a,e/255*a,a)}function gg(b,c){const a=c[b];return void 0===a?null:a}function x(a){return{type:a}}function gh(a){return{result:"success",value:a}}function gi(a){return{result:"error",value:a}}function gj(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function gk(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function gl(a){return!!a.expression&&a.expression.interpolated}function gm(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function gn(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function go(a){return a}function gp(a,e){const r="color"===e.type,g=a.stops&&"object"==typeof a.stops[0][0],s=g||!(g|| void 0!==a.property),b=a.type||(gl(e)?"exponential":"interval");if(r&&((a=ce({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],m.parse(a[1])])),a.default=m.parse(a.default?a.default:e.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!gd[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let f,j,t;if("exponential"===b)f=gt;else if("interval"===b)f=gs;else if("categorical"===b){for(const k of(f=gr,j=Object.create(null),a.stops))j[k[0]]=k[1];t=typeof a.stops[0][0]}else{if("identity"!==b)throw new Error(`Unknown function type "${b}"`);f=gu}if(g){const c={},l=[];for(let h=0;ha[0]),evaluate:({zoom:b},c)=>gt({stops:n,base:a.base},e,b).evaluate(b,c)}}if(s){const q="exponential"===b?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:ai.interpolationFactor.bind(void 0,q),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:b})=>f(a,e,b,j,t)}}return{kind:"source",evaluate(d,b){const c=b&&b.properties?b.properties[a.property]:void 0;return void 0===c?gq(a.default,e.default):f(a,e,c,j,t)}}}function gq(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function gr(b,c,a,d,e){return gq(typeof a===e?d[a]:void 0,b.default,c.default)}function gs(a,d,b){if("number"!==gm(b))return gq(a.default,d.default);const c=a.stops.length;if(1===c||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[c-1][0])return a.stops[c-1][1];const e=f3(a.stops.map(a=>a[0]),b);return a.stops[e][1]}function gt(a,e,b){const h=void 0!==a.base?a.base:1;if("number"!==gm(b))return gq(a.default,e.default);const d=a.stops.length;if(1===d||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[d-1][0])return a.stops[d-1][1];const c=f3(a.stops.map(a=>a[0]),b),i=function(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}(b,h,a.stops[c][0],a.stops[c+1][0]),f=a.stops[c][1],j=a.stops[c+1][1];let g=f4[e.type]||go;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=gd[a.colorSpace];g=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),i))}return"function"==typeof f.evaluate?{evaluate(...a){const b=f.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return g(b,c,i)}}:g(f,j,i)}function gu(c,b,a){return"color"===b.type?a=m.parse(a):"formatted"===b.type?a=fB.fromString(a.toString()):"resolvedImage"===b.type?a=cj.fromString(a.toString()):gm(a)===b.type||"enum"===b.type&&b.values[a]||(a=void 0),gq(a,c.default,b.default)}aX.register(U,{error:[{kind:"error"},[i],(a,[b])=>{throw new fG(b.evaluate(a))}],typeof:[i,[l],(a,[b])=>ft(fE(b.evaluate(a)))],"to-rgba":[z(f,4),[y],(a,[b])=>b.evaluate(a).toArray()],rgb:[y,[f,f,f],a$],rgba:[y,[f,f,f,f],a$],has:{type:h,overloads:[[[i],(a,[d])=>{var b,c;return b=d.evaluate(a),c=a.properties(),b in c}],[[i,K],(a,[b,c])=>b.evaluate(a) in c.evaluate(a)]]},get:{type:l,overloads:[[[i],(a,[b])=>gg(b.evaluate(a),a.properties())],[[i,K],(a,[b,c])=>gg(b.evaluate(a),c.evaluate(a))]]},"feature-state":[l,[i],(a,[b])=>gg(b.evaluate(a),a.featureState||{})],properties:[K,[],a=>a.properties()],"geometry-type":[i,[],a=>a.geometryType()],id:[l,[],a=>a.id()],zoom:[f,[],a=>a.globals.zoom],pitch:[f,[],a=>a.globals.pitch||0],"distance-from-center":[f,[],a=>a.distanceFromCenter()],"heatmap-density":[f,[],a=>a.globals.heatmapDensity||0],"line-progress":[f,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[f,[],a=>a.globals.skyRadialProgress||0],accumulated:[l,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated],"+":[f,x(f),(b,c)=>{let a=0;for(const d of c)a+=d.evaluate(b);return a}],"*":[f,x(f),(b,c)=>{let a=1;for(const d of c)a*=d.evaluate(b);return a}],"-":{type:f,overloads:[[[f,f],(a,[b,c])=>b.evaluate(a)-c.evaluate(a)],[[f],(a,[b])=>-b.evaluate(a)]]},"/":[f,[f,f],(a,[b,c])=>b.evaluate(a)/c.evaluate(a)],"%":[f,[f,f],(a,[b,c])=>b.evaluate(a)%c.evaluate(a)],ln2:[f,[],()=>Math.LN2],pi:[f,[],()=>Math.PI],e:[f,[],()=>Math.E],"^":[f,[f,f],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a))],sqrt:[f,[f],(a,[b])=>Math.sqrt(b.evaluate(a))],log10:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10],ln:[f,[f],(a,[b])=>Math.log(b.evaluate(a))],log2:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2],sin:[f,[f],(a,[b])=>Math.sin(b.evaluate(a))],cos:[f,[f],(a,[b])=>Math.cos(b.evaluate(a))],tan:[f,[f],(a,[b])=>Math.tan(b.evaluate(a))],asin:[f,[f],(a,[b])=>Math.asin(b.evaluate(a))],acos:[f,[f],(a,[b])=>Math.acos(b.evaluate(a))],atan:[f,[f],(a,[b])=>Math.atan(b.evaluate(a))],min:[f,x(f),(b,a)=>Math.min(...a.map(a=>a.evaluate(b)))],max:[f,x(f),(b,a)=>Math.max(...a.map(a=>a.evaluate(b)))],abs:[f,[f],(a,[b])=>Math.abs(b.evaluate(a))],round:[f,[f],(b,[c])=>{const a=c.evaluate(b);return a<0?-Math.round(-a):Math.round(a)}],floor:[f,[f],(a,[b])=>Math.floor(b.evaluate(a))],ceil:[f,[f],(a,[b])=>Math.ceil(b.evaluate(a))],"filter-==":[h,[i,l],(a,[b,c])=>a.properties()[b.value]===c.value],"filter-id-==":[h,[l],(a,[b])=>a.id()===b.value],"filter-type-==":[h,[i],(a,[b])=>a.geometryType()===b.value],"filter-<":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a{const a=c.id(),b=d.value;return typeof a==typeof b&&a":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>b}],"filter-id->":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>b}],"filter-<=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<=b}],"filter-id-<=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<=b}],"filter->=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>=b}],"filter-id->=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>=b}],"filter-has":[h,[l],(a,[b])=>b.value in a.properties()],"filter-has-id":[h,[],a=>null!==a.id()&& void 0!==a.id()],"filter-type-in":[h,[z(i)],(a,[b])=>b.value.indexOf(a.geometryType())>=0],"filter-id-in":[h,[z(l)],(a,[b])=>b.value.indexOf(a.id())>=0],"filter-in-small":[h,[i,z(l)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0],"filter-in-large":[h,[i,z(l)],(b,[c,a])=>(function(d,e,b,c){for(;b<=c;){const a=b+c>>1;if(e[a]===d)return!0;e[a]>d?c=a-1:b=a+1}return!1})(b.properties()[c.value],a.value,0,a.value.length-1)],all:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0}]]},any:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)||c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1}]]},"!":[h,[h],(a,[b])=>!b.evaluate(a)],"is-supported-script":[h,[i],(a,[c])=>{const b=a.globals&&a.globals.isSupportedScript;return!b||b(c.evaluate(a))}],upcase:[i,[i],(a,[b])=>b.evaluate(a).toUpperCase()],downcase:[i,[i],(a,[b])=>b.evaluate(a).toLowerCase()],concat:[i,x(l),(b,a)=>a.map(a=>fF(a.evaluate(b))).join("")],"resolved-locale":[i,[cg],(a,[b])=>b.evaluate(a).resolvedLocale()]});class cM{constructor(c,b){var a;this.expression=c,this._warningHistory={},this._evaluator=new fK,this._defaultValue=b?"color"===(a=b).type&&gn(a.default)?new m(0,0,0,0):"color"===a.type?m.parse(a.default)||null:void 0===a.default?null:a.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,e,f,g,h){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=e||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=g||null,this._evaluator.featureDistanceData=h||null,this.expression.evaluate(this._evaluator)}evaluate(c,d,e,f,g,h,i,j){this._evaluator.globals=c,this._evaluator.feature=d||null,this._evaluator.featureState=e||null,this._evaluator.canonical=f,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=i||null,this._evaluator.featureDistanceData=j||null;try{const a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new fG(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(a)} instead.`);return a}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,"undefined"!=typeof console&&console.warn(b.message)),this._defaultValue}}}function gv(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in U}function cN(d,a){const b=new f1(U,[],a?function(a){const b={color:y,string:i,number:f,enum:i,boolean:h,formatted:ch,resolvedImage:ci};return"array"===a.type?z(b[a.value]||l,a.length):b[a.type]}(a):void 0),c=b.parse(d,void 0,void 0,void 0,a&&"string"===a.type?{typeAnnotation:"coerce"}:void 0);return c?gh(new cM(c,a)):gi(b.errors)}class cO{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!f_(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}}class cP{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!f_(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}interpolationFactor(a,b,c){return this.interpolationType?ai.interpolationFactor(this.interpolationType,a,b,c):0}}function gw(b,c){if("error"===(b=cN(b,c)).result)return b;const d=b.value.expression,e=f$(d);if(!e&&!gj(c))return gi([new fr("","data expressions not supported")]);const f=f0(d,["zoom","pitch","distance-from-center"]);if(!f&&!gk(c))return gi([new fr("","zoom expressions not supported")]);const a=gx(d);return a||f?a instanceof fr?gi([a]):a instanceof ai&&!gl(c)?gi([new fr("",'"interpolate" expressions cannot be used with this property')]):gh(a?new cP(e?"camera":"composite",b.value,a.labels,a instanceof ai?a.interpolation:void 0):new cO(e?"constant":"source",b.value)):gi([new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class cQ{constructor(a,b){this._parameters=a,this._specification=b,ce(this,gp(this._parameters,this._specification))}static deserialize(a){return new cQ(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function gx(a){let b=null;if(a instanceof cw)b=gx(a.result);else if(a instanceof cv){for(const c of a.args)if(b=gx(c))break}else(a instanceof cq||a instanceof ai)&&a.input instanceof aX&&"zoom"===a.input.name&&(b=a);return b instanceof fr||a.eachChild(c=>{const a=gx(c);a instanceof fr?b=a:!b&&a?b=new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):b&&a&&b!==a&&(b=new fr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),b}function cR(c){const d=c.key,a=c.value,b=c.valueSpec||{},f=c.objectElementValidators||{},l=c.style,m=c.styleSpec;let g=[];const k=gm(a);if("object"!==k)return[new cc(d,a,`object expected, ${k} found`)];for(const e in a){const j=e.split(".")[0],n=b[j]||b["*"];let h;if(f[j])h=f[j];else if(b[j])h=gR;else if(f["*"])h=f["*"];else{if(!b["*"]){g.push(new cc(d,a[e],`unknown property "${e}"`));continue}h=gR}g=g.concat(h({key:(d?`${d}.`:d)+e,value:a[e],valueSpec:n,style:l,styleSpec:m,object:a,objectKey:e},a))}for(const i in b)f[i]||b[i].required&& void 0===b[i].default&& void 0===a[i]&&g.push(new cc(d,a,`missing required property "${i}"`));return g}function cS(c){const b=c.value,a=c.valueSpec,i=c.style,h=c.styleSpec,e=c.key,j=c.arrayElementValidator||gR;if("array"!==gm(b))return[new cc(e,b,`array expected, ${gm(b)} found`)];if(a.length&&b.length!==a.length)return[new cc(e,b,`array length ${a.length} expected, length ${b.length} found`)];if(a["min-length"]&&b.lengthg)return[new cc(e,a,`${a} is greater than the maximum value ${g}`)]}return[]}function cU(a){const f=a.valueSpec,c=fp(a.value.type);let g,h,i,j={};const d="categorical"!==c&& void 0===a.value.property,e="array"===gm(a.value.stops)&&"array"===gm(a.value.stops[0])&&"object"===gm(a.value.stops[0][0]),b=cR({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(a){if("identity"===c)return[new cc(a.key,a.value,'identity function may not have a "stops" property')];let b=[];const d=a.value;return b=b.concat(cS({key:a.key,value:d,valueSpec:a.valueSpec,style:a.style,styleSpec:a.styleSpec,arrayElementValidator:k})),"array"===gm(d)&&0===d.length&&b.push(new cc(a.key,d,"array must have at least one stop")),b},default:function(a){return gR({key:a.key,value:a.value,valueSpec:f,style:a.style,styleSpec:a.styleSpec})}}});return"identity"===c&&d&&b.push(new cc(a.key,a.value,'missing required property "property"')),"identity"===c||a.value.stops||b.push(new cc(a.key,a.value,'missing required property "stops"')),"exponential"===c&&a.valueSpec.expression&&!gl(a.valueSpec)&&b.push(new cc(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(d||gj(a.valueSpec)?d&&!gk(a.valueSpec)&&b.push(new cc(a.key,a.value,"zoom functions not supported")):b.push(new cc(a.key,a.value,"property functions not supported"))),("categorical"===c||e)&& void 0===a.value.property&&b.push(new cc(a.key,a.value,'"property" property is required')),b;function k(c){let d=[];const a=c.value,b=c.key;if("array"!==gm(a))return[new cc(b,a,`array expected, ${gm(a)} found`)];if(2!==a.length)return[new cc(b,a,`array length 2 expected, length ${a.length} found`)];if(e){if("object"!==gm(a[0]))return[new cc(b,a,`object expected, ${gm(a[0])} found`)];if(void 0===a[0].zoom)return[new cc(b,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new cc(b,a,"object stop key must have value")];if(i&&i>fp(a[0].zoom))return[new cc(b,a[0].zoom,"stop zoom values must appear in ascending order")];fp(a[0].zoom)!==i&&(i=fp(a[0].zoom),h=void 0,j={}),d=d.concat(cR({key:`${b}[0]`,value:a[0],valueSpec:{zoom:{}},style:c.style,styleSpec:c.styleSpec,objectElementValidators:{zoom:cT,value:l}}))}else d=d.concat(l({key:`${b}[0]`,value:a[0],valueSpec:{},style:c.style,styleSpec:c.styleSpec},a));return gv(fq(a[1]))?d.concat([new cc(`${b}[1]`,a[1],"expressions are not allowed in function stops.")]):d.concat(gR({key:`${b}[1]`,value:a[1],valueSpec:f,style:c.style,styleSpec:c.styleSpec}))}function l(a,k){const b=gm(a.value),d=fp(a.value),e=null!==a.value?a.value:k;if(g){if(b!==g)return[new cc(a.key,e,`${b} stop domain type must match previous stop domain type ${g}`)]}else g=b;if("number"!==b&&"string"!==b&&"boolean"!==b)return[new cc(a.key,e,"stop domain value must be a number, string, or boolean")];if("number"!==b&&"categorical"!==c){let i=`number expected, ${b} found`;return gj(f)&& void 0===c&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new cc(a.key,e,i)]}return"categorical"!==c||"number"!==b||isFinite(d)&&Math.floor(d)===d?"categorical"!==c&&"number"===b&& void 0!==h&&dnew cc(`${a.key}${b.key}`,a.value,b.message));const b=c.value.expression||c.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!b.outputDefined())return[new cc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===a.expressionContext&&"layout"===a.propertyType&&!f_(b))return[new cc(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===a.expressionContext)return gz(b,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!f0(b,["zoom","feature-state"]))return[new cc(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===a.expressionContext&&!f$(b))return[new cc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function gz(b,a){const c=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const d of a.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return b instanceof aX&&c.has(b.name)?[new cc(a.key,a.value,`["${b.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`)]:(b.eachChild(b=>{e.push(...gz(b,a))}),e)}function cV(c){const e=c.key,a=c.value,b=c.valueSpec,d=[];return Array.isArray(b.values)?-1===b.values.indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${b.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(b.values).indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(a)} found`)),d}function gA(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!gA(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function gB(a,k="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};gA(a)||(a=gI(a));const c=a;let d=!0;try{d=function(a){if(!gE(a))return a;let b=fq(a);return gD(b),b=gC(b)}(c)}catch(l){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(b,c,a){var d=a(3454);!function(c,a){b.exports=a()}(this,function(){"use strict";var c,e,b;function a(g,a){if(c){if(e){var f="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+c+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",d={};c(d),b=a(d),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(b.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else e=a}else c=a}return a(["exports"],function(a){"use strict";var bq="2.7.0",eG=H;function H(a,c,d,b){this.cx=3*a,this.bx=3*(d-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*c,this.by=3*(b-c)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=b,this.p2x=d,this.p2y=b}H.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},H.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},H.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},H.prototype.solveCurveX=function(c,e){var b,d,a,f,g;for(void 0===e&&(e=1e-6),a=c,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(a)-c)Math.abs(h))break;a-=f/h}if((a=c)<(b=0))return b;if(a>(d=1))return d;for(;bf?b=a:d=a,a=.5*(d-b)+b}return a},H.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var aF=aG;function aG(a,b){this.x=a,this.y=b}aG.prototype={clone:function(){return new aG(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(b,a){var c=Math.cos(b),d=Math.sin(b),e=a.y+d*(this.x-a.x)+c*(this.y-a.y);return this.x=a.x+c*(this.x-a.x)-d*(this.y-a.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},aG.convert=function(a){return a instanceof aG?a:Array.isArray(a)?new aG(a[0],a[1]):a};var s="undefined"!=typeof self?self:{},I="undefined"!=typeof Float32Array?Float32Array:Array;function aH(){var a=new I(9);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function aI(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function aJ(a,b,c){var h=b[0],i=b[1],j=b[2],k=b[3],l=b[4],m=b[5],n=b[6],o=b[7],p=b[8],q=b[9],r=b[10],s=b[11],t=b[12],u=b[13],v=b[14],w=b[15],d=c[0],e=c[1],f=c[2],g=c[3];return a[0]=d*h+e*l+f*p+g*t,a[1]=d*i+e*m+f*q+g*u,a[2]=d*j+e*n+f*r+g*v,a[3]=d*k+e*o+f*s+g*w,a[4]=(d=c[4])*h+(e=c[5])*l+(f=c[6])*p+(g=c[7])*t,a[5]=d*i+e*m+f*q+g*u,a[6]=d*j+e*n+f*r+g*v,a[7]=d*k+e*o+f*s+g*w,a[8]=(d=c[8])*h+(e=c[9])*l+(f=c[10])*p+(g=c[11])*t,a[9]=d*i+e*m+f*q+g*u,a[10]=d*j+e*n+f*r+g*v,a[11]=d*k+e*o+f*s+g*w,a[12]=(d=c[12])*h+(e=c[13])*l+(f=c[14])*p+(g=c[15])*t,a[13]=d*i+e*m+f*q+g*u,a[14]=d*j+e*n+f*r+g*v,a[15]=d*k+e*o+f*s+g*w,a}function br(b,a,f){var r,g,h,i,j,k,l,m,n,o,p,q,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[1],h=a[2],i=a[3],j=a[4],k=a[5],l=a[6],m=a[7],n=a[8],o=a[9],p=a[10],q=a[11],b[0]=r=a[0],b[1]=g,b[2]=h,b[3]=i,b[4]=j,b[5]=k,b[6]=l,b[7]=m,b[8]=n,b[9]=o,b[10]=p,b[11]=q,b[12]=r*c+j*d+n*e+a[12],b[13]=g*c+k*d+o*e+a[13],b[14]=h*c+l*d+p*e+a[14],b[15]=i*c+m*d+q*e+a[15]),b}function bs(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function bt(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*d+j*c,a[5]=g*d+k*c,a[6]=h*d+l*c,a[7]=i*d+m*c,a[8]=j*d-f*c,a[9]=k*d-g*c,a[10]=l*d-h*c,a[11]=m*d-i*c,a}function bu(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d-j*c,a[1]=g*d-k*c,a[2]=h*d-l*c,a[3]=i*d-m*c,a[8]=f*c+j*d,a[9]=g*c+k*d,a[10]=h*c+l*d,a[11]=i*c+m*d,a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)});var bv=aJ;function aK(){var a=new I(3);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function eH(b){var a=new I(3);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a}function aL(a){return Math.hypot(a[0],a[1],a[2])}function Q(b,c,d){var a=new I(3);return a[0]=b,a[1]=c,a[2]=d,a}function bw(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function aM(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function aN(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function eI(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function bx(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function by(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function bz(c,a){var d=a[0],e=a[1],f=a[2],b=d*d+e*e+f*f;return b>0&&(b=1/Math.sqrt(b)),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function bA(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function bB(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function bC(b,g,a){var c=g[0],d=g[1],e=g[2],f=a[3]*c+a[7]*d+a[11]*e+a[15];return b[0]=(a[0]*c+a[4]*d+a[8]*e+a[12])/(f=f||1),b[1]=(a[1]*c+a[5]*d+a[9]*e+a[13])/f,b[2]=(a[2]*c+a[6]*d+a[10]*e+a[14])/f,b}function bD(a,h,b){var c=b[0],d=b[1],e=b[2],i=h[0],j=h[1],k=h[2],l=d*k-e*j,f=e*i-c*k,g=c*j-d*i,p=d*g-e*f,n=e*l-c*g,o=c*f-d*l,m=2*b[3];return f*=m,g*=m,n*=2,o*=2,a[0]=i+(l*=m)+(p*=2),a[1]=j+f+n,a[2]=k+g+o,a}var J,bE=aM;function bF(b,c,a){var d=c[0],e=c[1],f=c[2],g=c[3];return b[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*g,b[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*g,b[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*g,b[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*g,b}function aO(){var a=new I(4);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function bG(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function bH(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+i*c,a[1]=g*d+h*c,a[2]=h*d-g*c,a[3]=i*d-f*c,a}function eJ(a,b){return a[0]===b[0]&&a[1]===b[1]}aK(),J=new I(4),I!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0,J[3]=0),aK(),Q(1,0,0),Q(0,1,0),aO(),aO(),aH(),ll=new I(2),I!=Float32Array&&(ll[0]=0,ll[1]=0);const aP=Math.PI/180,eK=180/Math.PI;function bI(a){return a*aP}function bJ(a){return a*eK}const eL=[[0,0],[1,0],[1,1],[0,1]];function bK(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function aQ(a,b,c,d){const e=new eG(a,b,c,d);return function(a){return e.solve(a)}}const bL=aQ(.25,.1,.25,1);function bM(a,b,c){return Math.min(c,Math.max(b,a))}function bN(b,c,a){return(a=bM((a-b)/(c-b),0,1))*a*(3-2*a)}function bO(e,a,c){const b=c-a,d=((e-a)%b+b)%b+a;return d===a?c:d}function bP(a,c,b){if(!a.length)return b(null,[]);let d=a.length;const e=new Array(a.length);let f=null;a.forEach((a,g)=>{c(a,(a,c)=>{a&&(f=a),e[g]=c,0== --d&&b(f,e)})})}function bQ(a){const b=[];for(const c in a)b.push(a[c]);return b}function bR(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}let eM=1;function bS(){return eM++}function eN(){return function b(a){return a?(a^16*Math.random()>>a/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,b)}()}function bT(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function eO(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function bU(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function bV(a,b){return -1!==a.indexOf(b,a.length-b.length)}function eP(a,d,e){const c={};for(const b in a)c[b]=d.call(e||this,a[b],b,a);return c}function bW(a,d,e){const c={};for(const b in a)d.call(e||this,a[b],b,a)&&(c[b]=a[b]);return c}function bX(a){return Array.isArray(a)?a.map(bX):"object"==typeof a&&a?eP(a,bX):a}const eQ={};function bY(a){eQ[a]||("undefined"!=typeof console&&console.warn(a),eQ[a]=!0)}function eR(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function eS(a){let e=0;for(let b,c,d=0,f=a.length,g=f-1;d@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,c,d,e)=>{const b=d||e;return a[c]=!b||b.toLowerCase(),""}),a["max-age"]){const b=parseInt(a["max-age"],10);isNaN(b)?delete a["max-age"]:a["max-age"]=b}return a}let eU,af,eV,eW=null;function eX(b){if(null==eW){const a=b.navigator?b.navigator.userAgent:null;eW=!!b.safari||!(!a||!(/\b(iPad|iPhone|iPod)\b/.test(a)||a.match("Safari")&&!a.match("Chrome")))}return eW}function eY(b){try{const a=s[b];return a.setItem("_mapbox_test_",1),a.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const b$={now:()=>void 0!==eV?eV:s.performance.now(),setNow(a){eV=a},restoreNow(){eV=void 0},frame(a){const b=s.requestAnimationFrame(a);return{cancel:()=>s.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=s.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(eU||(eU=s.document.createElement("a")),eU.href=a,eU.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==af&&(af=s.matchMedia("(prefers-reduced-motion: reduce)")),af.matches)}};let R;const b_={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==R){const aR=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R=null!=d.env.API_URL_REGEX?new RegExp(d.env.API_URL_REGEX):aR}catch(eZ){R=aR}}return R},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},b0={supported:!1,testSupport:function(a){!e_&&ag&&(e0?e1(a):e$=a)}};let e$,ag,e_=!1,e0=!1;function e1(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,ag),a.isContextLost())return;b0.supported=!0}catch(c){}a.deleteTexture(b),e_=!0}s.document&&((ag=s.document.createElement("img")).onload=function(){e$&&e1(e$),e$=null,e0=!0},ag.onerror=function(){e_=!0,e$=null},ag.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const b1="NO_ACCESS_TOKEN";function b2(a){return 0===a.indexOf("mapbox:")}function e2(a){return b_.API_URL_REGEX.test(a)}const e3=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function e4(b){const a=b.match(e3);if(!a)throw new Error("Unable to parse URL object");return{protocol:a[1],authority:a[2],path:a[3]||"/",params:a[4]?a[4].split("&"):[]}}function e5(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function e6(b){if(!b)return null;const a=b.split(".");if(!a||3!==a.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(a[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class e7{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(c){const a=e6(b_.ACCESS_TOKEN);let b="";return b=a&&a.u?s.btoa(encodeURIComponent(a.u).replace(/%([0-9A-F]{2})/g,(b,a)=>String.fromCharCode(Number("0x"+a)))):b_.ACCESS_TOKEN||"",c?`mapbox.eventData.${c}:${b}`:`mapbox.eventData:${b}`}fetchEventData(){const c=eY("localStorage"),d=this.getStorageKey(),e=this.getStorageKey("uuid");if(c)try{const a=s.localStorage.getItem(d);a&&(this.eventData=JSON.parse(a));const b=s.localStorage.getItem(e);b&&(this.anonId=b)}catch(f){bY("Unable to read from LocalStorage")}}saveEventData(){const a=eY("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{s.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){bY("Unable to write to LocalStorage")}}processRequests(a){}postEvent(d,a,h,e){if(!b_.EVENTS_URL)return;const b=e4(b_.EVENTS_URL);b.params.push(`access_token=${e||b_.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(d).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:bq,skuId:"01",userId:this.anonId},f=a?bR(c,a):c,g={url:e5(b),headers:{"Content-Type":"text/plain"},body:JSON.stringify([f])};this.pendingRequest=fj(g,a=>{this.pendingRequest=null,h(a),this.saveEventData(),this.processRequests(e)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const aS=new class extends e7{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){b_.EVENTS_URL&&b_.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>b2(a)||e2(a))&&this.queueRequest(Date.now(),b)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const c=e6(b_.ACCESS_TOKEN),f=c?c.u:b_.ACCESS_TOKEN;let a=f!==this.eventData.tokenU;eO(this.anonId)||(this.anonId=eN(),a=!0);const b=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(b),d=(b-this.eventData.lastSuccess)/864e5;a=a||d>=1||d< -1||g.getDate()!==h.getDate()}else a=!0;if(!a)return this.processRequests();this.postEvent(b,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=b,this.eventData.tokenU=f)},e)}},b3=aS.postTurnstileEvent.bind(aS),aT=new class extends e7{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.EVENTS_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||(this.anonId||this.fetchEventData(),eO(this.anonId)||(this.anonId=eN()),this.postEvent(c,{skuToken:this.skuToken},b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b))}},b4=aT.postMapLoadEvent.bind(aT),aU=new class extends e7{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,b,f,c){if(!b_.API_URL||!b_.SESSION_PATH)return;const a=e4(b_.API_URL+b_.SESSION_PATH);a.params.push(`sku=${b||""}`),a.params.push(`access_token=${c||b_.ACCESS_TOKEN||""}`);const d={url:e5(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=fk(d,a=>{this.pendingRequest=null,f(a),this.saveEventData(),this.processRequests(c)})}getSessionAPI(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.SESSION_PATH&&b_.API_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||this.getSession(c,this.skuToken,b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b)}},b5=aU.getSessionAPI.bind(aU),e8=new Set,e9="mapbox-tiles";let fa,fb,fc=500,fd=50;function fe(){s.caches&&!fa&&(fa=s.caches.open(e9))}function ff(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let fg=1/0;const aV={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(aV);class fh extends Error{constructor(a,b,c){401===b&&e2(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const b6=bZ()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,b7=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(b6())&&!/^\w+:/.test(c))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return function(a,g){var c;const e=new s.AbortController,b=new s.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:b6(),signal:e.signal});let h=!1,i=!1;const f=(c=b.url).indexOf("sku=")>0&&e2(c);"json"===a.type&&b.headers.set("Accept","application/json");const d=(c,d,e)=>{if(i)return;if(c&&"SecurityError"!==c.message&&bY(c),d&&e)return j(d);const h=Date.now();s.fetch(b).then(b=>{if(b.ok){const c=f?b.clone():null;return j(b,c,h)}return g(new fh(b.statusText,b.status,a.url))}).catch(a=>{20!==a.code&&g(new Error(a.message))})},j=(c,d,e)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{i||(d&&e&&function(e,a,c){if(fe(),!fa)return;const d={status:a.status,statusText:a.statusText,headers:new s.Headers};a.headers.forEach((a,b)=>d.headers.set(b,a));const b=eT(a.headers.get("Cache-Control")||"");b["no-store"]||(b["max-age"]&&d.headers.set("Expires",new Date(c+1e3*b["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||function(a,b){if(void 0===fb)try{new Response(new ReadableStream),fb=!0}catch(c){fb=!1}fb?b(a.body):a.blob().then(b)}(a,a=>{const b=new s.Response(a,d);fe(),fa&&fa.then(a=>a.put(ff(e.url),b)).catch(a=>bY(a.message))}))}(b,d,e),h=!0,g(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{i||g(new Error(a.message))})};return f?function(b,a){if(fe(),!fa)return a(null);const c=ff(b.url);fa.then(b=>{b.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=eT(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);b.delete(c),e&&b.put(c,d.clone()),a(null,d,e)}).catch(a)}).catch(a)}(b,d):d(null,null),{cancel(){i=!0,h||e.abort()}}}(a,b);if(bZ()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return function(b,d){const a=new s.XMLHttpRequest;for(const c in a.open(b.method||"GET",b.url,!0),"arrayBuffer"===b.type&&(a.responseType="arraybuffer"),b.headers)a.setRequestHeader(c,b.headers[c]);return"json"===b.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===b.credentials,a.onerror=()=>{d(new Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let c=a.response;if("json"===b.type)try{c=JSON.parse(a.response)}catch(e){return d(e)}d(null,c,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else d(new fh(a.statusText,a.status,b.url))},a.send(b.body),{cancel:()=>a.abort()}}(a,b)},fi=function(a,b){return b7(bR(a,{type:"arrayBuffer"}),b)},fj=function(a,b){return b7(bR(a,{method:"POST"}),b)},fk=function(a,b){return b7(bR(a,{method:"GET"}),b)};function fl(b){const a=s.document.createElement("a");return a.href=b,a.protocol===s.document.location.protocol&&a.host===s.document.location.host}const fm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let b8,b9;b8=[],b9=0;const ca=function(a,c){if(b0.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),b9>=b_.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:a,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return b8.push(b),b}b9++;let d=!1;const e=()=>{if(!d)for(d=!0,b9--;b8.length&&b9{e(),b?c(b):a&&(s.createImageBitmap?function(a,c){const b=new s.Blob([new Uint8Array(a)],{type:"image/png"});s.createImageBitmap(b).then(a=>{c(null,a)}).catch(a=>{c(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(a,(a,b)=>c(a,b,d,f)):function(b,e){const a=new s.Image,c=s.URL;a.onload=()=>{e(null,a),c.revokeObjectURL(a.src),a.onload=null,s.requestAnimationFrame(()=>{a.src=fm})},a.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const d=new s.Blob([new Uint8Array(b)],{type:"image/png"});a.src=b.byteLength?c.createObjectURL(d):fm}(a,(a,b)=>c(a,b,d,f)))});return{cancel(){f.cancel(),e()}}};function fn(a,c,b){b[a]&& -1!==b[a].indexOf(c)||(b[a]=b[a]||[],b[a].push(c))}function fo(b,d,a){if(a&&a[b]){const c=a[b].indexOf(d);-1!==c&&a[b].splice(c,1)}}class aW{constructor(a,b={}){bR(this,b),this.type=a}}class cb extends aW{constructor(a,b={}){super("error",bR({error:a},b))}}class S{on(a,b){return this._listeners=this._listeners||{},fn(a,b,this._listeners),this}off(a,b){return fo(a,b,this._listeners),fo(a,b,this._oneTimeListeners),this}once(b,a){return a?(this._oneTimeListeners=this._oneTimeListeners||{},fn(b,a,this._oneTimeListeners),this):new Promise(a=>this.once(b,a))}fire(a,e){"string"==typeof a&&(a=new aW(a,e||{}));const b=a.type;if(this.listens(b)){a.target=this;const f=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const g of f)g.call(this,a);const h=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const c of h)fo(b,c,this._oneTimeListeners),c.call(this,a);const d=this._eventedParent;d&&(bR(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(a))}else a instanceof cb&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var b=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class cc{constructor(b,a,d,c){this.message=(b?`${b}: `:"")+d,c&&(this.identifier=c),null!=a&&a.__line__&&(this.line=a.__line__)}}function cd(a){const b=a.value;return b?[new cc(a.key,b,"constants have been deprecated as of v8")]:[]}function ce(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}function fp(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function fq(a){if(Array.isArray(a))return a.map(fq);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=fq(a[c]);return b}return fp(a)}class fr extends Error{constructor(b,a){super(a),this.message=a,this.key=b}}class fs{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new fs(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw new Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const cf={kind:"null"},f={kind:"number"},i={kind:"string"},h={kind:"boolean"},y={kind:"color"},K={kind:"object"},l={kind:"value"},cg={kind:"collator"},ch={kind:"formatted"},ci={kind:"resolvedImage"};function z(a,b){return{kind:"array",itemType:a,N:b}}function ft(a){if("array"===a.kind){const b=ft(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const fu=[cf,f,i,h,y,ch,K,z(l),ci];function fv(b,a){if("error"===a.kind)return null;if("array"===b.kind){if("array"===a.kind&&(0===a.N&&"value"===a.itemType.kind||!fv(b.itemType,a.itemType))&&("number"!=typeof b.N||b.N===a.N))return null}else{if(b.kind===a.kind)return null;if("value"===b.kind){for(const c of fu)if(!fv(c,a))return null}}return`Expected ${ft(b)} but found ${ft(a)} instead.`}function fw(b,a){return a.some(a=>a.kind===b.kind)}function fx(b,a){return a.some(a=>"null"===a?null===b:"array"===a?Array.isArray(b):"object"===a?b&&!Array.isArray(b)&&"object"==typeof b:a===typeof b)}function ah(b){var a={exports:{}};return b(a,a.exports),a.exports}var fy=ah(function(b,a){var c={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(b,c,a){return a<0?a+=1:a>1&&(a-=1),6*a<1?b+(c-b)*a*6:2*a<1?c:3*a<2?b+(c-b)*(2/3-a)*6:b}try{a.parseCSSColor=function(q){var a,b=q.replace(/ /g,"").toLowerCase();if(b in c)return c[b].slice();if("#"===b[0])return 4===b.length?(a=parseInt(b.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===b.length&&(a=parseInt(b.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var j=b.indexOf("("),p=b.indexOf(")");if(-1!==j&&p+1===b.length){var r=b.substr(0,j),h=b.substr(j+1,p-(j+1)).split(","),k=1;switch(r){case"rgba":if(4!==h.length)return null;k=f(h.pop());case"rgb":return 3!==h.length?null:[e(h[0]),e(h[1]),e(h[2]),k];case"hsla":if(4!==h.length)return null;k=f(h.pop());case"hsl":if(3!==h.length)return null;var m=(parseFloat(h[0])%360+360)%360/360,n=f(h[1]),i=f(h[2]),l=i<=.5?i*(n+1):i+n-i*n,o=2*i-l;return[d(255*g(o,l,m+1/3)),d(255*g(o,l,m)),d(255*g(o,l,m-1/3)),k];default:return null}}return null}}catch(h){}});class m{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(b){if(!b)return;if(b instanceof m)return b;if("string"!=typeof b)return;const a=fy.parseCSSColor(b);return a?new m(a[0]/255*a[3],a[1]/255*a[3],a[2]/255*a[3],a[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:b,g:c,b:d,a:a}=this;return 0===a?[0,0,0,0]:[255*b/a,255*c/a,255*d/a,a]}}m.black=new m(0,0,0,1),m.white=new m(1,1,1,1),m.transparent=new m(0,0,0,0),m.red=new m(1,0,0,1),m.blue=new m(0,0,1,1);class fz{constructor(b,a,c){this.sensitivity=b?a?"variant":"case":a?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class fA{constructor(a,b,c,d,e){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=e}}class fB{constructor(a){this.sections=a}static fromString(a){return new fB([new fA(a,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof fB?a:fB.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const b=["format"];for(const a of this.sections){if(a.image){b.push(["image",a.image.name]);continue}b.push(a.text);const c={};a.fontStack&&(c["text-font"]=["literal",a.fontStack.split(",")]),a.scale&&(c["font-scale"]=a.scale),a.textColor&&(c["text-color"]=["rgba"].concat(a.textColor.toArray())),b.push(c)}return b}}class cj{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new cj({name:a,available:!1}):null}serialize(){return["image",this.name]}}function fC(b,c,d,a){return"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof d&&d>=0&&d<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[b,c,d,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[b,c,d,a]:[b,c,d]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fD(a){if(null===a||"string"==typeof a||"boolean"==typeof a||"number"==typeof a||a instanceof m||a instanceof fz||a instanceof fB||a instanceof cj)return!0;if(Array.isArray(a)){for(const b of a)if(!fD(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!fD(a[c]))return!1;return!0}return!1}function fE(a){if(null===a)return cf;if("string"==typeof a)return i;if("boolean"==typeof a)return h;if("number"==typeof a)return f;if(a instanceof m)return y;if(a instanceof fz)return cg;if(a instanceof fB)return ch;if(a instanceof cj)return ci;if(Array.isArray(a)){const d=a.length;let b;for(const e of a){const c=fE(e);if(b){if(b===c)continue;b=l;break}b=c}return z(b||l,d)}return K}function fF(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof m||a instanceof fB||a instanceof cj?a.toString():JSON.stringify(a)}class ck{constructor(a,b){this.type=a,this.value=b}static parse(b,d){if(2!==b.length)return d.error(`'literal' expression requires exactly one argument, but found ${b.length-1} instead.`);if(!fD(b[1]))return d.error("invalid value");const e=b[1];let c=fE(e);const a=d.expectedType;return"array"===c.kind&&0===c.N&&a&&"array"===a.kind&&("number"!=typeof a.N||0===a.N)&&(c=a),new ck(c,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof m?["rgba"].concat(this.value.toArray()):this.value instanceof fB?this.value.serialize():this.value}}class fG{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const fH={string:i,number:f,boolean:h,object:K};class L{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");let e,b=1;const g=a[0];if("array"===g){let f,h;if(a.length>2){const d=a[1];if("string"!=typeof d||!(d in fH)||"object"===d)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=fH[d],b++}else f=l;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return c.error('The length argument to "array" must be a positive integer literal',2);h=a[2],b++}e=z(f,h)}else e=fH[g];const i=[];for(;ba.outputDefined())}serialize(){const a=this.type,c=[a.kind];if("array"===a.kind){const b=a.itemType;if("string"===b.kind||"number"===b.kind||"boolean"===b.kind){c.push(b.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&c.push(d)}}return c.concat(this.args.map(a=>a.serialize()))}}class cl{constructor(a){this.type=ch,this.sections=a}static parse(c,b){if(c.length<2)return b.error("Expected at least one argument.");const m=c[1];if(!Array.isArray(m)&&"object"==typeof m)return b.error("First argument must be an image or text section.");const d=[];let h=!1;for(let e=1;e<=c.length-1;++e){const a=c[e];if(h&&"object"==typeof a&&!Array.isArray(a)){h=!1;let n=null;if(a["font-scale"]&&!(n=b.parse(a["font-scale"],1,f)))return null;let o=null;if(a["text-font"]&&!(o=b.parse(a["text-font"],1,z(i))))return null;let p=null;if(a["text-color"]&&!(p=b.parse(a["text-color"],1,y)))return null;const j=d[d.length-1];j.scale=n,j.font=o,j.textColor=p}else{const k=b.parse(c[e],1,l);if(!k)return null;const g=k.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,d.push({content:k,scale:null,font:null,textColor:null})}}return new cl(d)}evaluate(a){return new fB(this.sections.map(b=>{const c=b.content.evaluate(a);return fE(c)===ci?new fA("",c,null,null,null):new fA(fF(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(b){for(const a of this.sections)b(a.content),a.scale&&b(a.scale),a.font&&b(a.font),a.textColor&&b(a.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const a of this.sections){c.push(a.content.serialize());const b={};a.scale&&(b["font-scale"]=a.scale.serialize()),a.font&&(b["text-font"]=a.font.serialize()),a.textColor&&(b["text-color"]=a.textColor.serialize()),c.push(b)}return c}}class cm{constructor(a){this.type=ci,this.input=a}static parse(b,a){if(2!==b.length)return a.error("Expected two arguments.");const c=a.parse(b[1],1,i);return c?new cm(c):a.error("No image name provided.")}evaluate(a){const c=this.input.evaluate(a),b=cj.fromString(c);return b&&a.availableImages&&(b.available=a.availableImages.indexOf(c)> -1),b}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const fI={"to-boolean":h,"to-color":y,"to-number":f,"to-string":i};class T{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");const d=a[0];if(("to-boolean"===d||"to-string"===d)&&2!==a.length)return c.error("Expected one argument.");const g=fI[d],e=[];for(let b=1;b4?`Invalid rbga value ${JSON.stringify(a)}: expected an array containing either three or four numeric values.`:fC(a[0],a[1],a[2],a[3])))return new m(a[0]/255,a[1]/255,a[2]/255,a[3])}throw new fG(c||`Could not parse color from value '${"string"==typeof a?a:String(JSON.stringify(a))}'`)}if("number"===this.type.kind){let d=null;for(const h of this.args){if(null===(d=h.evaluate(b)))return 0;const f=Number(d);if(!isNaN(f))return f}throw new fG(`Could not convert ${JSON.stringify(d)} to number.`)}return"formatted"===this.type.kind?fB.fromString(fF(this.args[0].evaluate(b))):"resolvedImage"===this.type.kind?cj.fromString(fF(this.args[0].evaluate(b))):fF(this.args[0].evaluate(b))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new cl([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new cm(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const fJ=["Unknown","Point","LineString","Polygon"];class fK{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?fJ[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=m.parse(a)),b}}class aX{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(f,c){const j=f[0],b=aX.definitions[j];if(!b)return c.error(`Unknown expression "${j}". If you wanted a literal array, use ["literal", [...]].`,0);const q=Array.isArray(b)?b[0]:b.type,m=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,h=m.filter(([a])=>!Array.isArray(a)||a.length===f.length-1);let e=null;for(const[a,r]of h){e=new f1(c.registry,c.path,null,c.scope);const d=[];let n=!1;for(let i=1;i{var a;return a=b,Array.isArray(a)?`(${a.map(ft).join(", ")})`:`(${ft(a.type)}...)`}).join(" | "),k=[];for(let l=1;l=b[2]||a[1]<=b[1]||a[3]>=b[3])}function fN(a,c){const d=(180+a[0])/360,e=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,b=Math.pow(2,c.z);return[Math.round(d*b*8192),Math.round(e*b*8192)]}function fO(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function fP(h,i){var d,b,e;let f=!1;for(let g=0,j=i.length;g(d=h)[1]!=(e=c[a+1])[1]>d[1]&&d[0]<(e[0]-b[0])*(d[1]-b[1])/(e[1]-b[1])+b[0]&&(f=!f)}}return f}function fQ(c,b){for(let a=0;a0&&h<0||g<0&&h>0}function fS(i,j,k){var a,b,c,d,g,h;for(const f of k)for(let e=0;eb[2]){const d=.5*c;let e=a[0]-b[0]>d?-c:b[0]-a[0]>d?c:0;0===e&&(e=a[0]-b[2]>d?-c:b[2]-a[0]>d?c:0),a[0]+=e}fL(f,a)}function fY(f,g,h,a){const i=8192*Math.pow(2,a.z),b=[8192*a.x,8192*a.y],c=[];for(const j of f)for(const d of j){const e=[d.x+b[0],d.y+b[1]];fX(e,g,h,i),c.push(e)}return c}function fZ(j,a,k,c){var b;const e=8192*Math.pow(2,c.z),f=[8192*c.x,8192*c.y],d=[];for(const l of j){const g=[];for(const h of l){const i=[h.x+f[0],h.y+f[1]];fL(a,i),g.push(i)}d.push(g)}if(a[2]-a[0]<=e/2)for(const m of((b=a)[0]=b[1]=1/0,b[2]=b[3]=-1/0,d))for(const n of m)fX(n,a,k,e);return d}class co{constructor(a,b){this.type=h,this.geojson=a,this.geometries=b}static parse(b,d){if(2!==b.length)return d.error(`'within' expression requires exactly one argument, but found ${b.length-1} instead.`);if(fD(b[1])){const a=b[1];if("FeatureCollection"===a.type)for(let c=0;c{b&&!f$(a)&&(b=!1)}),b}function f_(a){if(a instanceof aX&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!f_(a)&&(b=!1)}),b}function f0(a,b){if(a instanceof aX&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!f0(a,b)&&(c=!1)}),c}class cp{constructor(b,a){this.type=a.type,this.name=b,this.boundExpression=a}static parse(c,b){if(2!==c.length||"string"!=typeof c[1])return b.error("'var' expression requires exactly one string literal argument.");const a=c[1];return b.scope.has(a)?new cp(a,b.scope.get(a)):b.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class f1{constructor(b,a=[],c,d=new fs,e=[]){this.registry=b,this.path=a,this.key=a.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=e,this.expectedType=c}parse(a,b,d,e,c={}){return b?this.concat(b,d,e)._parse(a,c):this._parse(a,c)}_parse(a,f){function g(a,b,c){return"assert"===c?new L(b,[a]):"coerce"===c?new T(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[d];if(h){let b=h.parse(a,this);if(!b)return null;if(this.expectedType){const c=this.expectedType,e=b.type;if("string"!==c.kind&&"number"!==c.kind&&"boolean"!==c.kind&&"object"!==c.kind&&"array"!==c.kind||"value"!==e.kind){if("color"!==c.kind&&"formatted"!==c.kind&&"resolvedImage"!==c.kind||"value"!==e.kind&&"string"!==e.kind){if(this.checkSubtype(c,e))return null}else b=g(b,c,f.typeAnnotation||"coerce")}else b=g(b,c,f.typeAnnotation||"assert")}if(!(b instanceof ck)&&"resolvedImage"!==b.type.kind&&f2(b)){const i=new fK;try{b=new ck(b.type,b.evaluate(i))}catch(j){return this.error(j.message),null}}return b}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof a} instead.`)}concat(a,c,b){const d="number"==typeof a?this.path.concat(a):this.path,e=b?this.scope.concat(b):this.scope;return new f1(this.registry,d,c||null,e,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new fr(c,a))}checkSubtype(b,c){const a=fv(b,c);return a&&this.error(a),a}}function f2(a){if(a instanceof cp)return f2(a.boundExpression);if(a instanceof aX&&"error"===a.name||a instanceof cn||a instanceof co)return!1;const c=a instanceof T||a instanceof L;let b=!0;return a.eachChild(a=>{b=c?b&&f2(a):b&&a instanceof ck}),!!b&&f$(a)&&f0(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function f3(b,c){const g=b.length-1;let d,h,e=0,f=g,a=0;for(;e<=f;)if(d=b[a=Math.floor((e+f)/2)],h=b[a+1],d<=c){if(a===g||cc))throw new fG("Input is not a number.");f=a-1}return 0}class cq{constructor(a,b,c){for(const[d,e]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(e)}static parse(b,a){if(b.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if((b.length-1)%2!=0)return a.error("Expected an even number of arguments.");const i=a.parse(b[1],1,f);if(!i)return null;const d=[];let e=null;a.expectedType&&"value"!==a.expectedType.kind&&(e=a.expectedType);for(let c=1;c=g)return a.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',j);const h=a.parse(k,l,e);if(!h)return null;e=e||h.type,d.push([g,h])}return new cq(e,i,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const e=b.length;return d>=b[e-1]?c[e-1].evaluate(a):c[f3(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const b=["step",this.input.serialize()];for(let a=0;a0&&b.push(this.labels[a]),b.push(this.outputs[a].serialize());return b}}function aY(b,c,a){return b*(1-a)+c*a}var f4=Object.freeze({__proto__:null,number:aY,color:function(a,b,c){var d,e,f,g,h,i,j,k,l,n,o,p;return new m((d=a.r,e=b.r,d*(1-(f=c))+e*f),(g=a.g,h=b.g,g*(1-(i=c))+h*i),(j=a.b,k=b.b,j*(1-(l=c))+k*l),(n=a.a,o=b.a,n*(1-(p=c))+o*p))},array:function(a,b,c){return a.map((f,g)=>{var a,d,e;return a=f,d=b[g],a*(1-(e=c))+d*e})}});const f5=4/29,aZ=6/29,f6=3*aZ*aZ,f7=Math.PI/180,f8=180/Math.PI;function f9(a){return a>.008856451679035631?Math.pow(a,1/3):a/f6+f5}function ga(a){return a>aZ?a*a*a:f6*(a-f5)}function gb(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function gc(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function cr(a){const b=gc(a.r),c=gc(a.g),d=gc(a.b),f=f9((.4124564*b+.3575761*c+.1804375*d)/.95047),e=f9((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*e-16,a:500*(f-e),b:200*(e-f9((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function cs(b){let a=(b.l+16)/116,c=isNaN(b.a)?a:a+b.a/500,d=isNaN(b.b)?a:a-b.b/200;return a=1*ga(a),c=.95047*ga(c),d=1.08883*ga(d),new m(gb(3.2404542*c-1.5371385*a-.4985314*d),gb(-0.969266*c+1.8760108*a+.041556*d),gb(.0556434*c-.2040259*a+1.0572252*d),b.alpha)}const ct={forward:cr,reverse:cs,interpolate:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o;return{l:(d=a.l,e=b.l,d*(1-(f=c))+e*f),a:(g=a.a,h=b.a,g*(1-(i=c))+h*i),b:(j=a.b,k=b.b,j*(1-(l=c))+k*l),alpha:(m=a.alpha,n=b.alpha,m*(1-(o=c))+n*o)}}},cu={forward:function(d){const{l:e,a:a,b:b}=cr(d),c=Math.atan2(b,a)*f8;return{h:c<0?c+360:c,c:Math.sqrt(a*a+b*b),l:e,alpha:d.a}},reverse:function(a){const b=a.h*f7,c=a.c;return cs({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){var d,e,f,g,h,i,j,k,l;return{h:function(b,c,d){const a=c-b;return b+d*(a>180||a< -180?a-360*Math.round(a/360):a)}(a.h,b.h,c),c:(d=a.c,e=b.c,d*(1-(f=c))+e*f),l:(g=a.l,h=b.l,g*(1-(i=c))+h*i),alpha:(j=a.alpha,k=b.alpha,j*(1-(l=c))+k*l)}}};var gd=Object.freeze({__proto__:null,lab:ct,hcl:cu});class ai{constructor(a,b,c,d,e){for(const[f,g]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],e))this.labels.push(f),this.outputs.push(g)}static interpolationFactor(a,d,e,f){let b=0;if("exponential"===a.name)b=ge(d,a.base,e,f);else if("linear"===a.name)b=ge(d,1,e,f);else if("cubic-bezier"===a.name){const c=a.controlPoints;b=new eG(c[0],c[1],c[2],c[3]).solve(ge(d,1,e,f))}return b}static parse(g,a){let[h,b,i,...j]=g;if(!Array.isArray(b)||0===b.length)return a.error("Expected an interpolation type expression.",1);if("linear"===b[0])b={name:"linear"};else if("exponential"===b[0]){const n=b[1];if("number"!=typeof n)return a.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:n}}else{if("cubic-bezier"!==b[0])return a.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const k=b.slice(1);if(4!==k.length||k.some(a=>"number"!=typeof a||a<0||a>1))return a.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:k}}}if(g.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${g.length-1}.`);if((g.length-1)%2!=0)return a.error("Expected an even number of arguments.");if(!(i=a.parse(i,2,f)))return null;const e=[];let c=null;"interpolate-hcl"===h||"interpolate-lab"===h?c=y:a.expectedType&&"value"!==a.expectedType.kind&&(c=a.expectedType);for(let d=0;d=l)return a.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const m=a.parse(p,q,c);if(!m)return null;c=c||m.type,e.push([l,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new ai(c,h,b,i,e):a.error(`Type ${ft(c)} is not interpolatable.`)}evaluate(b){const a=this.labels,c=this.outputs;if(1===a.length)return c[0].evaluate(b);const d=this.input.evaluate(b);if(d<=a[0])return c[0].evaluate(b);const i=a.length;if(d>=a[i-1])return c[i-1].evaluate(b);const e=f3(a,d),f=ai.interpolationFactor(this.interpolation,d,a[e],a[e+1]),g=c[e].evaluate(b),h=c[e+1].evaluate(b);return"interpolate"===this.operator?f4[this.type.kind.toLowerCase()](g,h,f):"interpolate-hcl"===this.operator?cu.reverse(cu.interpolate(cu.forward(g),cu.forward(h),f)):ct.reverse(ct.interpolate(ct.forward(g),ct.forward(h),f))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let b;b="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const c=[this.operator,b,this.input.serialize()];for(let a=0;afv(b,a.type));return new cv(h?l:a,c)}evaluate(d){let b,a=null,c=0;for(const e of this.args){if(c++,(a=e.evaluate(d))&&a instanceof cj&&!a.available&&(b||(b=a),a=null,c===this.args.length))return b;if(null!==a)break}return a}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cw{constructor(b,a){this.type=a.type,this.bindings=[].concat(b),this.result=a}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,c){if(a.length<4)return c.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const e=[];for(let b=1;b=b.length)throw new fG(`Array index out of bounds: ${a} > ${b.length-1}.`);if(a!==Math.floor(a))throw new fG(`Array index must be an integer, but found ${a} instead.`);return b[a]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class cy{constructor(a,b){this.type=h,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);return c&&d?fw(c.type,[h,i,f,cf,l])?new cy(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`):null}evaluate(c){const b=this.needle.evaluate(c),a=this.haystack.evaluate(c);if(!a)return!1;if(!fx(b,["boolean","string","number","null"]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(b))} instead.`);if(!fx(a,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(a))} instead.`);return a.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class cz{constructor(a,b,c){this.type=f,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);if(!c||!d)return null;if(!fw(c.type,[h,i,f,cf,l]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`);if(4===a.length){const e=b.parse(a[3],3,f);return e?new cz(c,d,e):null}return new cz(c,d)}evaluate(c){const a=this.needle.evaluate(c),b=this.haystack.evaluate(c);if(!fx(a,["boolean","string","number","null"]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(a))} instead.`);if(!fx(b,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(b))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(c);return b.indexOf(a,d)}return b.indexOf(a)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class cA{constructor(a,b,c,d,e,f){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=e,this.otherwise=f}static parse(b,c){if(b.length<5)return c.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if(b.length%2!=1)return c.error("Expected an even number of arguments.");let g,d;c.expectedType&&"value"!==c.expectedType.kind&&(d=c.expectedType);const j={},k=[];for(let e=2;eNumber.MAX_SAFE_INTEGER)return f.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof a&&Math.floor(a)!==a)return f.error("Numeric branch labels must be integer values.");if(g){if(f.checkSubtype(g,fE(a)))return null}else g=fE(a);if(void 0!==j[String(a)])return f.error("Branch labels must be unique.");j[String(a)]=k.length}const m=c.parse(o,e,d);if(!m)return null;d=d||m.type,k.push(m)}const i=c.parse(b[1],1,l);if(!i)return null;const n=c.parse(b[b.length-1],b.length-1,d);return n?"value"!==i.type.kind&&c.concat(1).checkSubtype(g,i.type)?null:new cA(g,d,i,j,k,n):null}evaluate(a){const b=this.input.evaluate(a);return(fE(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const b=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),c=[],e={};for(const a of h){const f=e[this.cases[a]];void 0===f?(e[this.cases[a]]=c.length,c.push([this.cases[a],[a]])):c[f][1].push(a)}const g=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,d]of c)b.push(1===d.length?g(d[0]):d.map(g)),b.push(this.outputs[i].serialize());return b.push(this.otherwise.serialize()),b}}class cB{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const f=[];for(let d=1;da.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cC{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,c){if(a.length<=2||a.length>=5)return c.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const b=c.parse(a[1],1,l),d=c.parse(a[2],2,f);if(!b||!d)return null;if(!fw(b.type,[z(l),i,l]))return c.error(`Expected first argument to be of type array or string, but found ${ft(b.type)} instead`);if(4===a.length){const e=c.parse(a[3],3,f);return e?new cC(b.type,b,d,e):null}return new cC(b.type,b,d)}evaluate(b){const a=this.input.evaluate(b),c=this.beginIndex.evaluate(b);if(!fx(a,["string","array"]))throw new fG(`Expected first argument to be of type array or string, but found ${ft(fE(a))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(b);return a.slice(c,d)}return a.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function gf(b,a){return"=="===b||"!="===b?"boolean"===a.kind||"string"===a.kind||"number"===a.kind||"null"===a.kind||"value"===a.kind:"string"===a.kind||"number"===a.kind||"value"===a.kind}function cD(d,a,b,c){return 0===c.compare(a,b)}function A(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(a,b,c){this.type=h,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(f,c){if(3!==f.length&&4!==f.length)return c.error("Expected two or three arguments.");const g=f[0];let a=c.parse(f[1],1,l);if(!a)return null;if(!gf(g,a.type))return c.concat(1).error(`"${g}" comparisons are not supported for type '${ft(a.type)}'.`);let b=c.parse(f[2],2,l);if(!b)return null;if(!gf(g,b.type))return c.concat(2).error(`"${g}" comparisons are not supported for type '${ft(b.type)}'.`);if(a.type.kind!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error(`Cannot compare types '${ft(a.type)}' and '${ft(b.type)}'.`);d&&("value"===a.type.kind&&"value"!==b.type.kind?a=new L(b.type,[a]):"value"!==a.type.kind&&"value"===b.type.kind&&(b=new L(a.type,[b])));let h=null;if(4===f.length){if("string"!==a.type.kind&&"string"!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error("Cannot use collator to compare non-string types.");if(!(h=c.parse(f[3],3,cg)))return null}return new e(a,b,h)}evaluate(e){const f=this.lhs.evaluate(e),g=this.rhs.evaluate(e);if(d&&this.hasUntypedArgument){const h=fE(f),i=fE(g);if(h.kind!==i.kind||"string"!==h.kind&&"number"!==h.kind)throw new fG(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${h.kind}, ${i.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const j=fE(f),k=fE(g);if("string"!==j.kind||"string"!==k.kind)return b(e,f,g)}return this.collator?c(e,f,g,this.collator.evaluate(e)):b(e,f,g)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const cE=A("==",function(c,a,b){return a===b},cD),cF=A("!=",function(c,a,b){return a!==b},function(d,a,b,c){return!cD(0,a,b,c)}),cG=A("<",function(c,a,b){return ac.compare(a,b)}),cH=A(">",function(c,a,b){return a>b},function(d,a,b,c){return c.compare(a,b)>0}),cI=A("<=",function(c,a,b){return a<=b},function(d,a,b,c){return 0>=c.compare(a,b)}),cJ=A(">=",function(c,a,b){return a>=b},function(d,a,b,c){return c.compare(a,b)>=0});class cK{constructor(a,b,c,d,e){this.type=i,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=e}static parse(c,b){if(3!==c.length)return b.error("Expected two arguments.");const d=b.parse(c[1],1,f);if(!d)return null;const a=c[2];if("object"!=typeof a||Array.isArray(a))return b.error("NumberFormat options argument must be an object.");let e=null;if(a.locale&&!(e=b.parse(a.locale,1,i)))return null;let g=null;if(a.currency&&!(g=b.parse(a.currency,1,i)))return null;let h=null;if(a["min-fraction-digits"]&&!(h=b.parse(a["min-fraction-digits"],1,f)))return null;let j=null;return!a["max-fraction-digits"]||(j=b.parse(a["max-fraction-digits"],1,f))?new cK(d,e,g,h,j):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a]}}class cL{constructor(a){this.type=f,this.input=a}static parse(b,c){if(2!==b.length)return c.error(`Expected 1 argument, but found ${b.length-1} instead.`);const a=c.parse(b[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?c.error(`Expected argument of type string or array, but found ${ft(a.type)} instead.`):new cL(a):null}evaluate(b){const a=this.input.evaluate(b);if("string"==typeof a||Array.isArray(a))return a.length;throw new fG(`Expected value to be of type string or array, but found ${ft(fE(a))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const U={"==":cE,"!=":cF,">":cH,"<":cG,">=":cJ,"<=":cI,array:L,at:cx,boolean:L,case:cB,coalesce:cv,collator:cn,format:cl,image:cm,in:cy,"index-of":cz,interpolate:ai,"interpolate-hcl":ai,"interpolate-lab":ai,length:cL,let:cw,literal:ck,match:cA,number:L,"number-format":cK,object:L,slice:cC,step:cq,string:L,"to-boolean":T,"to-color":T,"to-number":T,"to-string":T,var:cp,within:co};function a$(b,[c,d,e,f]){c=c.evaluate(b),d=d.evaluate(b),e=e.evaluate(b);const a=f?f.evaluate(b):1,g=fC(c,d,e,a);if(g)throw new fG(g);return new m(c/255*a,d/255*a,e/255*a,a)}function gg(b,c){const a=c[b];return void 0===a?null:a}function x(a){return{type:a}}function gh(a){return{result:"success",value:a}}function gi(a){return{result:"error",value:a}}function gj(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function gk(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function gl(a){return!!a.expression&&a.expression.interpolated}function gm(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function gn(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function go(a){return a}function gp(a,e){const r="color"===e.type,g=a.stops&&"object"==typeof a.stops[0][0],s=g||!(g|| void 0!==a.property),b=a.type||(gl(e)?"exponential":"interval");if(r&&((a=ce({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],m.parse(a[1])])),a.default=m.parse(a.default?a.default:e.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!gd[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let f,j,t;if("exponential"===b)f=gt;else if("interval"===b)f=gs;else if("categorical"===b){for(const k of(f=gr,j=Object.create(null),a.stops))j[k[0]]=k[1];t=typeof a.stops[0][0]}else{if("identity"!==b)throw new Error(`Unknown function type "${b}"`);f=gu}if(g){const c={},l=[];for(let h=0;ha[0]),evaluate:({zoom:b},c)=>gt({stops:n,base:a.base},e,b).evaluate(b,c)}}if(s){const q="exponential"===b?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:ai.interpolationFactor.bind(void 0,q),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:b})=>f(a,e,b,j,t)}}return{kind:"source",evaluate(d,b){const c=b&&b.properties?b.properties[a.property]:void 0;return void 0===c?gq(a.default,e.default):f(a,e,c,j,t)}}}function gq(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function gr(b,c,a,d,e){return gq(typeof a===e?d[a]:void 0,b.default,c.default)}function gs(a,d,b){if("number"!==gm(b))return gq(a.default,d.default);const c=a.stops.length;if(1===c||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[c-1][0])return a.stops[c-1][1];const e=f3(a.stops.map(a=>a[0]),b);return a.stops[e][1]}function gt(a,e,b){const h=void 0!==a.base?a.base:1;if("number"!==gm(b))return gq(a.default,e.default);const d=a.stops.length;if(1===d||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[d-1][0])return a.stops[d-1][1];const c=f3(a.stops.map(a=>a[0]),b),i=function(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}(b,h,a.stops[c][0],a.stops[c+1][0]),f=a.stops[c][1],j=a.stops[c+1][1];let g=f4[e.type]||go;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=gd[a.colorSpace];g=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),i))}return"function"==typeof f.evaluate?{evaluate(...a){const b=f.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return g(b,c,i)}}:g(f,j,i)}function gu(c,b,a){return"color"===b.type?a=m.parse(a):"formatted"===b.type?a=fB.fromString(a.toString()):"resolvedImage"===b.type?a=cj.fromString(a.toString()):gm(a)===b.type||"enum"===b.type&&b.values[a]||(a=void 0),gq(a,c.default,b.default)}aX.register(U,{error:[{kind:"error"},[i],(a,[b])=>{throw new fG(b.evaluate(a))}],typeof:[i,[l],(a,[b])=>ft(fE(b.evaluate(a)))],"to-rgba":[z(f,4),[y],(a,[b])=>b.evaluate(a).toArray()],rgb:[y,[f,f,f],a$],rgba:[y,[f,f,f,f],a$],has:{type:h,overloads:[[[i],(a,[d])=>{var b,c;return b=d.evaluate(a),c=a.properties(),b in c}],[[i,K],(a,[b,c])=>b.evaluate(a) in c.evaluate(a)]]},get:{type:l,overloads:[[[i],(a,[b])=>gg(b.evaluate(a),a.properties())],[[i,K],(a,[b,c])=>gg(b.evaluate(a),c.evaluate(a))]]},"feature-state":[l,[i],(a,[b])=>gg(b.evaluate(a),a.featureState||{})],properties:[K,[],a=>a.properties()],"geometry-type":[i,[],a=>a.geometryType()],id:[l,[],a=>a.id()],zoom:[f,[],a=>a.globals.zoom],pitch:[f,[],a=>a.globals.pitch||0],"distance-from-center":[f,[],a=>a.distanceFromCenter()],"heatmap-density":[f,[],a=>a.globals.heatmapDensity||0],"line-progress":[f,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[f,[],a=>a.globals.skyRadialProgress||0],accumulated:[l,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated],"+":[f,x(f),(b,c)=>{let a=0;for(const d of c)a+=d.evaluate(b);return a}],"*":[f,x(f),(b,c)=>{let a=1;for(const d of c)a*=d.evaluate(b);return a}],"-":{type:f,overloads:[[[f,f],(a,[b,c])=>b.evaluate(a)-c.evaluate(a)],[[f],(a,[b])=>-b.evaluate(a)]]},"/":[f,[f,f],(a,[b,c])=>b.evaluate(a)/c.evaluate(a)],"%":[f,[f,f],(a,[b,c])=>b.evaluate(a)%c.evaluate(a)],ln2:[f,[],()=>Math.LN2],pi:[f,[],()=>Math.PI],e:[f,[],()=>Math.E],"^":[f,[f,f],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a))],sqrt:[f,[f],(a,[b])=>Math.sqrt(b.evaluate(a))],log10:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10],ln:[f,[f],(a,[b])=>Math.log(b.evaluate(a))],log2:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2],sin:[f,[f],(a,[b])=>Math.sin(b.evaluate(a))],cos:[f,[f],(a,[b])=>Math.cos(b.evaluate(a))],tan:[f,[f],(a,[b])=>Math.tan(b.evaluate(a))],asin:[f,[f],(a,[b])=>Math.asin(b.evaluate(a))],acos:[f,[f],(a,[b])=>Math.acos(b.evaluate(a))],atan:[f,[f],(a,[b])=>Math.atan(b.evaluate(a))],min:[f,x(f),(b,a)=>Math.min(...a.map(a=>a.evaluate(b)))],max:[f,x(f),(b,a)=>Math.max(...a.map(a=>a.evaluate(b)))],abs:[f,[f],(a,[b])=>Math.abs(b.evaluate(a))],round:[f,[f],(b,[c])=>{const a=c.evaluate(b);return a<0?-Math.round(-a):Math.round(a)}],floor:[f,[f],(a,[b])=>Math.floor(b.evaluate(a))],ceil:[f,[f],(a,[b])=>Math.ceil(b.evaluate(a))],"filter-==":[h,[i,l],(a,[b,c])=>a.properties()[b.value]===c.value],"filter-id-==":[h,[l],(a,[b])=>a.id()===b.value],"filter-type-==":[h,[i],(a,[b])=>a.geometryType()===b.value],"filter-<":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a{const a=c.id(),b=d.value;return typeof a==typeof b&&a":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>b}],"filter-id->":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>b}],"filter-<=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<=b}],"filter-id-<=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<=b}],"filter->=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>=b}],"filter-id->=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>=b}],"filter-has":[h,[l],(a,[b])=>b.value in a.properties()],"filter-has-id":[h,[],a=>null!==a.id()&& void 0!==a.id()],"filter-type-in":[h,[z(i)],(a,[b])=>b.value.indexOf(a.geometryType())>=0],"filter-id-in":[h,[z(l)],(a,[b])=>b.value.indexOf(a.id())>=0],"filter-in-small":[h,[i,z(l)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0],"filter-in-large":[h,[i,z(l)],(b,[c,a])=>(function(d,e,b,c){for(;b<=c;){const a=b+c>>1;if(e[a]===d)return!0;e[a]>d?c=a-1:b=a+1}return!1})(b.properties()[c.value],a.value,0,a.value.length-1)],all:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0}]]},any:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)||c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1}]]},"!":[h,[h],(a,[b])=>!b.evaluate(a)],"is-supported-script":[h,[i],(a,[c])=>{const b=a.globals&&a.globals.isSupportedScript;return!b||b(c.evaluate(a))}],upcase:[i,[i],(a,[b])=>b.evaluate(a).toUpperCase()],downcase:[i,[i],(a,[b])=>b.evaluate(a).toLowerCase()],concat:[i,x(l),(b,a)=>a.map(a=>fF(a.evaluate(b))).join("")],"resolved-locale":[i,[cg],(a,[b])=>b.evaluate(a).resolvedLocale()]});class cM{constructor(c,b){var a;this.expression=c,this._warningHistory={},this._evaluator=new fK,this._defaultValue=b?"color"===(a=b).type&&gn(a.default)?new m(0,0,0,0):"color"===a.type?m.parse(a.default)||null:void 0===a.default?null:a.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,e,f,g,h){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=e||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=g||null,this._evaluator.featureDistanceData=h||null,this.expression.evaluate(this._evaluator)}evaluate(c,d,e,f,g,h,i,j){this._evaluator.globals=c,this._evaluator.feature=d||null,this._evaluator.featureState=e||null,this._evaluator.canonical=f,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=i||null,this._evaluator.featureDistanceData=j||null;try{const a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new fG(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(a)} instead.`);return a}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,"undefined"!=typeof console&&console.warn(b.message)),this._defaultValue}}}function gv(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in U}function cN(d,a){const b=new f1(U,[],a?function(a){const b={color:y,string:i,number:f,enum:i,boolean:h,formatted:ch,resolvedImage:ci};return"array"===a.type?z(b[a.value]||l,a.length):b[a.type]}(a):void 0),c=b.parse(d,void 0,void 0,void 0,a&&"string"===a.type?{typeAnnotation:"coerce"}:void 0);return c?gh(new cM(c,a)):gi(b.errors)}class cO{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!f_(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}}class cP{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!f_(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}interpolationFactor(a,b,c){return this.interpolationType?ai.interpolationFactor(this.interpolationType,a,b,c):0}}function gw(b,c){if("error"===(b=cN(b,c)).result)return b;const d=b.value.expression,e=f$(d);if(!e&&!gj(c))return gi([new fr("","data expressions not supported")]);const f=f0(d,["zoom","pitch","distance-from-center"]);if(!f&&!gk(c))return gi([new fr("","zoom expressions not supported")]);const a=gx(d);return a||f?a instanceof fr?gi([a]):a instanceof ai&&!gl(c)?gi([new fr("",'"interpolate" expressions cannot be used with this property')]):gh(a?new cP(e?"camera":"composite",b.value,a.labels,a instanceof ai?a.interpolation:void 0):new cO(e?"constant":"source",b.value)):gi([new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class cQ{constructor(a,b){this._parameters=a,this._specification=b,ce(this,gp(this._parameters,this._specification))}static deserialize(a){return new cQ(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function gx(a){let b=null;if(a instanceof cw)b=gx(a.result);else if(a instanceof cv){for(const c of a.args)if(b=gx(c))break}else(a instanceof cq||a instanceof ai)&&a.input instanceof aX&&"zoom"===a.input.name&&(b=a);return b instanceof fr||a.eachChild(c=>{const a=gx(c);a instanceof fr?b=a:!b&&a?b=new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):b&&a&&b!==a&&(b=new fr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),b}function cR(c){const d=c.key,a=c.value,b=c.valueSpec||{},f=c.objectElementValidators||{},l=c.style,m=c.styleSpec;let g=[];const k=gm(a);if("object"!==k)return[new cc(d,a,`object expected, ${k} found`)];for(const e in a){const j=e.split(".")[0],n=b[j]||b["*"];let h;if(f[j])h=f[j];else if(b[j])h=gR;else if(f["*"])h=f["*"];else{if(!b["*"]){g.push(new cc(d,a[e],`unknown property "${e}"`));continue}h=gR}g=g.concat(h({key:(d?`${d}.`:d)+e,value:a[e],valueSpec:n,style:l,styleSpec:m,object:a,objectKey:e},a))}for(const i in b)f[i]||b[i].required&& void 0===b[i].default&& void 0===a[i]&&g.push(new cc(d,a,`missing required property "${i}"`));return g}function cS(c){const b=c.value,a=c.valueSpec,i=c.style,h=c.styleSpec,e=c.key,j=c.arrayElementValidator||gR;if("array"!==gm(b))return[new cc(e,b,`array expected, ${gm(b)} found`)];if(a.length&&b.length!==a.length)return[new cc(e,b,`array length ${a.length} expected, length ${b.length} found`)];if(a["min-length"]&&b.lengthg)return[new cc(e,a,`${a} is greater than the maximum value ${g}`)]}return[]}function cU(a){const f=a.valueSpec,c=fp(a.value.type);let g,h,i,j={};const d="categorical"!==c&& void 0===a.value.property,e="array"===gm(a.value.stops)&&"array"===gm(a.value.stops[0])&&"object"===gm(a.value.stops[0][0]),b=cR({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(a){if("identity"===c)return[new cc(a.key,a.value,'identity function may not have a "stops" property')];let b=[];const d=a.value;return b=b.concat(cS({key:a.key,value:d,valueSpec:a.valueSpec,style:a.style,styleSpec:a.styleSpec,arrayElementValidator:k})),"array"===gm(d)&&0===d.length&&b.push(new cc(a.key,d,"array must have at least one stop")),b},default:function(a){return gR({key:a.key,value:a.value,valueSpec:f,style:a.style,styleSpec:a.styleSpec})}}});return"identity"===c&&d&&b.push(new cc(a.key,a.value,'missing required property "property"')),"identity"===c||a.value.stops||b.push(new cc(a.key,a.value,'missing required property "stops"')),"exponential"===c&&a.valueSpec.expression&&!gl(a.valueSpec)&&b.push(new cc(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(d||gj(a.valueSpec)?d&&!gk(a.valueSpec)&&b.push(new cc(a.key,a.value,"zoom functions not supported")):b.push(new cc(a.key,a.value,"property functions not supported"))),("categorical"===c||e)&& void 0===a.value.property&&b.push(new cc(a.key,a.value,'"property" property is required')),b;function k(c){let d=[];const a=c.value,b=c.key;if("array"!==gm(a))return[new cc(b,a,`array expected, ${gm(a)} found`)];if(2!==a.length)return[new cc(b,a,`array length 2 expected, length ${a.length} found`)];if(e){if("object"!==gm(a[0]))return[new cc(b,a,`object expected, ${gm(a[0])} found`)];if(void 0===a[0].zoom)return[new cc(b,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new cc(b,a,"object stop key must have value")];if(i&&i>fp(a[0].zoom))return[new cc(b,a[0].zoom,"stop zoom values must appear in ascending order")];fp(a[0].zoom)!==i&&(i=fp(a[0].zoom),h=void 0,j={}),d=d.concat(cR({key:`${b}[0]`,value:a[0],valueSpec:{zoom:{}},style:c.style,styleSpec:c.styleSpec,objectElementValidators:{zoom:cT,value:l}}))}else d=d.concat(l({key:`${b}[0]`,value:a[0],valueSpec:{},style:c.style,styleSpec:c.styleSpec},a));return gv(fq(a[1]))?d.concat([new cc(`${b}[1]`,a[1],"expressions are not allowed in function stops.")]):d.concat(gR({key:`${b}[1]`,value:a[1],valueSpec:f,style:c.style,styleSpec:c.styleSpec}))}function l(a,k){const b=gm(a.value),d=fp(a.value),e=null!==a.value?a.value:k;if(g){if(b!==g)return[new cc(a.key,e,`${b} stop domain type must match previous stop domain type ${g}`)]}else g=b;if("number"!==b&&"string"!==b&&"boolean"!==b)return[new cc(a.key,e,"stop domain value must be a number, string, or boolean")];if("number"!==b&&"categorical"!==c){let i=`number expected, ${b} found`;return gj(f)&& void 0===c&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new cc(a.key,e,i)]}return"categorical"!==c||"number"!==b||isFinite(d)&&Math.floor(d)===d?"categorical"!==c&&"number"===b&& void 0!==h&&dnew cc(`${a.key}${b.key}`,a.value,b.message));const b=c.value.expression||c.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!b.outputDefined())return[new cc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===a.expressionContext&&"layout"===a.propertyType&&!f_(b))return[new cc(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===a.expressionContext)return gz(b,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!f0(b,["zoom","feature-state"]))return[new cc(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===a.expressionContext&&!f$(b))return[new cc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function gz(b,a){const c=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const d of a.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return b instanceof aX&&c.has(b.name)?[new cc(a.key,a.value,`["${b.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`)]:(b.eachChild(b=>{e.push(...gz(b,a))}),e)}function cV(c){const e=c.key,a=c.value,b=c.valueSpec,d=[];return Array.isArray(b.values)?-1===b.values.indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${b.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(b.values).indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(a)} found`)),d}function gA(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!gA(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function gB(a,k="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};gA(a)||(a=gI(a));const c=a;let d=!0;try{d=function(a){if(!gE(a))return a;let b=fq(a);return gD(b),b=gC(b)}(c)}catch(l){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! From ec147d19e31379a414b76f79ad7d66bfcd86fc95 Mon Sep 17 00:00:00 2001 From: austaras Date: Thu, 21 Apr 2022 14:27:52 +0800 Subject: [PATCH 23/27] update --- .../tests/single-pass/terser/1/output.js | 72 +++++++++---------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/crates/swc_ecma_minifier/tests/single-pass/terser/1/output.js b/crates/swc_ecma_minifier/tests/single-pass/terser/1/output.js index ff131235759a..e779f276440f 100644 --- a/crates/swc_ecma_minifier/tests/single-pass/terser/1/output.js +++ b/crates/swc_ecma_minifier/tests/single-pass/terser/1/output.js @@ -7,47 +7,45 @@ def_optimize(AST_Call, function(self, compressor) { }).optimize(compressor); } if (is_undeclared_ref(exp)) exp.name; - else if (exp instanceof AST_Dot) switch(exp.property){ - case "join": - if (exp.expression instanceof AST_Array) { - EXIT: if (!(self.args.length > 0) || (separator = self.args[0].evaluate(compressor)) !== self.args[0]) { - for(var separator, first, elements = [], consts = [], i = 0, len = exp.expression.elements.length; i < len; i++){ - var el = exp.expression.elements[i]; - if (el instanceof AST_Expansion) break EXIT; - var value = el.evaluate(compressor); - value !== el ? consts.push(value) : (consts.length > 0 && (elements.push(make_node(AST_String, self, { - value: consts.join(separator) - })), consts.length = 0), elements.push(el)); - } - if (consts.length > 0 && elements.push(make_node(AST_String, self, { + else if (exp instanceof AST_Dot && "join" === exp.property) { + if (exp.expression instanceof AST_Array) { + EXIT: if (!(self.args.length > 0) || (separator = self.args[0].evaluate(compressor)) !== self.args[0]) { + for(var separator, first, elements = [], consts = [], i = 0, len = exp.expression.elements.length; i < len; i++){ + var el = exp.expression.elements[i]; + if (el instanceof AST_Expansion) break EXIT; + var value = el.evaluate(compressor); + value !== el ? consts.push(value) : (consts.length > 0 && (elements.push(make_node(AST_String, self, { value: consts.join(separator) - })), 0 == elements.length) return make_node(AST_String, self, { - value: "" + })), consts.length = 0), elements.push(el)); + } + if (consts.length > 0 && elements.push(make_node(AST_String, self, { + value: consts.join(separator) + })), 0 == elements.length) return make_node(AST_String, self, { + value: "" + }); + if (1 == elements.length) { + if (elements[0].is_string(compressor)) return elements[0]; + return make_node(AST_Binary, elements[0], { + operator: "+", + left: make_node(AST_String, self, { + value: "" + }), + right: elements[0] }); - if (1 == elements.length) { - if (elements[0].is_string(compressor)) return elements[0]; - return make_node(AST_Binary, elements[0], { - operator: "+", - left: make_node(AST_String, self, { - value: "" - }), - right: elements[0] - }); - } - if ("" == separator) return first = elements[0].is_string(compressor) || elements[1].is_string(compressor) ? elements.shift() : make_node(AST_String, self, { - value: "" - }), elements.reduce(function(prev, el) { - return make_node(AST_Binary, el, { - operator: "+", - left: prev, - right: el - }); - }, first).optimize(compressor); - var node = self.clone(); - return node.expression = node.expression.clone(), node.expression.expression = node.expression.expression.clone(), node.expression.expression.elements = elements, best_of(compressor, self, node); } + if ("" == separator) return first = elements[0].is_string(compressor) || elements[1].is_string(compressor) ? elements.shift() : make_node(AST_String, self, { + value: "" + }), elements.reduce(function(prev, el) { + return make_node(AST_Binary, el, { + operator: "+", + left: prev, + right: el + }); + }, first).optimize(compressor); + var node = self.clone(); + return node.expression = node.expression.clone(), node.expression.expression = node.expression.expression.clone(), node.expression.expression.elements = elements, best_of(compressor, self, node); } - break; + } } } }); From 40b0eec9400d4405f63b1dcf43d2afe0fa0773f4 Mon Sep 17 00:00:00 2001 From: austaras Date: Thu, 21 Apr 2022 15:48:09 +0800 Subject: [PATCH 24/27] fix --- crates/swc_ecma_utils/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/swc_ecma_utils/src/lib.rs b/crates/swc_ecma_utils/src/lib.rs index 814fb84d71b3..8761da9d64af 100644 --- a/crates/swc_ecma_utils/src/lib.rs +++ b/crates/swc_ecma_utils/src/lib.rs @@ -392,7 +392,7 @@ impl StmtExt for Stmt { cons, alt: Some(alt), .. - }) if cons.terminates() && alt.terminates() => return true, + }) => return cons.terminates() && alt.terminates(), _ => (), } From deb73ecd0f4867281dbfb0c5887bbf87bcf75760 Mon Sep 17 00:00:00 2001 From: austaras Date: Thu, 21 Apr 2022 16:23:17 +0800 Subject: [PATCH 25/27] fix --- crates/swc_ecma_minifier/src/compress/optimize/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index bc886303d31b..6a65073cf219 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -2554,9 +2554,7 @@ where if stmts.len() != orig_len { self.changed = true; - if cfg!(feature = "debug") { - debug!("Dropping statements after a control keyword"); - } + report_change!("Dropping statements after a control keyword"); } return; From f79b1c1d61e2eaeaa0f4157f7e2b05965f765917 Mon Sep 17 00:00:00 2001 From: austaras Date: Thu, 21 Apr 2022 16:25:13 +0800 Subject: [PATCH 26/27] order --- crates/swc_ecma_minifier/src/compress/optimize/switches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 77e199ca607a..5ef03a9993b4 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -93,8 +93,6 @@ where self.optimize_switch_cases(&mut cases); - self.changed = true; - let var_ids: Vec = var_ids .into_iter() .map(|name| VarDeclarator { @@ -105,6 +103,8 @@ where }) .collect(); + self.changed = true; + if cases.len() == 1 && (cases[0].test.is_none() || exact.is_some()) && !contains_nested_break(&cases[0]) From 7b6afa80b35f111b596c9a3cfb225dce53a72923 Mon Sep 17 00:00:00 2001 From: austaras Date: Thu, 21 Apr 2022 16:26:48 +0800 Subject: [PATCH 27/27] fix --- crates/swc_ecma_minifier/src/compress/optimize/switches.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs index 5ef03a9993b4..9774c4456284 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/switches.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/switches.rs @@ -79,6 +79,7 @@ where let last = cases.last_mut().unwrap(); self.changed = true; + report_change!("switches: Turn exact match into default"); // so that following pass could turn it into if else if let Some(test) = last.test.take() { prepend(&mut last.cons, test.into_stmt())