From 9e4dea6663eaba794fb4793318865892eecce910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 10 Mar 2022 00:43:01 +0900 Subject: [PATCH] feat(es/minifier): Improve dropping of unused vars (#3923) --- ...orWithAnyAndEveryType_es2015.2.minified.js | 7 +- ...ratorWithAnyAndEveryType_es5.2.minified.js | 4 +- ...orWithInvalidOperands_es2015.2.minified.js | 2 +- ...ratorWithInvalidOperands_es5.2.minified.js | 2 +- ...atorWithNumberAndEnum_es2015.2.minified.js | 4 +- ...peratorWithNumberAndEnum_es5.2.minified.js | 4 +- ...pressionContextualTyping_es5.2.minified.js | 2 +- ...OperatorWithEnumUnion_es2015.2.minified.js | 4 +- ...ticOperatorWithEnumUnion_es5.2.minified.js | 4 +- ...ithDiscriminatedUnion_es2015.2.minified.js | 4 +- ...atWithDiscriminatedUnion_es5.2.minified.js | 4 +- ...estCommonTypeOfTuple2_es2015.2.minified.js | 4 +- ...clarationsAndAssignments_es5.2.minified.js | 2 +- ...ingPatternAndAssignment2_es5.2.minified.js | 4 +- ...ingPatternAndAssignment3_es5.2.minified.js | 8 +- ...destructuringControlFlow_es5.2.minified.js | 2 +- ...ParameterDeclaration1ES5_es5.2.minified.js | 6 +- ...rDeclaration1ES5iterable_es5.2.minified.js | 6 +- ...ParameterDeclaration1ES6_es5.2.minified.js | 4 +- ...ParameterDeclaration3ES5_es5.2.minified.js | 4 +- ...rDeclaration3ES5iterable_es5.2.minified.js | 4 +- ...ParameterDeclaration3ES6_es5.2.minified.js | 4 +- ...gVariableDeclaration1ES5_es5.2.minified.js | 8 +- ...eDeclaration1ES5iterable_es5.2.minified.js | 8 +- ...gVariableDeclaration1ES6_es5.2.minified.js | 8 +- ...ringVariableDeclaration2_es5.2.minified.js | 2 +- .../emitArrowFunctionES6_es2015.2.minified.js | 2 +- ...otationAndInitializer_es2015.2.minified.js | 3 +- ...OperatorWithEnumUnion_es2015.2.minified.js | 8 +- ...ionOperatorWithEnumUnion_es5.2.minified.js | 8 +- ...ationOperatorWithEnum_es2015.2.minified.js | 4 +- ...ntiationOperatorWithEnum_es5.2.minified.js | 4 +- ...orWithInvalidOperands_es2015.2.minified.js | 2 +- ...ratorWithInvalidOperands_es5.2.minified.js | 2 +- ...ValueAndValidOperands_es2015.2.minified.js | 6 +- ...ullValueAndValidOperands_es5.2.minified.js | 6 +- ...ValueAndValidOperands_es2015.2.minified.js | 6 +- ...nedValueAndValidOperands_es5.2.minified.js | 6 +- ...tsMultipleInvalidDecl_es2015.2.minified.js | 6 +- ...mentsMultipleInvalidDecl_es5.2.minified.js | 3 +- ...entsMultipleValidDecl_es2015.2.minified.js | 5 +- ...tementsMultipleValidDecl_es5.2.minified.js | 2 +- .../forStatements_es2015.2.minified.js | 6 +- .../forStatements_es5.2.minified.js | 2 +- ...sionContextualTyping1_es2015.2.minified.js | 3 +- ...ratedContextualTyping_es2015.2.minified.js | 4 +- ...eneratedContextualTyping_es5.2.minified.js | 4 +- ...ructorTypedArguments5_es2015.2.minified.js | 4 +- ...nstructorTypedArguments5_es5.2.minified.js | 4 +- ...nctionTypedArguments3_es2015.2.minified.js | 4 +- ...hFunctionTypedArguments3_es5.2.minified.js | 4 +- ...nctionTypedArguments4_es2015.2.minified.js | 4 +- ...tructorTypedArguments_es2015.2.minified.js | 4 +- ...unctionTypedArguments_es2015.2.minified.js | 3 +- ...nericContextualTypes1_es2015.2.minified.js | 3 +- ...BlockscopedProperties_es2015.2.minified.js | 1 - ...hisBlockscopedProperties_es5.2.minified.js | 1 - ...sUnknownNoImplicitAny_es2015.2.minified.js | 2 +- ...ThisUnknownNoImplicitAny_es5.2.minified.js | 2 +- .../globalThisUnknown_es2015.2.minified.js | 2 +- .../globalThisUnknown_es5.2.minified.js | 2 +- ...balThisVarDeclaration_es2015.2.minified.js | 2 +- ...globalThisVarDeclaration_es5.2.minified.js | 2 +- ...ogeneousArrayLiterals_es2015.2.minified.js | 7 - ...terogeneousArrayLiterals_es5.2.minified.js | 3 +- .../importTypeInJSDoc_es2015.2.minified.js | 3 +- ...orWithInvalidOperands_es2015.2.minified.js | 4 +- ...ratorWithInvalidOperands_es5.2.minified.js | 4 +- ...embersFromAssignments_es2015.2.minified.js | 8 +- ...ectionReductionStrict_es2015.2.minified.js | 3 +- ...ectionTypeOverloading_es2015.2.minified.js | 3 +- ...ersectionTypeOverloading_es5.2.minified.js | 3 +- ...eVariableDeclarations_es2015.2.minified.js | 4 +- .../iterableArrayPattern20_es5.2.minified.js | 2 +- .../iterableArrayPattern25_es5.2.minified.js | 2 +- .../iterableArrayPattern26_es5.2.minified.js | 2 +- .../iterableArrayPattern27_es5.2.minified.js | 2 +- .../iterableArrayPattern28_es5.2.minified.js | 2 +- .../iterableArrayPattern29_es5.2.minified.js | 2 +- .../iterableArrayPattern30_es5.2.minified.js | 2 +- ...iterableArrayPattern9_es2015.2.minified.js | 1 - ...eusesInputNodeInEmit2_es2015.2.minified.js | 3 +- ...sWithPrivateOverloads_es2015.2.minified.js | 3 +- ...ublicPrivateOverloads_es2015.2.minified.js | 3 +- .../newTarget.es5_es2015.2.minified.js | 3 +- .../newTarget.es6_es2015.2.minified.js | 3 +- ...ncheckedIndexedAccess_es2015.2.minified.js | 4 +- ...opertiesWithModuleES6_es2015.2.minified.js | 2 +- ...dPropertiesWithModuleES6_es5.2.minified.js | 2 +- ...dPropertiesWithModule_es2015.2.minified.js | 2 +- ...handPropertiesWithModule_es5.2.minified.js | 2 +- .../objectRestParameterES5_es5.2.minified.js | 4 +- .../objectRestParameter_es5.2.minified.js | 4 +- .../objectRest_es2015.2.minified.js | 7 +- .../objectRest_es5.2.minified.js | 4 +- ...HidingMembersOfObject_es2015.2.minified.js | 4 +- ...sizedContexualTyping1_es2015.2.minified.js | 3 +- ...sizedContexualTyping2_es2015.2.minified.js | 3 +- ...tVersusArrowFunction1_es2015.2.minified.js | 2 +- ...CastVersusArrowFunction1_es5.2.minified.js | 2 +- ...ComputedPropertyName2_es2015.2.minified.js | 1 - ...ComputedPropertyName2_es2015.2.minified.js | 1 - ...serES5SymbolProperty6_es2015.2.minified.js | 1 - ...serES5SymbolProperty7_es2015.2.minified.js | 1 - .../parserNotRegex2_es2015.2.minified.js | 2 +- .../parserNotRegex2_es5.2.minified.js | 2 +- ...parserSymbolProperty6_es2015.2.minified.js | 1 - ...parserSymbolProperty7_es2015.2.minified.js | 1 - ...esFromContextualTypes_es2015.2.minified.js | 5 +- .../strictTupleLength_es2015.2.minified.js | 4 +- .../strictTupleLength_es5.2.minified.js | 4 +- ...hConstructSignatures3_es2015.2.minified.js | 5 +- ...WithConstructSignatures3_es5.2.minified.js | 5 +- ...thConstructSignatures_es2015.2.minified.js | 4 +- ...gWithConstructSignatures_es5.2.minified.js | 4 +- ...PropertyAccessNoError_es2015.2.minified.js | 3 +- ...rSymbolIndexedAccess2_es2015.2.minified.js | 1 - ...mbolDeclarationEmit10_es2015.2.minified.js | 1 - ...mbolDeclarationEmit13_es2015.2.minified.js | 1 - ...mbolDeclarationEmit14_es2015.2.minified.js | 1 - ...ymbolDeclarationEmit2_es2015.2.minified.js | 1 - ...ymbolDeclarationEmit3_es2015.2.minified.js | 1 - ...ymbolDeclarationEmit4_es2015.2.minified.js | 1 - ...ymbolDeclarationEmit8_es2015.2.minified.js | 1 - ...ymbolDeclarationEmit9_es2015.2.minified.js | 1 - .../symbolProperty20_es2015.2.minified.js | 1 - .../symbolProperty23_es2015.2.minified.js | 1 - .../symbolProperty24_es2015.2.minified.js | 1 - .../symbolProperty25_es2015.2.minified.js | 1 - .../symbolProperty26_es2015.2.minified.js | 1 - .../symbolProperty27_es2015.2.minified.js | 1 - .../symbolProperty28_es2015.2.minified.js | 3 +- .../symbolProperty29_es2015.2.minified.js | 1 - .../symbolProperty30_es2015.2.minified.js | 1 - .../symbolProperty31_es2015.2.minified.js | 1 - .../symbolProperty32_es2015.2.minified.js | 1 - .../symbolProperty33_es2015.2.minified.js | 1 - .../symbolProperty34_es2015.2.minified.js | 1 - .../symbolProperty36_es2015.2.minified.js | 1 - .../symbolProperty39_es2015.2.minified.js | 1 - .../symbolProperty42_es2015.2.minified.js | 1 - .../symbolProperty44_es2015.2.minified.js | 1 - .../symbolProperty45_es2015.2.minified.js | 1 - .../symbolProperty50_es2015.2.minified.js | 2 - .../symbolProperty52_es2015.2.minified.js | 2 +- .../symbolProperty54_es2015.2.minified.js | 1 - .../symbolProperty58_es2015.2.minified.js | 1 - .../symbolProperty5_es2015.2.minified.js | 1 - .../symbolProperty6_es2015.2.minified.js | 1 - .../symbolType3_es2015.2.minified.js | 2 +- .../symbolType3_es5.2.minified.js | 2 +- ...lAndMemberExpressionsES6_es5.2.minified.js | 3 +- ...CallAndMemberExpressions_es5.2.minified.js | 3 +- .../thisTypeInFunctions_es2015.2.minified.js | 3 +- ...ithDifferingOverloads_es2015.2.minified.js | 4 +- ...esWithDifferingOverloads_es5.2.minified.js | 4 +- ...InstanceOfOnInterface_es2015.2.minified.js | 4 +- ...GuardOfFormInstanceOf_es2015.2.minified.js | 2 +- ...eParameterConstraint2_es2015.2.minified.js | 3 +- ...TypeParameterConstraint2_es5.2.minified.js | 3 +- .../typeofThis_es2015.2.minified.js | 2 +- .../react-instantsearch/2/output/index.js | 4 +- crates/swc_ecma_minifier/src/compress/mod.rs | 16 +- .../src/compress/optimize/mod.rs | 114 ++++--- .../src/compress/optimize/unused.rs | 286 ++++++++++++------ .../src/compress/pure/misc.rs | 30 +- .../src/compress/pure/mod.rs | 3 + .../src/compress/util/mod.rs | 39 +++ crates/swc_ecma_minifier/src/debug.rs | 30 +- crates/swc_ecma_minifier/tests/TODO.txt | 12 - .../fixture/issues/2257/full/output.js | 12 +- .../fixture/issues/emotion/react/1/output.js | 4 +- .../issues/react-instancesearch/004/output.js | 4 +- .../pages/index-cb36c1bf7f830e3c/output.js | 8 +- .../785-e1932cc99ac3bb67/output.js | 2 +- crates/swc_ecma_minifier/tests/golden.txt | 12 + .../tests/projects/output/angular-1.2.5.js | 2 +- .../tests/projects/output/react-dom-17.0.2.js | 6 +- .../tests/single-pass/1/output.js | 4 +- 179 files changed, 607 insertions(+), 465 deletions(-) diff --git a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType_es2015.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType_es2015.2.minified.js index 50c38d40573..d5605f3e7f6 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType_es2015.2.minified.js @@ -1,10 +1,9 @@ var E, M; -!function(E) { +(function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c"; -}(E || (E = {})), function(M1) { +})(E || (E = {})), function(M1) { var a; M1.a = a; }(M || (M = {})), new class { static foo() {} -}(), E.a, (a)=>a -; +}(), E.a; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType_es5.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType_es5.2.minified.js index 4b8d694958c..9c206dc94be 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithAnyAndEveryType_es5.2.minified.js @@ -6,9 +6,9 @@ var E, M, C = function() { } return C.foo = function() {}, C; }(); -!function(E) { +(function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c"; -}(E || (E = {})), function(M1) { +})(E || (E = {})), function(M1) { var a; M1.a = a; }(M || (M = {})), new C(), E.a; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands_es2015.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands_es2015.2.minified.js index 5428904cbf9..e63c88fa234 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands_es2015.2.minified.js @@ -7,4 +7,4 @@ class C { })(E || (E = {})), function(M1) { var a; M1.a = a; -}(M || (M = {})), {} + {}, E.a + new C(), E.a + C.foo(), E.a; +}(M || (M = {})), E.a + new C(), E.a + C.foo(), E.a; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands_es5.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands_es5.2.minified.js index 3398a24f9b0..f344e265ed7 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithInvalidOperands_es5.2.minified.js @@ -11,4 +11,4 @@ var E, M, C = function() { })(E || (E = {})), function(M1) { var a; M1.a = a; -}(M || (M = {})), {} + {}, E.a + new C(), E.a + C.foo(), E.a; +}(M || (M = {})), E.a + new C(), E.a + C.foo(), E.a; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum_es2015.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum_es2015.2.minified.js index 4b6c744665f..9f97cf14a1d 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum_es2015.2.minified.js @@ -1,6 +1,6 @@ var E, F; -!function(E) { +(function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), function(F) { +})(E || (E = {})), function(F) { F[F.c = 0] = "c", F[F.d = 1] = "d"; }(F || (F = {})), E.a, E.a + E.b, E.a + E.b, E.a + F.c; diff --git a/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum_es5.2.minified.js b/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum_es5.2.minified.js index 4b6c744665f..9f97cf14a1d 100644 --- a/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/additionOperatorWithNumberAndEnum_es5.2.minified.js @@ -1,6 +1,6 @@ var E, F; -!function(E) { +(function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), function(F) { +})(E || (E = {})), function(F) { F[F.c = 0] = "c", F[F.d = 1] = "d"; }(F || (F = {})), E.a, E.a + E.b, E.a + E.b, E.a + F.c; diff --git a/crates/swc/tests/tsc-references/argumentExpressionContextualTyping_es5.2.minified.js b/crates/swc/tests/tsc-references/argumentExpressionContextualTyping_es5.2.minified.js index a5ce9020465..b6c424c781d 100644 --- a/crates/swc/tests/tsc-references/argumentExpressionContextualTyping_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/argumentExpressionContextualTyping_es5.2.minified.js @@ -1,6 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function foo(param) { - var _x = swcHelpers.slicedToArray(param.x, 2), a = _x[0], b = _x[1], _y = param.y; + var _x = swcHelpers.slicedToArray(param.x, 2), _y = (_x[0], _x[1], param.y); _y.c, _y.d, _y.e; } function baz(x) {} diff --git a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion_es2015.2.minified.js b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion_es2015.2.minified.js index ffecb44370a..bb4ddcc7b25 100644 --- a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion_es2015.2.minified.js @@ -1,6 +1,6 @@ var E, F; -!function(E) { +(function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), function(F) { +})(E || (E = {})), function(F) { F[F.c = 0] = "c", F[F.d = 1] = "d"; }(F || (F = {})), E.a, E.a, E.a * E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a / E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a % E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a - E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a << E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a >> E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a >>> E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a & E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a ^ E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a | E.b, E.a, E.b, E.b, E.b; diff --git a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion_es5.2.minified.js b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion_es5.2.minified.js index ffecb44370a..bb4ddcc7b25 100644 --- a/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/arithmeticOperatorWithEnumUnion_es5.2.minified.js @@ -1,6 +1,6 @@ var E, F; -!function(E) { +(function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), function(F) { +})(E || (E = {})), function(F) { F[F.c = 0] = "c", F[F.d = 1] = "d"; }(F || (F = {})), E.a, E.a, E.a * E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a / E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a % E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a - E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a << E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a >> E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a >>> E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a & E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a ^ E.b, E.a, E.b, E.b, E.b, E.a, E.a, E.a | E.b, E.a, E.b, E.b, E.b; diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es2015.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es2015.2.minified.js index a5e1b052fcd..57dacecfc77 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es2015.2.minified.js @@ -1,4 +1,4 @@ -var Example1, Example2, Example3, Example4, Example5, GH14865, GH12052, GH39357; +var Example1, Example2, Example3, Example4, Example5, GH14865, GH12052; Example1 || (Example1 = {}), t = s, Example2 || (Example2 = {}), t = s, Example3 || (Example3 = {}), t = s, Example4 || (Example4 = {}), t = s, Example5 || (Example5 = {}), t = s, function(GH14865) { let b; b.type, b = { @@ -14,4 +14,4 @@ Example1 || (Example1 = {}), t = s, Example2 || (Example2 = {}), t = s, Example3 type: void 0 }; good.type = getAxisType(); -}(GH12052 || (GH12052 = {})), GH39357 || (GH39357 = {}); +}(GH12052 || (GH12052 = {})); diff --git a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es5.2.minified.js b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es5.2.minified.js index b112f093369..edcdcb3cda0 100644 --- a/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/assignmentCompatWithDiscriminatedUnion_es5.2.minified.js @@ -1,4 +1,4 @@ -var Example1, Example2, Example3, Example4, Example5, GH14865, GH12052, GH39357; +var Example1, Example2, Example3, Example4, Example5, GH14865, GH12052; Example1 || (Example1 = {}), t = s, Example2 || (Example2 = {}), t = s, Example3 || (Example3 = {}), t = s, Example4 || (Example4 = {}), t = s, Example5 || (Example5 = {}), t = s, function(GH14865) { var b; b.type, b = { @@ -10,4 +10,4 @@ Example1 || (Example1 = {}), t = s, Example2 || (Example2 = {}), t = s, Example3 return "categorical"; }; getAxisType(), void 0 = getAxisType(); -}(GH12052 || (GH12052 = {})), GH39357 || (GH39357 = {}); +}(GH12052 || (GH12052 = {})); diff --git a/crates/swc/tests/tsc-references/bestCommonTypeOfTuple2_es2015.2.minified.js b/crates/swc/tests/tsc-references/bestCommonTypeOfTuple2_es2015.2.minified.js index e1af0396baf..1343f9e4196 100644 --- a/crates/swc/tests/tsc-references/bestCommonTypeOfTuple2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/bestCommonTypeOfTuple2_es2015.2.minified.js @@ -1,2 +1,2 @@ -var t3, t4, t5; -(void 0)[4], (void 0)[4], t3[4], t4[2], t5[2]; +var t2, t3, t4, t5; +(void 0)[4], t2[4], t3[4], t4[2], t5[2]; diff --git a/crates/swc/tests/tsc-references/declarationsAndAssignments_es5.2.minified.js b/crates/swc/tests/tsc-references/declarationsAndAssignments_es5.2.minified.js index 767836a3f96..0a524a7ea47 100644 --- a/crates/swc/tests/tsc-references/declarationsAndAssignments_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/declarationsAndAssignments_es5.2.minified.js @@ -1,7 +1,7 @@ var M; import * as swcHelpers from "@swc/helpers"; function f14(param) { - var _param = swcHelpers.slicedToArray(param, 2), tmp = _param[0], ref = swcHelpers.slicedToArray(_param[1], 2), tmp1 = ref[0], ref1 = ref[1]; + var _param = swcHelpers.slicedToArray(param, 2), ref = (_param[0], swcHelpers.slicedToArray(_param[1], 2)), ref1 = (ref[0], ref[1]); ref1.x, ref1.y; } function f17(param) { diff --git a/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment2_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment2_es5.2.minified.js index cc1734b1c70..6f8d6a999f7 100644 --- a/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment2_es5.2.minified.js @@ -1,7 +1,7 @@ import * as swcHelpers from "@swc/helpers"; -var ref = [], a0 = swcHelpers.slicedToArray(ref[0], 1)[0], ref1 = swcHelpers.slicedToArray(ref[1], 1), ref2 = swcHelpers.slicedToArray(ref1[0], 1); +var ref = [], ref1 = (swcHelpers.slicedToArray(ref[0], 1)[0], swcHelpers.slicedToArray(ref[1], 1)), ref2 = swcHelpers.slicedToArray(ref1[0], 1); ref2[0]; -var _undefined = swcHelpers.slicedToArray(void 0, 2), ref3 = swcHelpers.slicedToArray(_undefined[0], 1), a2 = ref3[0], ref4 = swcHelpers.slicedToArray(_undefined[1], 1), ref5 = swcHelpers.slicedToArray(ref4[0], 1); +var _undefined = swcHelpers.slicedToArray(void 0, 2), ref3 = swcHelpers.slicedToArray(_undefined[0], 1), ref4 = (ref3[0], swcHelpers.slicedToArray(_undefined[1], 1)), ref5 = swcHelpers.slicedToArray(ref4[0], 1); ref5[0]; var ref6 = swcHelpers.slicedToArray([ 1, diff --git a/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment3_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment3_es5.2.minified.js index c326b7e0961..71eadc5daee 100644 --- a/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringArrayBindingPatternAndAssignment3_es5.2.minified.js @@ -1,13 +1,11 @@ import * as swcHelpers from "@swc/helpers"; var ref = [ 1 -], a = ref[0], tmp = ref[1], ref1 = [ +], ref1 = (ref[0], ref[1], [ 1 -]; -ref1[0], ref1[1], ref1[2]; -var ref2 = [ +]), ref2 = (ref1[0], ref1[1], ref1[2], [ 1 -]; +]); ref2[0], ref2[1], ref2[2], ref2[3], function(param) { var _param = swcHelpers.slicedToArray(param, 2); _param[0], _param[1]; diff --git a/crates/swc/tests/tsc-references/destructuringControlFlow_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringControlFlow_es5.2.minified.js index eca2ed68870..c8e158db034 100644 --- a/crates/swc/tests/tsc-references/destructuringControlFlow_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringControlFlow_es5.2.minified.js @@ -2,4 +2,4 @@ import * as swcHelpers from "@swc/helpers"; var ref = [ "foo" ]; -ref[0], ref[1].toUpperCase(); +(ref[0], ref[1]).toUpperCase(); diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES5_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES5_es5.2.minified.js index bd64b93e689..a99e89aaded 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES5_es5.2.minified.js @@ -1,6 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function a1(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref1 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref1 = swcHelpers.slicedToArray(ref[0], 1); ref1[0]; } function b2() { @@ -19,7 +19,7 @@ function c2(param) { param.z; } function c5(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref2 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref2 = swcHelpers.slicedToArray(ref[0], 1); ref2[0]; } a1([ @@ -74,7 +74,7 @@ a1([ void 0 ] ] - ], 3), a = swcHelpers.slicedToArray(ref[0], 1)[0], b = ref[1], ref3 = swcHelpers.slicedToArray(ref[2], 1), ref4 = swcHelpers.slicedToArray(ref3[0], 2); + ], 3), ref3 = (swcHelpers.slicedToArray(ref[0], 1)[0], ref[1], swcHelpers.slicedToArray(ref[2], 1)), ref4 = swcHelpers.slicedToArray(ref3[0], 2); ref4[0], ref4[1]; }([ [ diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES5iterable_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES5iterable_es5.2.minified.js index bd64b93e689..a99e89aaded 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES5iterable_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES5iterable_es5.2.minified.js @@ -1,6 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function a1(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref1 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref1 = swcHelpers.slicedToArray(ref[0], 1); ref1[0]; } function b2() { @@ -19,7 +19,7 @@ function c2(param) { param.z; } function c5(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref2 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref2 = swcHelpers.slicedToArray(ref[0], 1); ref2[0]; } a1([ @@ -74,7 +74,7 @@ a1([ void 0 ] ] - ], 3), a = swcHelpers.slicedToArray(ref[0], 1)[0], b = ref[1], ref3 = swcHelpers.slicedToArray(ref[2], 1), ref4 = swcHelpers.slicedToArray(ref3[0], 2); + ], 3), ref3 = (swcHelpers.slicedToArray(ref[0], 1)[0], ref[1], swcHelpers.slicedToArray(ref[2], 1)), ref4 = swcHelpers.slicedToArray(ref3[0], 2); ref4[0], ref4[1]; }([ [ diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES6_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES6_es5.2.minified.js index 94ae118ac46..f6e3cca1033 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration1ES6_es5.2.minified.js @@ -1,6 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function a1(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref1 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref1 = swcHelpers.slicedToArray(ref[0], 1); ref1[0]; } function b2() { @@ -19,7 +19,7 @@ function c2(param) { param.z; } function c5(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref2 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref2 = swcHelpers.slicedToArray(ref[0], 1); ref2[0]; } a1([ diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5_es5.2.minified.js index 14becac6d3b..ed2fe20c76a 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5_es5.2.minified.js @@ -1,6 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function a10(param) { - var _param = swcHelpers.toArray(param), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref1 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.toArray(param), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref1 = swcHelpers.slicedToArray(ref[0], 1); ref1[0], _param.slice(3); } var E, E1, array = [ @@ -19,7 +19,7 @@ function foo1() { }(swcHelpers.toConsumableArray(array)), (function() { for(var _len = arguments.length, x = new Array(_len), _key = 0; _key < _len; _key++)x[_key] = arguments[_key]; }).apply(void 0, swcHelpers.toConsumableArray(array)), function(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref2 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref2 = swcHelpers.slicedToArray(ref[0], 1); ref2[0]; }([ 1, diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable_es5.2.minified.js index 14becac6d3b..ed2fe20c76a 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES5iterable_es5.2.minified.js @@ -1,6 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function a10(param) { - var _param = swcHelpers.toArray(param), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref1 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.toArray(param), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref1 = swcHelpers.slicedToArray(ref[0], 1); ref1[0], _param.slice(3); } var E, E1, array = [ @@ -19,7 +19,7 @@ function foo1() { }(swcHelpers.toConsumableArray(array)), (function() { for(var _len = arguments.length, x = new Array(_len), _key = 0; _key < _len; _key++)x[_key] = arguments[_key]; }).apply(void 0, swcHelpers.toConsumableArray(array)), function(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref2 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref2 = swcHelpers.slicedToArray(ref[0], 1); ref2[0]; }([ 1, diff --git a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6_es5.2.minified.js index 14becac6d3b..ed2fe20c76a 100644 --- a/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringParameterDeclaration3ES6_es5.2.minified.js @@ -1,6 +1,6 @@ import * as swcHelpers from "@swc/helpers"; function a10(param) { - var _param = swcHelpers.toArray(param), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref1 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.toArray(param), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref1 = swcHelpers.slicedToArray(ref[0], 1); ref1[0], _param.slice(3); } var E, E1, array = [ @@ -19,7 +19,7 @@ function foo1() { }(swcHelpers.toConsumableArray(array)), (function() { for(var _len = arguments.length, x = new Array(_len), _key = 0; _key < _len; _key++)x[_key] = arguments[_key]; }).apply(void 0, swcHelpers.toConsumableArray(array)), function(param) { - var _param = swcHelpers.slicedToArray(param, 3), a = _param[0], b = _param[1], ref = swcHelpers.slicedToArray(_param[2], 1), ref2 = swcHelpers.slicedToArray(ref[0], 1); + var _param = swcHelpers.slicedToArray(param, 3), ref = (_param[0], _param[1], swcHelpers.slicedToArray(_param[2], 1)), ref2 = swcHelpers.slicedToArray(ref[0], 1); ref2[0]; }([ 1, diff --git a/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES5_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES5_es5.2.minified.js index dcedd58910f..9a756659fd0 100644 --- a/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES5_es5.2.minified.js @@ -9,14 +9,14 @@ var ref = [ void 0, void 0, void 0 -], tmp1 = ref[0], tmp2 = ref[1], tmp3 = ref[2], ref1 = swcHelpers.slicedToArray([ +], ref1 = (ref[0], ref[1], ref[2], swcHelpers.slicedToArray([ 1, "string" ].concat(swcHelpers.toConsumableArray([ !0, !1, !0 -])), 2); +])), 2)); ref1[0], ref1[1]; var _e = swcHelpers.slicedToArray([ 1, @@ -25,12 +25,12 @@ var _e = swcHelpers.slicedToArray([ b1: 4, b4: 0 } -], 3), e1 = _e[0], e2 = _e[1], tmp4 = _e[2], _f = swcHelpers.slicedToArray([ +], 3), _f = (_e[0], _e[1], _e[2], swcHelpers.slicedToArray([ 1, 2, { f3: 4, f5: 0 } -], 3), f1 = _f[0], f2 = _f[1], ref2 = _f[2]; +], 3)), ref2 = (_f[0], _f[1], _f[2]); ref2.f3, ref2.f5; diff --git a/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES5iterable_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES5iterable_es5.2.minified.js index dcedd58910f..9a756659fd0 100644 --- a/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES5iterable_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES5iterable_es5.2.minified.js @@ -9,14 +9,14 @@ var ref = [ void 0, void 0, void 0 -], tmp1 = ref[0], tmp2 = ref[1], tmp3 = ref[2], ref1 = swcHelpers.slicedToArray([ +], ref1 = (ref[0], ref[1], ref[2], swcHelpers.slicedToArray([ 1, "string" ].concat(swcHelpers.toConsumableArray([ !0, !1, !0 -])), 2); +])), 2)); ref1[0], ref1[1]; var _e = swcHelpers.slicedToArray([ 1, @@ -25,12 +25,12 @@ var _e = swcHelpers.slicedToArray([ b1: 4, b4: 0 } -], 3), e1 = _e[0], e2 = _e[1], tmp4 = _e[2], _f = swcHelpers.slicedToArray([ +], 3), _f = (_e[0], _e[1], _e[2], swcHelpers.slicedToArray([ 1, 2, { f3: 4, f5: 0 } -], 3), f1 = _f[0], f2 = _f[1], ref2 = _f[2]; +], 3)), ref2 = (_f[0], _f[1], _f[2]); ref2.f3, ref2.f5; diff --git a/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES6_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES6_es5.2.minified.js index dcedd58910f..9a756659fd0 100644 --- a/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringVariableDeclaration1ES6_es5.2.minified.js @@ -9,14 +9,14 @@ var ref = [ void 0, void 0, void 0 -], tmp1 = ref[0], tmp2 = ref[1], tmp3 = ref[2], ref1 = swcHelpers.slicedToArray([ +], ref1 = (ref[0], ref[1], ref[2], swcHelpers.slicedToArray([ 1, "string" ].concat(swcHelpers.toConsumableArray([ !0, !1, !0 -])), 2); +])), 2)); ref1[0], ref1[1]; var _e = swcHelpers.slicedToArray([ 1, @@ -25,12 +25,12 @@ var _e = swcHelpers.slicedToArray([ b1: 4, b4: 0 } -], 3), e1 = _e[0], e2 = _e[1], tmp4 = _e[2], _f = swcHelpers.slicedToArray([ +], 3), _f = (_e[0], _e[1], _e[2], swcHelpers.slicedToArray([ 1, 2, { f3: 4, f5: 0 } -], 3), f1 = _f[0], f2 = _f[1], ref2 = _f[2]; +], 3)), ref2 = (_f[0], _f[1], _f[2]); ref2.f3, ref2.f5; diff --git a/crates/swc/tests/tsc-references/destructuringVariableDeclaration2_es5.2.minified.js b/crates/swc/tests/tsc-references/destructuringVariableDeclaration2_es5.2.minified.js index ea7998260f5..9985f554dde 100644 --- a/crates/swc/tests/tsc-references/destructuringVariableDeclaration2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/destructuringVariableDeclaration2_es5.2.minified.js @@ -10,5 +10,5 @@ var ref1 = [ c3: 4, c5: 0 } -], c1 = ref1[0], c2 = ref1[1], ref2 = ref1[2]; +], ref2 = (ref1[0], ref1[1], ref1[2]); ref2.c3, ref2.c5, ref1.slice(4); diff --git a/crates/swc/tests/tsc-references/emitArrowFunctionES6_es2015.2.minified.js b/crates/swc/tests/tsc-references/emitArrowFunctionES6_es2015.2.minified.js index 46ce3305b3d..0631d937c5b 100644 --- a/crates/swc/tests/tsc-references/emitArrowFunctionES6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/emitArrowFunctionES6_es2015.2.minified.js @@ -1,4 +1,4 @@ function foo(func) {} foo(()=>!0 ), foo(()=>!1 -), ([{ value , done }])=>{}; +); diff --git a/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es2015.2.minified.js b/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es2015.2.minified.js index c12611cc247..352122a3abe 100644 --- a/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/everyTypeWithAnnotationAndInitializer_es2015.2.minified.js @@ -7,5 +7,4 @@ class C { return x.toString(); }; }(M || (M = {})), new Date(12), new Object(), new C(), new C(), new class { -}(), new C(), new M.A(), (x)=>"this is a string" -; +}(), new C(), new M.A(); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion_es2015.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion_es2015.2.minified.js index e08bc74cfa0..4f7242c7470 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion_es2015.2.minified.js @@ -1,6 +1,6 @@ -var E, F, a, b, c; -!function(E) { +var E, F, a, b; +(function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), function(F) { +})(E || (E = {})), function(F) { F[F.c = 0] = "c", F[F.d = 1] = "d"; -}(F || (F = {})), Math.pow(c, a), Math.pow(c, b), Math.pow(c, c), Math.pow(a, c), Math.pow(b, c), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, E.b), Math.pow(E.a, 1), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(1, E.b); +}(F || (F = {})), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, E.b), Math.pow(E.a, 1), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(1, E.b); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion_es5.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion_es5.2.minified.js index e08bc74cfa0..4f7242c7470 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnumUnion_es5.2.minified.js @@ -1,6 +1,6 @@ -var E, F, a, b, c; -!function(E) { +var E, F, a, b; +(function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), function(F) { +})(E || (E = {})), function(F) { F[F.c = 0] = "c", F[F.d = 1] = "d"; -}(F || (F = {})), Math.pow(c, a), Math.pow(c, b), Math.pow(c, c), Math.pow(a, c), Math.pow(b, c), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, E.b), Math.pow(E.a, 1), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(1, E.b); +}(F || (F = {})), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, E.b), Math.pow(E.a, 1), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(1, E.b); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum_es2015.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum_es2015.2.minified.js index 8f73188a2fe..085e3d49b42 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum_es2015.2.minified.js @@ -1,4 +1,4 @@ -var E, a, b, c; +var E, a, b; !function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), Math.pow(c, a), Math.pow(c, b), Math.pow(c, c), Math.pow(a, c), Math.pow(b, c), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, E.b), Math.pow(E.a, 1), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(1, E.b); +}(E || (E = {})), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, E.b), Math.pow(E.a, 1), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(1, E.b); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum_es5.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum_es5.2.minified.js index 8f73188a2fe..085e3d49b42 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithEnum_es5.2.minified.js @@ -1,4 +1,4 @@ -var E, a, b, c; +var E, a, b; !function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -}(E || (E = {})), Math.pow(c, a), Math.pow(c, b), Math.pow(c, c), Math.pow(a, c), Math.pow(b, c), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, E.b), Math.pow(E.a, 1), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(1, E.b); +}(E || (E = {})), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, E.b), Math.pow(E.a, 1), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(1, E.b); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands_es2015.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands_es2015.2.minified.js index 8b7382d73cd..428586e951d 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands_es2015.2.minified.js @@ -1,4 +1,4 @@ var E, a, b, c, d, e, f; !function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c"; -}(E || (E = {})), Math.pow(a, a), Math.pow(a, b), Math.pow(a, c), Math.pow(a, d), Math.pow(a, e), Math.pow(a, f), Math.pow(b, a), Math.pow(b, b), Math.pow(b, c), Math.pow(b, d), Math.pow(b, e), Math.pow(b, f), Math.pow(c, a), Math.pow(c, b), Math.pow(c, c), Math.pow(c, d), Math.pow(c, e), Math.pow(c, f), Math.pow(d, a), Math.pow(d, b), Math.pow(d, c), Math.pow(d, d), Math.pow(d, e), Math.pow(d, f), Math.pow(e, a), Math.pow(e, b), Math.pow(e, c), Math.pow(e, d), Math.pow(e, e), Math.pow(e, f), Math.pow(f, a), Math.pow(f, b), Math.pow(f, c), Math.pow(f, d), Math.pow(f, e), Math.pow(f, f), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, c), Math.pow(E.a, d), Math.pow(E.a, e), Math.pow(E.a, f), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(c, E.b), Math.pow(d, E.b), Math.pow(e, E.b), Math.pow(f, E.b); +}(E || (E = {})), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, c), Math.pow(E.a, d), Math.pow(E.a, e), Math.pow(E.a, f), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(c, E.b), Math.pow(d, E.b), Math.pow(e, E.b), Math.pow(f, E.b); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands_es5.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands_es5.2.minified.js index 8b7382d73cd..428586e951d 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithInvalidOperands_es5.2.minified.js @@ -1,4 +1,4 @@ var E, a, b, c, d, e, f; !function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b", E[E.c = 2] = "c"; -}(E || (E = {})), Math.pow(a, a), Math.pow(a, b), Math.pow(a, c), Math.pow(a, d), Math.pow(a, e), Math.pow(a, f), Math.pow(b, a), Math.pow(b, b), Math.pow(b, c), Math.pow(b, d), Math.pow(b, e), Math.pow(b, f), Math.pow(c, a), Math.pow(c, b), Math.pow(c, c), Math.pow(c, d), Math.pow(c, e), Math.pow(c, f), Math.pow(d, a), Math.pow(d, b), Math.pow(d, c), Math.pow(d, d), Math.pow(d, e), Math.pow(d, f), Math.pow(e, a), Math.pow(e, b), Math.pow(e, c), Math.pow(e, d), Math.pow(e, e), Math.pow(e, f), Math.pow(f, a), Math.pow(f, b), Math.pow(f, c), Math.pow(f, d), Math.pow(f, e), Math.pow(f, f), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, c), Math.pow(E.a, d), Math.pow(E.a, e), Math.pow(E.a, f), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(c, E.b), Math.pow(d, E.b), Math.pow(e, E.b), Math.pow(f, E.b); +}(E || (E = {})), Math.pow(E.a, a), Math.pow(E.a, b), Math.pow(E.a, c), Math.pow(E.a, d), Math.pow(E.a, e), Math.pow(E.a, f), Math.pow(a, E.b), Math.pow(b, E.b), Math.pow(c, E.b), Math.pow(d, E.b), Math.pow(e, E.b), Math.pow(f, E.b); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithNullValueAndValidOperands_es2015.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithNullValueAndValidOperands_es2015.2.minified.js index d0a3e57c065..42614f7f5a2 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithNullValueAndValidOperands_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithNullValueAndValidOperands_es2015.2.minified.js @@ -1,4 +1,4 @@ -var E, a, b; -(function(E) { +var E; +!function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -})(E || (E = {})), Math.pow(null, a), Math.pow(null, b), Math.pow(null, E.a), Math.pow(a, null), Math.pow(b, null), Math.pow(E.b, null); +}(E || (E = {})), Math.pow(null, E.a), Math.pow(E.b, null); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithNullValueAndValidOperands_es5.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithNullValueAndValidOperands_es5.2.minified.js index d0a3e57c065..42614f7f5a2 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithNullValueAndValidOperands_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithNullValueAndValidOperands_es5.2.minified.js @@ -1,4 +1,4 @@ -var E, a, b; -(function(E) { +var E; +!function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -})(E || (E = {})), Math.pow(null, a), Math.pow(null, b), Math.pow(null, E.a), Math.pow(a, null), Math.pow(b, null), Math.pow(E.b, null); +}(E || (E = {})), Math.pow(null, E.a), Math.pow(E.b, null); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithUndefinedValueAndValidOperands_es2015.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithUndefinedValueAndValidOperands_es2015.2.minified.js index f040523b656..4c02b5fb66e 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithUndefinedValueAndValidOperands_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithUndefinedValueAndValidOperands_es2015.2.minified.js @@ -1,4 +1,4 @@ -var E, a, b; -(function(E) { +var E; +!function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -})(E || (E = {})), Math.pow(void 0, a), Math.pow(void 0, b), Math.pow(void 0, E.a), Math.pow(a, void 0), Math.pow(b, void 0), Math.pow(E.b, void 0); +}(E || (E = {})), Math.pow(void 0, E.a), Math.pow(E.b, void 0); diff --git a/crates/swc/tests/tsc-references/exponentiationOperatorWithUndefinedValueAndValidOperands_es5.2.minified.js b/crates/swc/tests/tsc-references/exponentiationOperatorWithUndefinedValueAndValidOperands_es5.2.minified.js index f040523b656..4c02b5fb66e 100644 --- a/crates/swc/tests/tsc-references/exponentiationOperatorWithUndefinedValueAndValidOperands_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/exponentiationOperatorWithUndefinedValueAndValidOperands_es5.2.minified.js @@ -1,4 +1,4 @@ -var E, a, b; -(function(E) { +var E; +!function(E) { E[E.a = 0] = "a", E[E.b = 1] = "b"; -})(E || (E = {})), Math.pow(void 0, a), Math.pow(void 0, b), Math.pow(void 0, E.a), Math.pow(a, void 0), Math.pow(b, void 0), Math.pow(E.b, void 0); +}(E || (E = {})), Math.pow(void 0, E.a), Math.pow(E.b, void 0); diff --git a/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es2015.2.minified.js b/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es2015.2.minified.js index 0e27b55a260..1671e42ec59 100644 --- a/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es2015.2.minified.js @@ -12,6 +12,7 @@ for(!function(M1) { }(M || (M = {}));;); for(var M;;); for(;;); +for(;;); for(new C();;); for(new D();;); for(;;); @@ -19,12 +20,11 @@ for(;;); for(new C();;); for(new C2();;); for(;;); -for((x)=>"" -;;); +for(;;); for(;;); for(;;); for(new C(), new C2(), new D();;); for(new D();;); for(new Array();;); for(;;); -for(M.A;;); +M.A; diff --git a/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es5.2.minified.js b/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es5.2.minified.js index 27ad98f34ab..833c50086ae 100644 --- a/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatementsMultipleInvalidDecl_es5.2.minified.js @@ -25,6 +25,7 @@ for(!function(M1) { }(M || (M = {}));;); for(;;); for(;;); +for(;;); for(new C();;); for(new D();;); for(;;); @@ -39,4 +40,4 @@ for(new C(), new C2(), new D();;); for(new D();;); for(new Array();;); for(;;); -for(M.A;;); +M.A; diff --git a/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es2015.2.minified.js b/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es2015.2.minified.js index e1b3699019f..cbaab968b8e 100644 --- a/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es2015.2.minified.js @@ -9,8 +9,8 @@ for(;;); for(;;); for(;;); for(;;); -for((s)=>3 -;;); +for(;;); +for(;;); for(;;); for(;;); for(;;); @@ -20,4 +20,3 @@ for(;;); for(;;); for(;;); for(new Array();;); -for(;;); diff --git a/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es5.2.minified.js b/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es5.2.minified.js index 9f6a58bf17c..cbaab968b8e 100644 --- a/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatementsMultipleValidDecl_es5.2.minified.js @@ -18,5 +18,5 @@ for(;;); for(;;); for(;;); for(;;); +for(;;); for(new Array();;); -for(;;); diff --git a/crates/swc/tests/tsc-references/forStatements_es2015.2.minified.js b/crates/swc/tests/tsc-references/forStatements_es2015.2.minified.js index aee892cfe2f..52ed56cf9ec 100644 --- a/crates/swc/tests/tsc-references/forStatements_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatements_es2015.2.minified.js @@ -8,6 +8,7 @@ class C { }(M || (M = {})); for(var M;;); for(;;); +for(;;); for(new Date(12);;); for(new Object();;); for(;;); @@ -21,9 +22,6 @@ for(;;); for(new C();;); for(;;); for(;;); -for((x)=>2 -;;); +for(;;); for(;;); for(new M.A();;); -for((x)=>"this is a string" -;;); diff --git a/crates/swc/tests/tsc-references/forStatements_es5.2.minified.js b/crates/swc/tests/tsc-references/forStatements_es5.2.minified.js index 4a4bf4548b6..0cfac73eabc 100644 --- a/crates/swc/tests/tsc-references/forStatements_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/forStatements_es5.2.minified.js @@ -16,6 +16,7 @@ for(!function(M1) { }; }(M || (M = {}));;); for(;;); +for(;;); for(new Date(12);;); for(new Object();;); for(;;); @@ -31,4 +32,3 @@ for(;;); for(;;); for(;;); for(new M.A();;); -for(;;); diff --git a/crates/swc/tests/tsc-references/functionExpressionContextualTyping1_es2015.2.minified.js b/crates/swc/tests/tsc-references/functionExpressionContextualTyping1_es2015.2.minified.js index d7064d6e4dd..3b4e45c10a1 100644 --- a/crates/swc/tests/tsc-references/functionExpressionContextualTyping1_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/functionExpressionContextualTyping1_es2015.2.minified.js @@ -1,5 +1,4 @@ var E; !function(E) { E[E.red = 0] = "red", E[E.blue = 1] = "blue"; -}(E || (E = {})), (num, str)=>(num.toExponential(), 0) -; +}(E || (E = {})); diff --git a/crates/swc/tests/tsc-references/generatedContextualTyping_es2015.2.minified.js b/crates/swc/tests/tsc-references/generatedContextualTyping_es2015.2.minified.js index 0fa67479d41..d397587d06a 100644 --- a/crates/swc/tests/tsc-references/generatedContextualTyping_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/generatedContextualTyping_es2015.2.minified.js @@ -1,7 +1,7 @@ class Base { } new Base(); -var x181, x184, x187, x188, x189, x190, x191, x192, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, d1 = new class extends Base { +var x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, d1 = new class extends Base { }(), d2 = new class extends Base { }(); (class { @@ -184,7 +184,7 @@ var x181, x184, x187, x188, x189, x190, x191, x192, x193, x194, x195, x196, x197 d1, d2 ] -}, x181 || (x181 = {}), x184 || (x184 = {}), x187 || (x187 = {}), x188 || (x188 = {}), x189 || (x189 = {}), x190 || (x190 = {}), x191 || (x191 = {}), x192 || (x192 = {}), (x193 || (x193 = {})).t = ()=>[ +}, (x193 || (x193 = {})).t = ()=>[ d1, d2 ] diff --git a/crates/swc/tests/tsc-references/generatedContextualTyping_es5.2.minified.js b/crates/swc/tests/tsc-references/generatedContextualTyping_es5.2.minified.js index 32f460aee55..cb482172eaf 100644 --- a/crates/swc/tests/tsc-references/generatedContextualTyping_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/generatedContextualTyping_es5.2.minified.js @@ -1,5 +1,5 @@ import * as swcHelpers from "@swc/helpers"; -var x187, x188, x189, x190, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, Base = function() { +var x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203, x204, Base = function() { "use strict"; swcHelpers.classCallCheck(this, Base); }, Derived1 = function(Base1) { @@ -865,7 +865,7 @@ var x85 = function() { }; swcHelpers.classCallCheck(this, x120), this.parm = parm; }; -x187 || (x187 = {}), x188 || (x188 = {}), x189 || (x189 = {}), x190 || (x190 = {}), (x193 || (x193 = {})).t = function() { +(x193 || (x193 = {})).t = function() { return [ d1, d2 diff --git a/crates/swc/tests/tsc-references/genericCallWithConstructorTypedArguments5_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithConstructorTypedArguments5_es2015.2.minified.js index c93276bc02f..653fb822b03 100644 --- a/crates/swc/tests/tsc-references/genericCallWithConstructorTypedArguments5_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithConstructorTypedArguments5_es2015.2.minified.js @@ -1,5 +1,5 @@ -var arg, arg3, arg4, arg5; +var arg, arg2, arg3, arg4, arg5; function foo(arg1) { return new arg1.cb(null); } -foo(arg), foo(void 0), foo(arg3), foo(arg), foo(arg4), foo(arg5); +foo(arg), foo(arg2), foo(arg3), foo(arg), foo(arg4), foo(arg5); diff --git a/crates/swc/tests/tsc-references/genericCallWithConstructorTypedArguments5_es5.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithConstructorTypedArguments5_es5.2.minified.js index c93276bc02f..653fb822b03 100644 --- a/crates/swc/tests/tsc-references/genericCallWithConstructorTypedArguments5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithConstructorTypedArguments5_es5.2.minified.js @@ -1,5 +1,5 @@ -var arg, arg3, arg4, arg5; +var arg, arg2, arg3, arg4, arg5; function foo(arg1) { return new arg1.cb(null); } -foo(arg), foo(void 0), foo(arg3), foo(arg), foo(arg4), foo(arg5); +foo(arg), foo(arg2), foo(arg3), foo(arg), foo(arg4), foo(arg5); diff --git a/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments3_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments3_es2015.2.minified.js index a9972bc775b..64b779fd87a 100644 --- a/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments3_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments3_es2015.2.minified.js @@ -1,3 +1,3 @@ -var a; +var b; function foo4(cb) {} -foo4(a), foo4(void 0); +foo4(void 0), foo4(b); diff --git a/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments3_es5.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments3_es5.2.minified.js index a9972bc775b..64b779fd87a 100644 --- a/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments3_es5.2.minified.js @@ -1,3 +1,3 @@ -var a; +var b; function foo4(cb) {} -foo4(a), foo4(void 0); +foo4(void 0), foo4(b); diff --git a/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments4_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments4_es2015.2.minified.js index a9972bc775b..64b779fd87a 100644 --- a/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments4_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithFunctionTypedArguments4_es2015.2.minified.js @@ -1,3 +1,3 @@ -var a; +var b; function foo4(cb) {} -foo4(a), foo4(void 0); +foo4(void 0), foo4(b); diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments_es2015.2.minified.js index 4be3ff6f620..79d48da965e 100644 --- a/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedConstructorTypedArguments_es2015.2.minified.js @@ -1,10 +1,10 @@ var NonGenericParameter, GenericParameter; !function(NonGenericParameter) { - var a; + var b; function foo4(cb) { return new cb(null); } - foo4(a), foo4(void 0); + foo4(void 0), foo4(b); }(NonGenericParameter || (NonGenericParameter = {})), function(GenericParameter) { var a, b, c, c2; function foo5(cb) { diff --git a/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments_es2015.2.minified.js index d3c8a2eba76..5f5138bbf31 100644 --- a/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallWithOverloadedFunctionTypedArguments_es2015.2.minified.js @@ -1,10 +1,9 @@ var NonGenericParameter, GenericParameter; !function(NonGenericParameter) { - var a; function foo4(cb) { return cb; } - foo4(a), foo4((x)=>x + foo4(void 0), foo4((x)=>x ), foo4((x)=>x ); }(NonGenericParameter || (NonGenericParameter = {})), function(GenericParameter) { diff --git a/crates/swc/tests/tsc-references/genericContextualTypes1_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericContextualTypes1_es2015.2.minified.js index ed2ed7e8a53..1c52ec9c9c7 100644 --- a/crates/swc/tests/tsc-references/genericContextualTypes1_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericContextualTypes1_es2015.2.minified.js @@ -18,5 +18,4 @@ arrayMap((x)=>x.length }) ), arrayFilter((x)=>x.length > 10 ), arrayFilter((x)=>x.value > 10 -), flip(zip), (a)=>a -; +), flip(zip); diff --git a/crates/swc/tests/tsc-references/globalThisBlockscopedProperties_es2015.2.minified.js b/crates/swc/tests/tsc-references/globalThisBlockscopedProperties_es2015.2.minified.js index 1b90462f675..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/globalThisBlockscopedProperties_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisBlockscopedProperties_es2015.2.minified.js @@ -1 +0,0 @@ -globalThis.x, globalThis.y, globalThis.z, globalThis.x, globalThis.y, globalThis.z, globalThis.Float64Array, globalThis.Infinity; diff --git a/crates/swc/tests/tsc-references/globalThisBlockscopedProperties_es5.2.minified.js b/crates/swc/tests/tsc-references/globalThisBlockscopedProperties_es5.2.minified.js index 1b90462f675..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/globalThisBlockscopedProperties_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisBlockscopedProperties_es5.2.minified.js @@ -1 +0,0 @@ -globalThis.x, globalThis.y, globalThis.z, globalThis.x, globalThis.y, globalThis.z, globalThis.Float64Array, globalThis.Infinity; diff --git a/crates/swc/tests/tsc-references/globalThisUnknownNoImplicitAny_es2015.2.minified.js b/crates/swc/tests/tsc-references/globalThisUnknownNoImplicitAny_es2015.2.minified.js index 7612ef1b994..64b2f7519f9 100644 --- a/crates/swc/tests/tsc-references/globalThisUnknownNoImplicitAny_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisUnknownNoImplicitAny_es2015.2.minified.js @@ -1 +1 @@ -win.hi, this.hi, globalThis.hi, win.hi, this.hi, globalThis.hi; +win.hi, this.hi, win.hi, this.hi; diff --git a/crates/swc/tests/tsc-references/globalThisUnknownNoImplicitAny_es5.2.minified.js b/crates/swc/tests/tsc-references/globalThisUnknownNoImplicitAny_es5.2.minified.js index 7612ef1b994..64b2f7519f9 100644 --- a/crates/swc/tests/tsc-references/globalThisUnknownNoImplicitAny_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisUnknownNoImplicitAny_es5.2.minified.js @@ -1 +1 @@ -win.hi, this.hi, globalThis.hi, win.hi, this.hi, globalThis.hi; +win.hi, this.hi, win.hi, this.hi; diff --git a/crates/swc/tests/tsc-references/globalThisUnknown_es2015.2.minified.js b/crates/swc/tests/tsc-references/globalThisUnknown_es2015.2.minified.js index 7612ef1b994..64b2f7519f9 100644 --- a/crates/swc/tests/tsc-references/globalThisUnknown_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisUnknown_es2015.2.minified.js @@ -1 +1 @@ -win.hi, this.hi, globalThis.hi, win.hi, this.hi, globalThis.hi; +win.hi, this.hi, win.hi, this.hi; diff --git a/crates/swc/tests/tsc-references/globalThisUnknown_es5.2.minified.js b/crates/swc/tests/tsc-references/globalThisUnknown_es5.2.minified.js index 7612ef1b994..64b2f7519f9 100644 --- a/crates/swc/tests/tsc-references/globalThisUnknown_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisUnknown_es5.2.minified.js @@ -1 +1 @@ -win.hi, this.hi, globalThis.hi, win.hi, this.hi, globalThis.hi; +win.hi, this.hi, win.hi, this.hi; diff --git a/crates/swc/tests/tsc-references/globalThisVarDeclaration_es2015.2.minified.js b/crates/swc/tests/tsc-references/globalThisVarDeclaration_es2015.2.minified.js index 598983c00e1..a90e68a45f0 100644 --- a/crates/swc/tests/tsc-references/globalThisVarDeclaration_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisVarDeclaration_es2015.2.minified.js @@ -1 +1 @@ -this.a, this.b, globalThis.a, globalThis.b, self.a, self.b, window.a, window.b, top.a, top.b, this.a, this.b, globalThis.a, globalThis.b, self.a, self.b, window.a, window.b, top.a, top.b; +this.a, this.b, self.a, self.b, window.a, window.b, top.a, top.b, this.a, this.b, self.a, self.b, window.a, window.b, top.a, top.b; diff --git a/crates/swc/tests/tsc-references/globalThisVarDeclaration_es5.2.minified.js b/crates/swc/tests/tsc-references/globalThisVarDeclaration_es5.2.minified.js index 598983c00e1..a90e68a45f0 100644 --- a/crates/swc/tests/tsc-references/globalThisVarDeclaration_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/globalThisVarDeclaration_es5.2.minified.js @@ -1 +1 @@ -this.a, this.b, globalThis.a, globalThis.b, self.a, self.b, window.a, window.b, top.a, top.b, this.a, this.b, globalThis.a, globalThis.b, self.a, self.b, window.a, window.b, top.a, top.b; +this.a, this.b, self.a, self.b, window.a, window.b, top.a, top.b, this.a, this.b, self.a, self.b, window.a, window.b, top.a, top.b; diff --git a/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es2015.2.minified.js b/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es2015.2.minified.js index c120e7cd161..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es2015.2.minified.js @@ -1,7 +0,0 @@ -var base, derived, derived2, WithContextualType; -class Base { -} -class Derived extends Base { -} -Derived || (Derived = {}), WithContextualType || (WithContextualType = {}), ()=>derived2 -; diff --git a/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es5.2.minified.js b/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es5.2.minified.js index 52e9f6be561..ed6f8f9b52e 100644 --- a/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/heterogeneousArrayLiterals_es5.2.minified.js @@ -1,5 +1,5 @@ import * as swcHelpers from "@swc/helpers"; -var WithContextualType, Base = function() { +var Base = function() { "use strict"; swcHelpers.classCallCheck(this, Base); }, Derived = function(Base1) { @@ -19,4 +19,3 @@ var WithContextualType, Base = function() { } return Derived2; }(Base); -Derived || (Derived = {}), WithContextualType || (WithContextualType = {}); diff --git a/crates/swc/tests/tsc-references/importTypeInJSDoc_es2015.2.minified.js b/crates/swc/tests/tsc-references/importTypeInJSDoc_es2015.2.minified.js index ec86d1321dc..98790811318 100644 --- a/crates/swc/tests/tsc-references/importTypeInJSDoc_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/importTypeInJSDoc_es2015.2.minified.js @@ -1,5 +1,4 @@ module.exports = MyClass, new Foo({ doer: Foo.Bar -}), (r)=>r -; +}); export { }; diff --git a/crates/swc/tests/tsc-references/inOperatorWithInvalidOperands_es2015.2.minified.js b/crates/swc/tests/tsc-references/inOperatorWithInvalidOperands_es2015.2.minified.js index b311e2c2b36..2ae9c10009d 100644 --- a/crates/swc/tests/tsc-references/inOperatorWithInvalidOperands_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/inOperatorWithInvalidOperands_es2015.2.minified.js @@ -1,4 +1,4 @@ -var E, x, a1, a5, a6, b1, b2, b3, b4, b5; +var E, x; !function(E) { E[E.a = 0] = "a"; -}(E || (E = {})), a1 in x, (void 0) in x, (void 0) in x, (void 0) in x, null in x, (void 0) in x, E.a in x, !1 in x, {} in x, a5 in x, a6 in x, x in b1, x in b2, x in b3, x in b4, x in b5, x in 0, x in !1, x in "", x in null, x in void 0, {} in ""; +}(E || (E = {})), E.a in x; diff --git a/crates/swc/tests/tsc-references/inOperatorWithInvalidOperands_es5.2.minified.js b/crates/swc/tests/tsc-references/inOperatorWithInvalidOperands_es5.2.minified.js index 6a200f6fdfd..920454c5b8b 100644 --- a/crates/swc/tests/tsc-references/inOperatorWithInvalidOperands_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/inOperatorWithInvalidOperands_es5.2.minified.js @@ -1,8 +1,8 @@ import * as swcHelpers from "@swc/helpers"; -var E, x, a1, a2, a3, a4, a5, a6, b1, b2, b3, b4, b5, Foo = function() { +var E, x, Foo = function() { "use strict"; swcHelpers.classCallCheck(this, Foo); }; !function(E) { E[E.a = 0] = "a"; -}(E || (E = {})), a1 in x, a2 in x, a3 in x, a4 in x, null in x, (void 0) in x, E.a in x, !1 in x, {} in x, a5 in x, a6 in x, x in b1, x in b2, x in b3, x in b4, x in b5, x in 0, x in !1, x in "", x in null, x in void 0, {} in ""; +}(E || (E = {})), E.a in x; diff --git a/crates/swc/tests/tsc-references/inferringClassMembersFromAssignments_es2015.2.minified.js b/crates/swc/tests/tsc-references/inferringClassMembersFromAssignments_es2015.2.minified.js index 924a79bdf84..269421ac421 100644 --- a/crates/swc/tests/tsc-references/inferringClassMembersFromAssignments_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/inferringClassMembersFromAssignments_es2015.2.minified.js @@ -1,8 +1,6 @@ class C { method() { - Math.random() ? (this.inMethod = 0, this.inMethodNullable = null) : (this.inMethod = "string", this.inMethodNullable = void 0), this.inMultiple = "string", this.inMultipleMethods = "string", ()=>{ - Math.random() ? this.inNestedArrowFunction = 0 : this.inNestedArrowFunction = "string"; - }; + Math.random() ? (this.inMethod = 0, this.inMethodNullable = null) : (this.inMethod = "string", this.inMethodNullable = void 0), this.inMultiple = "string", this.inMultipleMethods = "string"; } get() { Math.random() ? this.inGetter = 0 : this.inGetter = "string", this.inMultiple = !1, this.inMultipleMethods = !1; @@ -11,9 +9,7 @@ class C { Math.random() ? this.inSetter = 0 : this.inSetter = "string"; } static method() { - Math.random() ? this.inStaticMethod = 0 : this.inStaticMethod = "string", ()=>{ - Math.random() ? this.inStaticNestedArrowFunction = 0 : this.inStaticNestedArrowFunction = "string"; - }; + Math.random() ? this.inStaticMethod = 0 : this.inStaticMethod = "string"; } static get() { Math.random() ? this.inStaticGetter = 0 : this.inStaticGetter = "string"; diff --git a/crates/swc/tests/tsc-references/intersectionReductionStrict_es2015.2.minified.js b/crates/swc/tests/tsc-references/intersectionReductionStrict_es2015.2.minified.js index f87341af2fc..c014ee532a1 100644 --- a/crates/swc/tests/tsc-references/intersectionReductionStrict_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/intersectionReductionStrict_es2015.2.minified.js @@ -6,5 +6,4 @@ const x1 = { a: "foo", b: !0 }; -x1[k] = "bar", x2[k] = "bar", s2 = s1 = s2, t2 = t1 = t2, (t)=>t -; +x1[k] = "bar", x2[k] = "bar", s2 = s1 = s2, t2 = t1 = t2; diff --git a/crates/swc/tests/tsc-references/intersectionTypeOverloading_es2015.2.minified.js b/crates/swc/tests/tsc-references/intersectionTypeOverloading_es2015.2.minified.js index f534a999b00..51255e978f3 100644 --- a/crates/swc/tests/tsc-references/intersectionTypeOverloading_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/intersectionTypeOverloading_es2015.2.minified.js @@ -1 +1,2 @@ -(void 0)("abc"), (void 0)("abc"); +var gf; +(void 0)("abc"), gf("abc"); diff --git a/crates/swc/tests/tsc-references/intersectionTypeOverloading_es5.2.minified.js b/crates/swc/tests/tsc-references/intersectionTypeOverloading_es5.2.minified.js index f534a999b00..51255e978f3 100644 --- a/crates/swc/tests/tsc-references/intersectionTypeOverloading_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/intersectionTypeOverloading_es5.2.minified.js @@ -1 +1,2 @@ -(void 0)("abc"), (void 0)("abc"); +var gf; +(void 0)("abc"), gf("abc"); diff --git a/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es2015.2.minified.js b/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es2015.2.minified.js index b0c52c8c4a2..d495ef9ec2e 100644 --- a/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/invalidMultipleVariableDeclarations_es2015.2.minified.js @@ -5,9 +5,9 @@ class C2 extends C { } class D { } -(function(M1) { +!function(M1) { M1.A = class { }, M1.F2 = function(x) { return x.toString(); }; -})(M || (M = {})), new C(), new D(), new C(), new C2(), new C(), new C2(), new D(), new D(), new Array(), M.A; +}(M || (M = {})), new C(), new D(), new C(), new C2(), new C(), new C2(), new D(), new D(), new Array(), M.A; diff --git a/crates/swc/tests/tsc-references/iterableArrayPattern20_es5.2.minified.js b/crates/swc/tests/tsc-references/iterableArrayPattern20_es5.2.minified.js index ca4a93c8362..588ee252105 100644 --- a/crates/swc/tests/tsc-references/iterableArrayPattern20_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/iterableArrayPattern20_es5.2.minified.js @@ -30,5 +30,5 @@ var Bar = function() { (function() { for(var _len = arguments.length, _tmp = new Array(_len), _key = 0; _key < _len; _key++)_tmp[_key] = arguments[_key]; var __tmp = swcHelpers.slicedToArray(_tmp, 2); - void 0 === swcHelpers.slicedToArray(__tmp[0], 1)[0] && new Foo, void 0 === __tmp[1] && new Foo; + void 0 === (void 0 === swcHelpers.slicedToArray(__tmp[0], 1)[0] && new Foo, __tmp[1]) && new Foo; }).apply(void 0, swcHelpers.toConsumableArray(new FooArrayIterator)); diff --git a/crates/swc/tests/tsc-references/iterableArrayPattern25_es5.2.minified.js b/crates/swc/tests/tsc-references/iterableArrayPattern25_es5.2.minified.js index 82293349c78..33ca61380e6 100644 --- a/crates/swc/tests/tsc-references/iterableArrayPattern25_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/iterableArrayPattern25_es5.2.minified.js @@ -1,7 +1,7 @@ import * as swcHelpers from "@swc/helpers"; !function() { for(var _len = arguments.length, _tmp = new Array(_len), _key = 0; _key < _len; _key++)_tmp[_key] = arguments[_key]; - var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), k1 = ref[0], v1 = ref[1], ref1 = swcHelpers.slicedToArray(__tmp[1], 2); + var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), ref1 = (ref[0], ref[1], swcHelpers.slicedToArray(__tmp[1], 2)); ref1[0], ref1[1]; }(new Map([ [ diff --git a/crates/swc/tests/tsc-references/iterableArrayPattern26_es5.2.minified.js b/crates/swc/tests/tsc-references/iterableArrayPattern26_es5.2.minified.js index 82293349c78..33ca61380e6 100644 --- a/crates/swc/tests/tsc-references/iterableArrayPattern26_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/iterableArrayPattern26_es5.2.minified.js @@ -1,7 +1,7 @@ import * as swcHelpers from "@swc/helpers"; !function() { for(var _len = arguments.length, _tmp = new Array(_len), _key = 0; _key < _len; _key++)_tmp[_key] = arguments[_key]; - var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), k1 = ref[0], v1 = ref[1], ref1 = swcHelpers.slicedToArray(__tmp[1], 2); + var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), ref1 = (ref[0], ref[1], swcHelpers.slicedToArray(__tmp[1], 2)); ref1[0], ref1[1]; }(new Map([ [ diff --git a/crates/swc/tests/tsc-references/iterableArrayPattern27_es5.2.minified.js b/crates/swc/tests/tsc-references/iterableArrayPattern27_es5.2.minified.js index cf1b975a83e..a2085c8d8f9 100644 --- a/crates/swc/tests/tsc-references/iterableArrayPattern27_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/iterableArrayPattern27_es5.2.minified.js @@ -1,7 +1,7 @@ import * as swcHelpers from "@swc/helpers"; (function() { for(var _len = arguments.length, _tmp = new Array(_len), _key = 0; _key < _len; _key++)_tmp[_key] = arguments[_key]; - var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), k1 = ref[0], v1 = ref[1], ref1 = swcHelpers.slicedToArray(__tmp[1], 2); + var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), ref1 = (ref[0], ref[1], swcHelpers.slicedToArray(__tmp[1], 2)); ref1[0], ref1[1]; }).apply(void 0, swcHelpers.toConsumableArray(new Map([ [ diff --git a/crates/swc/tests/tsc-references/iterableArrayPattern28_es5.2.minified.js b/crates/swc/tests/tsc-references/iterableArrayPattern28_es5.2.minified.js index 77280003c13..60ecc7f8cde 100644 --- a/crates/swc/tests/tsc-references/iterableArrayPattern28_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/iterableArrayPattern28_es5.2.minified.js @@ -1,7 +1,7 @@ import * as swcHelpers from "@swc/helpers"; (function() { for(var _len = arguments.length, _tmp = new Array(_len), _key = 0; _key < _len; _key++)_tmp[_key] = arguments[_key]; - var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), k1 = ref[0], v1 = ref[1], ref1 = swcHelpers.slicedToArray(__tmp[1], 2); + var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), ref1 = (ref[0], ref[1], swcHelpers.slicedToArray(__tmp[1], 2)); ref1[0], ref1[1]; }).apply(void 0, swcHelpers.toConsumableArray(new Map([ [ diff --git a/crates/swc/tests/tsc-references/iterableArrayPattern29_es5.2.minified.js b/crates/swc/tests/tsc-references/iterableArrayPattern29_es5.2.minified.js index 6dbbf66736a..26c31e7445a 100644 --- a/crates/swc/tests/tsc-references/iterableArrayPattern29_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/iterableArrayPattern29_es5.2.minified.js @@ -1,7 +1,7 @@ import * as swcHelpers from "@swc/helpers"; (function() { for(var _len = arguments.length, _tmp = new Array(_len), _key = 0; _key < _len; _key++)_tmp[_key] = arguments[_key]; - var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), k1 = ref[0], v1 = ref[1], ref1 = swcHelpers.slicedToArray(__tmp[1], 2); + var __tmp = swcHelpers.slicedToArray(_tmp, 2), ref = swcHelpers.slicedToArray(__tmp[0], 2), ref1 = (ref[0], ref[1], swcHelpers.slicedToArray(__tmp[1], 2)); ref1[0], ref1[1]; }).apply(void 0, swcHelpers.toConsumableArray(new Map([ [ diff --git a/crates/swc/tests/tsc-references/iterableArrayPattern30_es5.2.minified.js b/crates/swc/tests/tsc-references/iterableArrayPattern30_es5.2.minified.js index f558f34a701..3595e16a4bc 100644 --- a/crates/swc/tests/tsc-references/iterableArrayPattern30_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/iterableArrayPattern30_es5.2.minified.js @@ -8,5 +8,5 @@ var ref = swcHelpers.slicedToArray(new Map([ "hello", !0 ] -]), 2), ref1 = swcHelpers.slicedToArray(ref[0], 2), k1 = ref1[0], v1 = ref1[1], ref2 = swcHelpers.slicedToArray(ref[1], 2); +]), 2), ref1 = swcHelpers.slicedToArray(ref[0], 2), ref2 = (ref1[0], ref1[1], swcHelpers.slicedToArray(ref[1], 2)); ref2[0], ref2[1]; diff --git a/crates/swc/tests/tsc-references/iterableArrayPattern9_es2015.2.minified.js b/crates/swc/tests/tsc-references/iterableArrayPattern9_es2015.2.minified.js index ae1f0b9df59..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/iterableArrayPattern9_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/iterableArrayPattern9_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.iterator; diff --git a/crates/swc/tests/tsc-references/jsDeclarationsParameterTagReusesInputNodeInEmit2_es2015.2.minified.js b/crates/swc/tests/tsc-references/jsDeclarationsParameterTagReusesInputNodeInEmit2_es2015.2.minified.js index 3a57e96f469..c2e56751a88 100644 --- a/crates/swc/tests/tsc-references/jsDeclarationsParameterTagReusesInputNodeInEmit2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/jsDeclarationsParameterTagReusesInputNodeInEmit2_es2015.2.minified.js @@ -3,5 +3,4 @@ class Base { } const BaseFactory = ()=>new Base() ; -BaseFactory.Base = Base, module.exports = BaseFactory, (base)=>base -; +BaseFactory.Base = Base, module.exports = BaseFactory; diff --git a/crates/swc/tests/tsc-references/memberFunctionsWithPrivateOverloads_es2015.2.minified.js b/crates/swc/tests/tsc-references/memberFunctionsWithPrivateOverloads_es2015.2.minified.js index b03909b4ca0..a2e1cd97552 100644 --- a/crates/swc/tests/tsc-references/memberFunctionsWithPrivateOverloads_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/memberFunctionsWithPrivateOverloads_es2015.2.minified.js @@ -1,4 +1,5 @@ -(void 0).foo(1), (void 0).foo(2), (class { +var d; +(void 0).foo(1), d.foo(2), (class { foo(x, y) {} bar(x, y) {} static foo(x, y) {} diff --git a/crates/swc/tests/tsc-references/memberFunctionsWithPublicPrivateOverloads_es2015.2.minified.js b/crates/swc/tests/tsc-references/memberFunctionsWithPublicPrivateOverloads_es2015.2.minified.js index c3d688082e2..47912f2b316 100644 --- a/crates/swc/tests/tsc-references/memberFunctionsWithPublicPrivateOverloads_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/memberFunctionsWithPublicPrivateOverloads_es2015.2.minified.js @@ -1 +1,2 @@ -(void 0).foo(1), (void 0).foo(2); +var d; +(void 0).foo(1), d.foo(2); diff --git a/crates/swc/tests/tsc-references/newTarget.es5_es2015.2.minified.js b/crates/swc/tests/tsc-references/newTarget.es5_es2015.2.minified.js index 487d006207b..96ad64bacea 100644 --- a/crates/swc/tests/tsc-references/newTarget.es5_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/newTarget.es5_es2015.2.minified.js @@ -2,8 +2,7 @@ constructor(){ this.d = function() { return new.target; - }, new.target, ()=>new.target - ; + }, new.target; } }).c = function() { return new.target; diff --git a/crates/swc/tests/tsc-references/newTarget.es6_es2015.2.minified.js b/crates/swc/tests/tsc-references/newTarget.es6_es2015.2.minified.js index 487d006207b..96ad64bacea 100644 --- a/crates/swc/tests/tsc-references/newTarget.es6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/newTarget.es6_es2015.2.minified.js @@ -2,8 +2,7 @@ constructor(){ this.d = function() { return new.target; - }, new.target, ()=>new.target - ; + }, new.target; } }).c = function() { return new.target; diff --git a/crates/swc/tests/tsc-references/noUncheckedIndexedAccess_es2015.2.minified.js b/crates/swc/tests/tsc-references/noUncheckedIndexedAccess_es2015.2.minified.js index 330309888eb..729604fa2b4 100644 --- a/crates/swc/tests/tsc-references/noUncheckedIndexedAccess_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/noUncheckedIndexedAccess_es2015.2.minified.js @@ -5,6 +5,4 @@ var NumericEnum1, NumericEnum2, StringEnum1; NumericEnum2[NumericEnum2.A = 0] = "A", NumericEnum2[NumericEnum2.B = 1] = "B", NumericEnum2[NumericEnum2.C = 2] = "C"; }(NumericEnum2 || (NumericEnum2 = {})), function(StringEnum1) { StringEnum1.A = "Alpha", StringEnum1.B = "Beta"; -}(StringEnum1 || (StringEnum1 = {})), strMap.foo, strMap.bar, strMap[0], strMap[0], strMap[0], strMap[0], strMap.foo, strMap[NumericEnum1.A], strMap[NumericEnum2.A], strMap[StringEnum1.A], strMap[StringEnum1.A], strMap[NumericEnum1.A], strMap[NumericEnum2.A], strMap[null], strMap.foo, strMap.bar, strMap.baz = void 0, strMap.qua = void 0, strMap[0] = void 0, strMap[null] = void 0, numMap[0], numMap[0], numMap[0], numMap[NumericEnum1.A], numMap[NumericEnum2.A], obj1.x, obj1.y, obj1.y, obj1.z, strMapUnion.foo, symbolMap[s], symbolMap[s] = void 0, nonEmptyStringArray[0], nonEmptyStringArray[1], (key)=>{ - myRecord2[key] = void 0, myRecord2[key]; -}; +}(StringEnum1 || (StringEnum1 = {})), strMap.foo, strMap.bar, strMap[0], strMap[0], strMap[0], strMap[0], strMap.foo, strMap[NumericEnum1.A], strMap[NumericEnum2.A], strMap[StringEnum1.A], strMap[StringEnum1.A], strMap[NumericEnum1.A], strMap[NumericEnum2.A], strMap[null], strMap.foo, strMap.bar, strMap.baz = void 0, strMap.qua = void 0, strMap[0] = void 0, strMap[null] = void 0, numMap[0], numMap[0], numMap[0], numMap[NumericEnum1.A], numMap[NumericEnum2.A], obj1.x, obj1.y, obj1.y, obj1.z, strMapUnion.foo, symbolMap[s], symbolMap[s] = void 0, nonEmptyStringArray[0], nonEmptyStringArray[1]; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6_es2015.2.minified.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6_es2015.2.minified.js index 45819dc79a9..ea1147bf505 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6_es2015.2.minified.js @@ -2,4 +2,4 @@ var m; !function(m1) { var x; m1.x = x; -}(m || (m = {})), m || (m = {}), x, x; +}(m || (m = {})), m || (m = {}), x; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6_es5.2.minified.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6_es5.2.minified.js index abf16cf688e..ea1147bf505 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModuleES6_es5.2.minified.js @@ -2,4 +2,4 @@ var m; !function(m1) { var x; m1.x = x; -}(m || (m = {})), m || (m = {}), x, x, x; +}(m || (m = {})), m || (m = {}), x; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule_es2015.2.minified.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule_es2015.2.minified.js index 45819dc79a9..ea1147bf505 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule_es2015.2.minified.js @@ -2,4 +2,4 @@ var m; !function(m1) { var x; m1.x = x; -}(m || (m = {})), m || (m = {}), x, x; +}(m || (m = {})), m || (m = {}), x; diff --git a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule_es5.2.minified.js b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule_es5.2.minified.js index abf16cf688e..ea1147bf505 100644 --- a/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/objectLiteralShorthandPropertiesWithModule_es5.2.minified.js @@ -2,4 +2,4 @@ var m; !function(m1) { var x; m1.x = x; -}(m || (m = {})), m || (m = {}), x, x, x; +}(m || (m = {})), m || (m = {}), x; diff --git a/crates/swc/tests/tsc-references/objectRestParameterES5_es5.2.minified.js b/crates/swc/tests/tsc-references/objectRestParameterES5_es5.2.minified.js index 286f8fa1b24..06ff52fb1f0 100644 --- a/crates/swc/tests/tsc-references/objectRestParameterES5_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/objectRestParameterES5_es5.2.minified.js @@ -10,9 +10,9 @@ suddenly(function(_param) { ka: 1 }, y: "noo" - }, _z = _param.x.z, nested = swcHelpers.objectWithoutProperties(_param.x, [ + }, nested = (_param.x.z, swcHelpers.objectWithoutProperties(_param.x, [ "z" - ]), rest = swcHelpers.objectWithoutProperties(_param, [ + ])), rest = swcHelpers.objectWithoutProperties(_param, [ "x" ]); return rest.y + nested.ka; diff --git a/crates/swc/tests/tsc-references/objectRestParameter_es5.2.minified.js b/crates/swc/tests/tsc-references/objectRestParameter_es5.2.minified.js index 286f8fa1b24..06ff52fb1f0 100644 --- a/crates/swc/tests/tsc-references/objectRestParameter_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/objectRestParameter_es5.2.minified.js @@ -10,9 +10,9 @@ suddenly(function(_param) { ka: 1 }, y: "noo" - }, _z = _param.x.z, nested = swcHelpers.objectWithoutProperties(_param.x, [ + }, nested = (_param.x.z, swcHelpers.objectWithoutProperties(_param.x, [ "z" - ]), rest = swcHelpers.objectWithoutProperties(_param, [ + ])), rest = swcHelpers.objectWithoutProperties(_param, [ "x" ]); return rest.y + nested.ka; diff --git a/crates/swc/tests/tsc-references/objectRest_es2015.2.minified.js b/crates/swc/tests/tsc-references/objectRest_es2015.2.minified.js index 13ccd6438a3..26d539b7d57 100644 --- a/crates/swc/tests/tsc-references/objectRest_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/objectRest_es2015.2.minified.js @@ -87,9 +87,4 @@ var { [computed]: stillNotGreat , [computed2]: soSo } = o, o = swcHelpers.objec _o = o, o = swcHelpers.objectWithoutProperties(_o, [ computed, computed2 -].map(swcHelpers.toPropertyKey)), ({ [computed]: stillNotGreat , [computed2]: soSo } = _o), (_param)=>{ - var { aNumber =12 } = _param; - return aNumber + swcHelpers.objectWithoutProperties(_param, [ - "aNumber" - ]).anythingGoes; -}; +].map(swcHelpers.toPropertyKey)), { [computed]: stillNotGreat , [computed2]: soSo } = _o; diff --git a/crates/swc/tests/tsc-references/objectRest_es5.2.minified.js b/crates/swc/tests/tsc-references/objectRest_es5.2.minified.js index 19c3925730c..4c9cb1094f3 100644 --- a/crates/swc/tests/tsc-references/objectRest_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/objectRest_es5.2.minified.js @@ -77,10 +77,10 @@ var i = removable; i.removed, swcHelpers.objectWithoutProperties(i, [ "removed" ]); -var computed = "b", computed2 = "a", stillNotGreat = o[computed], soSo = o[computed2], o = swcHelpers.objectWithoutProperties(o, [ +var computed = "b", computed2 = "a", o = (o[computed], o[computed2], swcHelpers.objectWithoutProperties(o, [ computed, computed2 -].map(swcHelpers.toPropertyKey)); +].map(swcHelpers.toPropertyKey))); _o = o, o = swcHelpers.objectWithoutProperties(_o, [ computed, computed2 diff --git a/crates/swc/tests/tsc-references/objectTypeHidingMembersOfObject_es2015.2.minified.js b/crates/swc/tests/tsc-references/objectTypeHidingMembersOfObject_es2015.2.minified.js index 47c19ea4a51..0639fe0bfb2 100644 --- a/crates/swc/tests/tsc-references/objectTypeHidingMembersOfObject_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/objectTypeHidingMembersOfObject_es2015.2.minified.js @@ -1,4 +1,4 @@ -var b; -(void 0).valueOf(), (void 0).valueOf(), ({ +var i, b; +(void 0).valueOf(), i.valueOf(), ({ valueOf: ()=>{} }).valueOf(), b.valueOf(); diff --git a/crates/swc/tests/tsc-references/parenthesizedContexualTyping1_es2015.2.minified.js b/crates/swc/tests/tsc-references/parenthesizedContexualTyping1_es2015.2.minified.js index 9678c11fb3d..0d20c29aed4 100644 --- a/crates/swc/tests/tsc-references/parenthesizedContexualTyping1_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parenthesizedContexualTyping1_es2015.2.minified.js @@ -23,5 +23,4 @@ fun((x)=>x , 10), fun(0.5 > Math.random() ? (x)=>x : (x)=>void 0 , (x)=>x -, 10), (y)=>void 0 -; +, 10); diff --git a/crates/swc/tests/tsc-references/parenthesizedContexualTyping2_es2015.2.minified.js b/crates/swc/tests/tsc-references/parenthesizedContexualTyping2_es2015.2.minified.js index 7ba25833b6c..472f3dc9b48 100644 --- a/crates/swc/tests/tsc-references/parenthesizedContexualTyping2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parenthesizedContexualTyping2_es2015.2.minified.js @@ -21,5 +21,4 @@ fun((x)=>(x(void 0), x) , 10), fun(0.5 > Math.random() ? (x)=>(x(void 0), x) : (x)=>void 0 , (x)=>(x(void 0), x) -, 10), (y)=>void 0 -; +, 10); diff --git a/crates/swc/tests/tsc-references/parserCastVersusArrowFunction1_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserCastVersusArrowFunction1_es2015.2.minified.js index 1f5285f4f0b..ddf4d83a165 100644 --- a/crates/swc/tests/tsc-references/parserCastVersusArrowFunction1_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserCastVersusArrowFunction1_es2015.2.minified.js @@ -1 +1 @@ -a, a, a, b, a = 1, b = 2; +a, a, a = 1, b = 2; diff --git a/crates/swc/tests/tsc-references/parserCastVersusArrowFunction1_es5.2.minified.js b/crates/swc/tests/tsc-references/parserCastVersusArrowFunction1_es5.2.minified.js index 1f5285f4f0b..ddf4d83a165 100644 --- a/crates/swc/tests/tsc-references/parserCastVersusArrowFunction1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserCastVersusArrowFunction1_es5.2.minified.js @@ -1 +1 @@ -a, a, a, b, a = 1, b = 2; +a, a, a = 1, b = 2; diff --git a/crates/swc/tests/tsc-references/parserComputedPropertyName2_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserComputedPropertyName2_es2015.2.minified.js index 302143a2e0d..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/parserComputedPropertyName2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserComputedPropertyName2_es2015.2.minified.js @@ -1 +0,0 @@ -e; diff --git a/crates/swc/tests/tsc-references/parserES5ComputedPropertyName2_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserES5ComputedPropertyName2_es2015.2.minified.js index 302143a2e0d..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/parserES5ComputedPropertyName2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserES5ComputedPropertyName2_es2015.2.minified.js @@ -1 +0,0 @@ -e; diff --git a/crates/swc/tests/tsc-references/parserES5SymbolProperty6_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserES5SymbolProperty6_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/parserES5SymbolProperty6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserES5SymbolProperty6_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/parserES5SymbolProperty7_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserES5SymbolProperty7_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/parserES5SymbolProperty7_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserES5SymbolProperty7_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/parserNotRegex2_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserNotRegex2_es2015.2.minified.js index 0e564f02752..46eea566a86 100644 --- a/crates/swc/tests/tsc-references/parserNotRegex2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserNotRegex2_es2015.2.minified.js @@ -1 +1 @@ -A, B(C(), ()=>{}, ()=>{}); +B(C(), ()=>{}, ()=>{}); diff --git a/crates/swc/tests/tsc-references/parserNotRegex2_es5.2.minified.js b/crates/swc/tests/tsc-references/parserNotRegex2_es5.2.minified.js index fc3338a13a4..da74ad6f471 100644 --- a/crates/swc/tests/tsc-references/parserNotRegex2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserNotRegex2_es5.2.minified.js @@ -1 +1 @@ -A, B(C(), function() {}, function() {}); +B(C(), function() {}, function() {}); diff --git a/crates/swc/tests/tsc-references/parserSymbolProperty6_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserSymbolProperty6_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/parserSymbolProperty6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserSymbolProperty6_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/parserSymbolProperty7_es2015.2.minified.js b/crates/swc/tests/tsc-references/parserSymbolProperty7_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/parserSymbolProperty7_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/parserSymbolProperty7_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/restTuplesFromContextualTypes_es2015.2.minified.js b/crates/swc/tests/tsc-references/restTuplesFromContextualTypes_es2015.2.minified.js index 580189521fb..976bb8a485e 100644 --- a/crates/swc/tests/tsc-references/restTuplesFromContextualTypes_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/restTuplesFromContextualTypes_es2015.2.minified.js @@ -11,7 +11,4 @@ f1((a, b, c)=>{}), f1((...x)=>{}), f1((a, ...x)=>{}), f1((a, b, ...x)=>{}), f1(( , (x)=>"" + x ), pipe((x, y)=>42 , (x)=>"" + x -), take(function(...rest) {}), (...params)=>{ - const [num, strOrErr] = params; - return num; -}; +), take(function(...rest) {}); diff --git a/crates/swc/tests/tsc-references/strictTupleLength_es2015.2.minified.js b/crates/swc/tests/tsc-references/strictTupleLength_es2015.2.minified.js index 3eef46febd8..6faa7e0457d 100644 --- a/crates/swc/tests/tsc-references/strictTupleLength_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/strictTupleLength_es2015.2.minified.js @@ -1,3 +1,3 @@ -t0.length, t1.length, t2.length, arr.length; -var t0, t1, t2, arr, t1 = t2, t2 = t1; +(void 0).length, t1.length, t2.length, arr.length; +var t1, t2, arr, t1 = t2, t2 = t1; arr = t1 = arr; diff --git a/crates/swc/tests/tsc-references/strictTupleLength_es5.2.minified.js b/crates/swc/tests/tsc-references/strictTupleLength_es5.2.minified.js index 3eef46febd8..6faa7e0457d 100644 --- a/crates/swc/tests/tsc-references/strictTupleLength_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/strictTupleLength_es5.2.minified.js @@ -1,3 +1,3 @@ -t0.length, t1.length, t2.length, arr.length; -var t0, t1, t2, arr, t1 = t2, t2 = t1; +(void 0).length, t1.length, t2.length, arr.length; +var t1, t2, arr, t1 = t2, t2 = t1; arr = t1 = arr; diff --git a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3_es2015.2.minified.js index a1052e6621b..dc90094e02a 100644 --- a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3_es2015.2.minified.js @@ -2,4 +2,7 @@ var Errors, WithGenericSignaturesInBaseType; !function(Errors) { var r2arg1, r3arg1, r4arg1, r5arg1, r6arg1, r7arg1, r7arg3, r8arg, r9arg; foo2(void 0), foo7(r2arg1), foo8(r3arg1), foo10(r4arg1), foo11(r5arg1), foo12(r6arg1), foo15(r7arg1), foo15(r7arg3), foo16(r8arg), foo17(r9arg); -}(Errors || (Errors = {})), WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}), foo2(void 0), foo3(void 0); +}(Errors || (Errors = {})), function(WithGenericSignaturesInBaseType) { + var r3arg2; + foo2(void 0), foo3(r3arg2); +}(WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {})); diff --git a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3_es5.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3_es5.2.minified.js index 2acf42ecf63..6a45132f830 100644 --- a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures3_es5.2.minified.js @@ -30,4 +30,7 @@ import * as swcHelpers from "@swc/helpers"; return OtherDerived; }(Base1); foo2(r1arg1), foo7(r2arg1), foo8(r3arg1), foo10(r4arg1), foo11(r5arg1), foo12(r6arg1), foo15(r7arg1), foo15(r7arg3), foo16(r8arg), foo17(r9arg); -}(Errors || (Errors = {})), WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}), foo2(void 0), foo3(void 0); +}(Errors || (Errors = {})), function(WithGenericSignaturesInBaseType) { + var r3arg2; + foo2(void 0), foo3(r3arg2); +}(WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {})); diff --git a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures_es2015.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures_es2015.2.minified.js index 2445e630875..1cb42999340 100644 --- a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures_es2015.2.minified.js @@ -1,5 +1,5 @@ var ConstructSignature; !function(ConstructSignature) { - var r3arg1, r4arg1; - foo1(void 0), foo1(void 0), foo2(r3arg1), foo2(r4arg1); + var rarg2, r3arg1, r4arg1; + foo1(void 0), foo1(rarg2), foo2(r3arg1), foo2(r4arg1); }(ConstructSignature || (ConstructSignature = {})); diff --git a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures_es5.2.minified.js b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures_es5.2.minified.js index 2445e630875..1cb42999340 100644 --- a/crates/swc/tests/tsc-references/subtypingWithConstructSignatures_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/subtypingWithConstructSignatures_es5.2.minified.js @@ -1,5 +1,5 @@ var ConstructSignature; !function(ConstructSignature) { - var r3arg1, r4arg1; - foo1(void 0), foo1(void 0), foo2(r3arg1), foo2(r4arg1); + var rarg2, r3arg1, r4arg1; + foo1(void 0), foo1(rarg2), foo2(r3arg1), foo2(r4arg1); }(ConstructSignature || (ConstructSignature = {})); diff --git a/crates/swc/tests/tsc-references/superPropertyAccessNoError_es2015.2.minified.js b/crates/swc/tests/tsc-references/superPropertyAccessNoError_es2015.2.minified.js index 7c4208cca04..0792567aa3f 100644 --- a/crates/swc/tests/tsc-references/superPropertyAccessNoError_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/superPropertyAccessNoError_es2015.2.minified.js @@ -11,8 +11,7 @@ class SomeBaseClass { } new class extends SomeBaseClass { fn() { - super.func(), ()=>super.func() - ; + super.func(); } get a() { return super.func(), null; diff --git a/crates/swc/tests/tsc-references/superSymbolIndexedAccess2_es2015.2.minified.js b/crates/swc/tests/tsc-references/superSymbolIndexedAccess2_es2015.2.minified.js index e1e7649a32b..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/superSymbolIndexedAccess2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/superSymbolIndexedAccess2_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.isConcatSpreadable, Symbol.isConcatSpreadable; diff --git a/crates/swc/tests/tsc-references/symbolDeclarationEmit10_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit10_es2015.2.minified.js index e1e7649a32b..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit10_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit10_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.isConcatSpreadable, Symbol.isConcatSpreadable; diff --git a/crates/swc/tests/tsc-references/symbolDeclarationEmit13_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit13_es2015.2.minified.js index 0e3b7f7bd05..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit13_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit13_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toPrimitive, Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolDeclarationEmit14_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit14_es2015.2.minified.js index 0e3b7f7bd05..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit14_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit14_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toPrimitive, Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolDeclarationEmit2_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit2_es2015.2.minified.js index e648971c478..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit2_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toPrimitive; diff --git a/crates/swc/tests/tsc-references/symbolDeclarationEmit3_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit3_es2015.2.minified.js index e648971c478..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit3_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit3_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toPrimitive; diff --git a/crates/swc/tests/tsc-references/symbolDeclarationEmit4_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit4_es2015.2.minified.js index dc8e4162941..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit4_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit4_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toPrimitive, Symbol.toPrimitive; diff --git a/crates/swc/tests/tsc-references/symbolDeclarationEmit8_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit8_es2015.2.minified.js index 89ac9ff26cd..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit8_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit8_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.isConcatSpreadable; diff --git a/crates/swc/tests/tsc-references/symbolDeclarationEmit9_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolDeclarationEmit9_es2015.2.minified.js index 89ac9ff26cd..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolDeclarationEmit9_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolDeclarationEmit9_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.isConcatSpreadable; diff --git a/crates/swc/tests/tsc-references/symbolProperty20_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty20_es2015.2.minified.js index b67b12d5976..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty20_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty20_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.iterator, Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty23_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty23_es2015.2.minified.js index e648971c478..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty23_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty23_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toPrimitive; diff --git a/crates/swc/tests/tsc-references/symbolProperty24_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty24_es2015.2.minified.js index e648971c478..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty24_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty24_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toPrimitive; diff --git a/crates/swc/tests/tsc-references/symbolProperty25_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty25_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty25_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty25_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty26_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty26_es2015.2.minified.js index 297499517f9..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty26_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty26_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag, Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty27_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty27_es2015.2.minified.js index 297499517f9..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty27_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty27_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag, Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty28_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty28_es2015.2.minified.js index 01d12f2c771..9a9b0021a35 100644 --- a/crates/swc/tests/tsc-references/symbolProperty28_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty28_es2015.2.minified.js @@ -1,2 +1 @@ -var c; -Symbol.toStringTag, c[Symbol.toStringTag]().x; +(void 0)[Symbol.toStringTag]().x; diff --git a/crates/swc/tests/tsc-references/symbolProperty29_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty29_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty29_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty29_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty30_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty30_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty30_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty30_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty31_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty31_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty31_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty31_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty32_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty32_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty32_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty32_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty33_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty33_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty33_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty33_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty34_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty34_es2015.2.minified.js index c562216962f..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty34_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty34_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty36_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty36_es2015.2.minified.js index e1e7649a32b..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty36_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty36_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.isConcatSpreadable, Symbol.isConcatSpreadable; diff --git a/crates/swc/tests/tsc-references/symbolProperty39_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty39_es2015.2.minified.js index 5c6cd4f7942..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty39_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty39_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.iterator, Symbol.iterator; diff --git a/crates/swc/tests/tsc-references/symbolProperty42_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty42_es2015.2.minified.js index ae1f0b9df59..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty42_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty42_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.iterator; diff --git a/crates/swc/tests/tsc-references/symbolProperty44_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty44_es2015.2.minified.js index 475bcc14bf9..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty44_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty44_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.hasInstance, Symbol.hasInstance; diff --git a/crates/swc/tests/tsc-references/symbolProperty45_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty45_es2015.2.minified.js index 626b649d858..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty45_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty45_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.hasInstance, Symbol.toPrimitive; diff --git a/crates/swc/tests/tsc-references/symbolProperty50_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty50_es2015.2.minified.js index 39fedf8e101..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty50_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty50_es2015.2.minified.js @@ -1,2 +0,0 @@ -var M; -M || (M = {}), Symbol.iterator; diff --git a/crates/swc/tests/tsc-references/symbolProperty52_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty52_es2015.2.minified.js index 560300527c2..7ae2d004866 100644 --- a/crates/swc/tests/tsc-references/symbolProperty52_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty52_es2015.2.minified.js @@ -1 +1 @@ -Symbol.nonsense, ({})[Symbol.nonsense]; +({})[Symbol.nonsense]; diff --git a/crates/swc/tests/tsc-references/symbolProperty54_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty54_es2015.2.minified.js index 86622cf6d3c..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty54_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty54_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.prototype; diff --git a/crates/swc/tests/tsc-references/symbolProperty58_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty58_es2015.2.minified.js index 9a10cdda5c8..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty58_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty58_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.foo; diff --git a/crates/swc/tests/tsc-references/symbolProperty5_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty5_es2015.2.minified.js index b9802cab444..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty5_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty5_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.iterator, Symbol.toPrimitive, Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolProperty6_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolProperty6_es2015.2.minified.js index b9802cab444..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/symbolProperty6_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolProperty6_es2015.2.minified.js @@ -1 +0,0 @@ -Symbol.iterator, Symbol.toPrimitive, Symbol.toStringTag; diff --git a/crates/swc/tests/tsc-references/symbolType3_es2015.2.minified.js b/crates/swc/tests/tsc-references/symbolType3_es2015.2.minified.js index 91332257a21..04b4ca2fc9c 100644 --- a/crates/swc/tests/tsc-references/symbolType3_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolType3_es2015.2.minified.js @@ -1,2 +1,2 @@ var s = Symbol(); -delete Symbol.iterator, Symbol.toPrimitive, Symbol.toStringTag, ++s, --s, Symbol(), Symbol(), Symbol(), Symbol(), Symbol(); +delete Symbol.iterator, ++s, --s, Symbol(), Symbol(), Symbol(), Symbol(), Symbol(); diff --git a/crates/swc/tests/tsc-references/symbolType3_es5.2.minified.js b/crates/swc/tests/tsc-references/symbolType3_es5.2.minified.js index 0d7e95c08c8..4e1d9a3c2d0 100644 --- a/crates/swc/tests/tsc-references/symbolType3_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/symbolType3_es5.2.minified.js @@ -1,3 +1,3 @@ import * as swcHelpers from "@swc/helpers"; var s = Symbol(); -delete Symbol.iterator, Symbol.toPrimitive, swcHelpers.typeOf(Symbol.toStringTag), ++s, --s, Symbol(), Symbol(), Symbol(), Symbol(), Symbol(); +delete Symbol.iterator, swcHelpers.typeOf(Symbol.toStringTag), ++s, --s, Symbol(), Symbol(), Symbol(), Symbol(), Symbol(); diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressionsES6_es5.2.minified.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressionsES6_es5.2.minified.js index 743a412e1d0..28a402e796c 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressionsES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressionsES6_es5.2.minified.js @@ -1,4 +1,3 @@ -var f; import * as swcHelpers from "@swc/helpers"; function _templateObject() { var data = swcHelpers.taggedTemplateLiteral([ @@ -9,4 +8,4 @@ function _templateObject() { return data; }, data; } -new new new (f(_templateObject(), 0)).member("hello")(42); +new new new ((void 0)(_templateObject(), 0)).member("hello")(42); diff --git a/crates/swc/tests/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressions_es5.2.minified.js b/crates/swc/tests/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressions_es5.2.minified.js index 743a412e1d0..28a402e796c 100644 --- a/crates/swc/tests/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressions_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressions_es5.2.minified.js @@ -1,4 +1,3 @@ -var f; import * as swcHelpers from "@swc/helpers"; function _templateObject() { var data = swcHelpers.taggedTemplateLiteral([ @@ -9,4 +8,4 @@ function _templateObject() { return data; }, data; } -new new new (f(_templateObject(), 0)).member("hello")(42); +new new new ((void 0)(_templateObject(), 0)).member("hello")(42); diff --git a/crates/swc/tests/tsc-references/thisTypeInFunctions_es2015.2.minified.js b/crates/swc/tests/tsc-references/thisTypeInFunctions_es2015.2.minified.js index e25ec4bd6e0..cf080248fd9 100644 --- a/crates/swc/tests/tsc-references/thisTypeInFunctions_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/thisTypeInFunctions_es2015.2.minified.js @@ -62,8 +62,7 @@ let reconstructed = { explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid }; -reconstructed.explicitThis(10), reconstructed.explicitProperty(11), (0, reconstructed.explicitVoid)(12), (x)=>x + this.y -; +reconstructed.explicitThis(10), reconstructed.explicitProperty(11), (0, reconstructed.explicitVoid)(12); let explicitCFunction, explicitPropertyFunction; c.explicitC = explicitCFunction, c.explicitC = function(m) { return this.n + m; diff --git a/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads_es2015.2.minified.js b/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads_es2015.2.minified.js index 9c57323d096..117934b2410 100644 --- a/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads_es2015.2.minified.js @@ -1,2 +1,2 @@ -var d; -(void 0).foo(!0), (void 0).foo(1, 2), d.foo(1, 1); +var c, d; +(void 0).foo(!0), c.foo(1, 2), d.foo(1, 1); diff --git a/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads_es5.2.minified.js b/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads_es5.2.minified.js index 9c57323d096..117934b2410 100644 --- a/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/twoMergedInterfacesWithDifferingOverloads_es5.2.minified.js @@ -1,2 +1,2 @@ -var d; -(void 0).foo(!0), (void 0).foo(1, 2), d.foo(1, 1); +var c, d; +(void 0).foo(!0), c.foo(1, 2), d.foo(1, 1); diff --git a/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOfOnInterface_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOfOnInterface_es2015.2.minified.js index e9405cdfd01..96e9cc93091 100644 --- a/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOfOnInterface_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOfOnInterface_es2015.2.minified.js @@ -1,2 +1,2 @@ -var c1, c2, d1, c1Orc2, c2Ord1; -c1Orc2 instanceof c1 && c1Orc2.p1, c1Orc2 instanceof c2 && c1Orc2.p2, c1Orc2 instanceof d1 && c1Orc2.p1, c1Orc2 instanceof d1 && c1Orc2.p3, c2Ord1 instanceof c2 && c2Ord1.p2, c2Ord1 instanceof d1 && c2Ord1.p3, c2Ord1 instanceof d1 && c2Ord1.p1, c2Ord1 instanceof c1; +var c2, d1, c1Orc2, c2Ord1; +c1Orc2 instanceof void 0 && c1Orc2.p1, c1Orc2 instanceof c2 && c1Orc2.p2, c1Orc2 instanceof d1 && c1Orc2.p1, c1Orc2 instanceof d1 && c1Orc2.p3, c2Ord1 instanceof c2 && c2Ord1.p2, c2Ord1 instanceof d1 && c2Ord1.p3, c2Ord1 instanceof d1 && c2Ord1.p1; diff --git a/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOf_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOf_es2015.2.minified.js index 2be76b181dd..5d45b0ddf79 100644 --- a/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOf_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeGuardOfFormInstanceOf_es2015.2.minified.js @@ -5,4 +5,4 @@ class C2 { } class D1 extends C1 { } -ctor1 instanceof C1 && ctor1.p1, ctor1 instanceof C2 && ctor1.p2, ctor1 instanceof D1 && ctor1.p1, ctor1 instanceof D1 && ctor1.p3, ctor2 instanceof C2 && ctor2.p2, ctor2 instanceof D1 && ctor2.p3, ctor2 instanceof D1 && ctor2.p1, ctor2 instanceof C1, ctor3 instanceof C1 ? ctor3.p1 : ctor3.p2, ctor4 instanceof C1 ? ctor4.p1 : ctor4 instanceof C2 ? ctor4.p2 : ctor4.p4, ctor5 instanceof C1 ? ctor5.p1 : ctor5.p2, ctor6 instanceof C1 || ctor6 instanceof C2 || ctor6.p4; +ctor1 instanceof C1 && ctor1.p1, ctor1 instanceof C2 && ctor1.p2, ctor1 instanceof D1 && ctor1.p1, ctor1 instanceof D1 && ctor1.p3, ctor2 instanceof C2 && ctor2.p2, ctor2 instanceof D1 && ctor2.p3, ctor2 instanceof D1 && ctor2.p1, ctor3 instanceof C1 ? ctor3.p1 : ctor3.p2, ctor4 instanceof C1 ? ctor4.p1 : ctor4 instanceof C2 ? ctor4.p2 : ctor4.p4, ctor5 instanceof C1 ? ctor5.p1 : ctor5.p2, ctor6 instanceof C1 || ctor6 instanceof C2 || ctor6.p4; diff --git a/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraint2_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraint2_es2015.2.minified.js index 525dd1b31ae..cbe62e56c9a 100644 --- a/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraint2_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraint2_es2015.2.minified.js @@ -1,11 +1,10 @@ -var n; function foo(x, y) { return y; } function foo2(x, y) { return y; } -foo(1, ""), foo(1, {}), foo(1, n), foo2(1, { +foo(1, ""), foo(1, {}), foo(1, void 0), foo2(1, { length: "" }), foo2(1, { length: {} diff --git a/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraint2_es5.2.minified.js b/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraint2_es5.2.minified.js index 525dd1b31ae..cbe62e56c9a 100644 --- a/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraint2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/typeParameterAsTypeParameterConstraint2_es5.2.minified.js @@ -1,11 +1,10 @@ -var n; function foo(x, y) { return y; } function foo2(x, y) { return y; } -foo(1, ""), foo(1, {}), foo(1, n), foo2(1, { +foo(1, ""), foo(1, {}), foo(1, void 0), foo2(1, { length: "" }), foo2(1, { length: {} diff --git a/crates/swc/tests/tsc-references/typeofThis_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeofThis_es2015.2.minified.js index f1300e6383d..8faf39b34bb 100644 --- a/crates/swc/tests/tsc-references/typeofThis_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeofThis_es2015.2.minified.js @@ -1,2 +1,2 @@ var Test6, Test7; -(Test6 || (Test6 = {})).f = ()=>{}, (Test7 || (Test7 = {})).f = ()=>{}, ()=>{}; +(Test6 || (Test6 = {})).f = ()=>{}, (Test7 || (Test7 = {})).f = ()=>{}; diff --git a/crates/swc/tests/vercel/full/react-instantsearch/2/output/index.js b/crates/swc/tests/vercel/full/react-instantsearch/2/output/index.js index e2da09612f1..6024d1f19f2 100644 --- a/crates/swc/tests/vercel/full/react-instantsearch/2/output/index.js +++ b/crates/swc/tests/vercel/full/react-instantsearch/2/output/index.js @@ -173,9 +173,9 @@ export default function n(e) { }, r = b(g, p, a.objectSpread({}, d)); h(g), r.on("search", function() { F || (F = setTimeout(function() { - var b = y.getState(), d = b.resultsFacetValues, c = a.objectWithoutProperties(b, [ + var b = y.getState(), c = (b.resultsFacetValues, a.objectWithoutProperties(b, [ "resultsFacetValues" - ]); + ])); y.setState(a.objectSpread({}, c, { isSearchStalled: !0 })); diff --git a/crates/swc_ecma_minifier/src/compress/mod.rs b/crates/swc_ecma_minifier/src/compress/mod.rs index 752acfb43a2..efc11e24de4 100644 --- a/crates/swc_ecma_minifier/src/compress/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/mod.rs @@ -29,7 +29,7 @@ use self::{hoist_decls::DeclHoisterConfig, optimize::optimizer}; use crate::{ analyzer::{analyze, UsageAnalyzer}, compress::hoist_decls::decl_hoister, - debug::dump, + debug::{dump, AssertValid}, marks::Marks, mode::Mode, option::CompressOptions, @@ -179,7 +179,10 @@ where fn optimize_unit_repeatedly(&mut self, n: &mut N) where - N: CompileUnit + VisitWith + for<'aa> VisitMutWith>, + N: CompileUnit + + VisitWith + + for<'aa> VisitMutWith> + + VisitWith, { if cfg!(feature = "debug") { tracing::debug!( @@ -227,7 +230,10 @@ where /// Optimize a module. `N` can be [Module] or [FnExpr]. fn optimize_unit(&mut self, n: &mut N) where - N: CompileUnit + VisitWith + for<'aa> VisitMutWith>, + N: CompileUnit + + VisitWith + + for<'aa> VisitMutWith> + + VisitWith, { let _timer = timer!("optimize", pass = self.pass); @@ -335,6 +341,10 @@ where } } + if cfg!(debug_assertions) { + n.visit_with(&mut AssertValid); + } + { let _timer = timer!("apply full optimizer"); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index d37874107e2..73ce8b28ab1 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -17,7 +17,7 @@ use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith, VisitWith}; use tracing::{span, Level}; use Value::Known; -use self::util::MultiReplacer; +use self::{unused::PropertyAccessOpts, util::MultiReplacer}; use super::util::{drop_invalid_stmts, is_fine_for_if_cons}; use crate::{ analyzer::{ProgramData, UsageAnalyzer}, @@ -26,7 +26,7 @@ use crate::{ marks::Marks, mode::Mode, option::CompressOptions, - util::{contains_leaping_yield, make_number, ModuleItemExt}, + util::{contains_leaping_yield, make_number, ExprOptExt, ModuleItemExt}, }; mod arguments; @@ -751,9 +751,8 @@ where .. }) => { if let PropName::Computed(key) = key { - exprs.extend( - self.ignore_return_value(key.expr.as_mut()).map(Box::new), - ); + exprs + .extend(self.ignore_return_value(&mut *key.expr).map(Box::new)); } if *is_static { @@ -961,23 +960,16 @@ where if !prop.is_computed() && (self.options.top_level() || !self.ctx.in_top_level()) => { - if let Expr::Ident(obj) = &**obj { - if let Some(usage) = self - .data - .as_ref() - .and_then(|data| data.vars.get(&obj.to_id())) - { - if !usage.declared { - return Some(e.take()); - } - - if !usage.mutated - && !usage.reassigned() - && usage.no_side_effect_for_member_access - { - return None; - } - } + if self.should_preserve_property_access( + obj, + PropertyAccessOpts { + allow_getter: true, + only_ident: true, + }, + ) { + return Some(e.take()); + } else { + return None; } } @@ -2792,39 +2784,81 @@ where for v in vars.iter_mut() { if v.init .as_deref() - .map(|e| !e.may_have_side_effects()) + .map(|e| !e.is_ident() && !e.may_have_side_effects()) .unwrap_or(true) { - self.drop_unused_var_declarator(v, true); + self.drop_unused_var_declarator(v, &mut None); } } + let mut can_prepend = true; + let mut side_effects = vec![]; + for v in vars.iter_mut() { - let was_value_none = v.init.is_none(); + let mut storage = None; + self.drop_unused_var_declarator(v, &mut storage); + side_effects.extend(storage); - self.drop_unused_var_declarator(v, true); + // Dropped. Side effects of the initializer is stored in `side_effects`. if v.name.is_invalid() { continue; } - if was_value_none { + + // If initializer is none, we can check next item without thinking about side + // effects. + if v.init.is_none() { continue; } - break; + // We can drop the next variable, as we don't have to worry about the side + // effect. + if side_effects.is_empty() { + can_prepend = false; + continue; + } + + // We now have to handle side effects. + + if can_prepend { + can_prepend = false; + + self.prepend_stmts.push(Stmt::Expr(ExprStmt { + span: DUMMY_SP, + expr: if side_effects.len() == 1 { + side_effects.remove(0) + } else { + Box::new(Expr::Seq(SeqExpr { + span: DUMMY_SP, + exprs: side_effects.take(), + })) + }, + })); + } else { + // We prepend side effects to the initializer. + + let seq = v.init.as_mut().unwrap().force_seq(); + seq.exprs = side_effects + .drain(..) + .into_iter() + .chain(seq.exprs.take()) + .filter(|e| !e.is_invalid()) + .collect(); + } } - for v in vars.iter_mut().rev() { - let was_value_none = v.init.is_none(); - - self.drop_unused_var_declarator(v, false); - if v.name.is_invalid() { - continue; - } - if was_value_none { - continue; - } - - break; + // We append side effects. + if !side_effects.is_empty() { + self.append_stmts.push(Stmt::Expr(ExprStmt { + span: DUMMY_SP, + expr: if side_effects.len() == 1 { + side_effects.remove(0) + } else { + Box::new(Expr::Seq(SeqExpr { + span: DUMMY_SP, + exprs: side_effects, + })) + }, + })); } vars.retain_mut(|var| { diff --git a/crates/swc_ecma_minifier/src/compress/optimize/unused.rs b/crates/swc_ecma_minifier/src/compress/optimize/unused.rs index d10b65f4508..099bfb8ba7e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/unused.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/unused.rs @@ -5,17 +5,30 @@ use swc_ecma_utils::{contains_ident_ref, ident::IdentLike}; use super::Optimizer; use crate::{ - compress::optimize::util::class_has_side_effect, debug::dump, mode::Mode, + compress::{optimize::util::class_has_side_effect, util::is_global_var}, + debug::dump, + mode::Mode, option::PureGetterOption, }; +#[derive(Debug, Default, Clone, Copy)] +pub(crate) struct PropertyAccessOpts { + pub allow_getter: bool, + + pub only_ident: bool, +} + /// Methods related to the option `unused`. impl Optimizer<'_, M> where M: Mode, { #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] - pub(super) fn drop_unused_var_declarator(&mut self, var: &mut VarDeclarator, prepend: bool) { + pub(super) fn drop_unused_var_declarator( + &mut self, + var: &mut VarDeclarator, + storage_for_side_effects: &mut Option>, + ) { if var.name.is_invalid() { return; } @@ -37,22 +50,9 @@ where if var.name.is_invalid() { tracing::debug!("unused: Removing an unused variable declarator"); - let side_effects = self.ignore_return_value(init); + let side_effects = self.ignore_return_value(init).map(Box::new); if let Some(e) = side_effects { - if prepend { - self.prepend_stmts.push(Stmt::Expr(ExprStmt { - span: var.span, - expr: Box::new(e), - })) - } else { - self.append_stmts.insert( - 0, - Stmt::Expr(ExprStmt { - span: var.span, - expr: Box::new(e), - }), - ) - } + *storage_for_side_effects = Some(e); } } } @@ -193,6 +193,148 @@ where } } + #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] + fn take_ident_of_pat_if_unused( + &mut self, + parent_span: Span, + i: &mut Ident, + init: Option<&mut Expr>, + ) { + if cfg!(debug_assertions) { + tracing::trace!("unused: Checking identifier `{}`", i); + } + + if !parent_span.has_mark(self.marks.non_top_level) + && self.options.top_retain.contains(&i.sym) + { + if cfg!(feature = "debug") { + tracing::trace!("unused: [X] Top-retain") + } + return; + } + + if let Some(v) = self + .data + .as_ref() + .and_then(|data| data.vars.get(&i.to_id()).cloned()) + { + if v.ref_count == 0 + && v.usage_count == 0 + && !v.reassigned_with_assignment + && !v.has_property_mutation + && !v.declared_as_catch_param + { + self.changed = true; + tracing::debug!( + "unused: Dropping a variable '{}{:?}' because it is not used", + i.sym, + i.span.ctxt + ); + // This will remove variable. + i.take(); + return; + } + + if v.ref_count == 0 && v.usage_count == 0 { + if let Some(e) = init { + if let Some(VarDeclKind::Const | VarDeclKind::Let) = self.ctx.var_kind { + if let Expr::Lit(Lit::Null(..)) = e { + return; + } + } + + let ret = self.ignore_return_value(e); + if let Some(ret) = ret { + *e = ret; + } else { + if let Some(VarDeclKind::Const | VarDeclKind::Let) = self.ctx.var_kind { + *e = Null { span: DUMMY_SP }.into(); + } else { + *e = Expr::Invalid(Invalid { span: DUMMY_SP }); + } + } + } + } + + if cfg!(feature = "debug") { + tracing::trace!( + "unused: Cannot drop ({}) because it's used", + dump(&*i, false) + ); + } + } + } + + pub(crate) fn should_preserve_property_access( + &self, + e: &Expr, + opts: PropertyAccessOpts, + ) -> bool { + if opts.only_ident && !e.is_ident() { + return true; + } + + match e { + Expr::Ident(e) => { + if e.span.ctxt.outer() == self.marks.top_level_mark { + if is_global_var(&e.sym) { + return false; + } + } + + if let Some(usage) = self + .data + .as_ref() + .and_then(|data| data.vars.get(&e.to_id())) + { + if !usage.declared { + return true; + } + + if !usage.mutated + && !usage.reassigned() + && usage.no_side_effect_for_member_access + { + return false; + } + } + } + + Expr::Object(o) => { + // We should check properties + return o.props.iter().any(|p| match p { + PropOrSpread::Spread(p) => self.should_preserve_property_access(&p.expr, opts), + PropOrSpread::Prop(p) => match &**p { + Prop::Assign(_) => true, + Prop::Getter(_) => !opts.allow_getter, + Prop::Shorthand(_) => false, + Prop::KeyValue(..) => false, + + Prop::Setter(_) => false, + Prop::Method(_) => false, + }, + }); + } + + Expr::Paren(p) => return self.should_preserve_property_access(&p.expr, opts), + + Expr::Fn(..) | Expr::Arrow(..) | Expr::Array(..) => { + return false; + } + + Expr::Seq(e) => { + if let Some(last) = e.exprs.last() { + return self.should_preserve_property_access(last, opts); + } + return true; + } + + _ => {} + } + + true + } + /// `parent_span` should be [Span] of [VarDeclarator] or [AssignExpr] #[cfg_attr(feature = "debug", tracing::instrument(skip_all))] pub(super) fn take_pat_if_unused( @@ -205,78 +347,36 @@ where return; } - let had_value = init.is_some(); - let can_drop_children = had_value; + if cfg!(feature = "debug") { + tracing::trace!("unused: take_pat_if_unused({})", dump(&*name, false)); + } if !name.is_ident() { // TODO: Use smart logic if self.options.pure_getters != PureGetterOption::Bool(true) { return; } + + if let Some(init) = init.as_mut() { + if self.should_preserve_property_access( + init, + PropertyAccessOpts { + allow_getter: false, + only_ident: false, + }, + ) { + return; + } + } } match name { Pat::Ident(i) => { - if !parent_span.has_mark(self.marks.non_top_level) - && self.options.top_retain.contains(&i.id.sym) - { - if cfg!(feature = "debug") { - tracing::trace!("unused: [X] Top-retain") - } - return; - } + self.take_ident_of_pat_if_unused(parent_span, &mut i.id, init); - if let Some(v) = self - .data - .as_ref() - .and_then(|data| data.vars.get(&i.to_id()).cloned()) - { - if v.ref_count == 0 - && v.usage_count == 0 - && !v.reassigned_with_assignment - && !v.has_property_mutation - && !v.declared_as_catch_param - { - self.changed = true; - tracing::debug!( - "unused: Dropping a variable '{}{:?}' because it is not used", - i.id.sym, - i.id.span.ctxt - ); - // This will remove variable. - name.take(); - return; - } - - if v.ref_count == 0 && v.usage_count == 0 { - if let Some(e) = init { - if let Some(VarDeclKind::Const | VarDeclKind::Let) = self.ctx.var_kind { - if let Expr::Lit(Lit::Null(..)) = e { - return; - } - } - - let ret = self.ignore_return_value(e); - if let Some(ret) = ret { - *e = ret; - } else { - if let Some(VarDeclKind::Const | VarDeclKind::Let) = - self.ctx.var_kind - { - *e = Null { span: DUMMY_SP }.into(); - } else { - *e = Expr::Invalid(Invalid { span: DUMMY_SP }); - } - } - } - } - - if cfg!(feature = "debug") { - tracing::trace!( - "unused: Cannot drop ({}) because it's used", - dump(&*i, false) - ); - } + // Removed + if i.id.sym == js_word!("") { + name.take(); } } @@ -319,18 +419,14 @@ where continue; } - let prop = init.as_mut().and_then(|value| { - self.access_property_with_prop_name(value, &p.key) - }); - - if can_drop_children && prop.is_none() { - continue; - } - - self.take_pat_if_unused(parent_span, &mut p.value, prop); + self.take_pat_if_unused(parent_span, &mut p.value, None); } - ObjectPatProp::Assign(_) => {} - ObjectPatProp::Rest(_) => {} + ObjectPatProp::Assign(AssignPatProp { + key, value: None, .. + }) => { + self.take_ident_of_pat_if_unused(parent_span, key, None); + } + _ => {} } } @@ -341,12 +437,20 @@ where return false; } } - ObjectPatProp::Assign(_) => {} + ObjectPatProp::Assign(p) => { + if p.key.sym == js_word!("") { + return false; + } + } ObjectPatProp::Rest(_) => {} } true - }) + }); + + if obj.props.is_empty() { + name.take(); + } } Pat::Rest(_) => {} diff --git a/crates/swc_ecma_minifier/src/compress/pure/misc.rs b/crates/swc_ecma_minifier/src/compress/pure/misc.rs index a30b8b238f6..73383ea4391 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/misc.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/misc.rs @@ -5,7 +5,7 @@ use swc_ecma_ast::*; use swc_ecma_utils::ident::IdentLike; use super::Pure; -use crate::compress::util::is_pure_undefined; +use crate::compress::util::{is_global_var, is_pure_undefined}; impl Pure<'_> { pub(super) fn remove_invalid(&mut self, e: &mut Expr) { @@ -55,6 +55,7 @@ impl Pure<'_> { self.ignore_return_value( arg.as_deref_mut().unwrap(), DropOpts { + drop_global_refs_if_unused: true, drop_zero: true, drop_str_lit: true, ..Default::default() @@ -145,20 +146,13 @@ impl Pure<'_> { if let Expr::Ident(i) = e { // If it's not a top level, it's a reference to a declared variable. if i.span.ctxt.outer() == self.marks.top_level_mark { - if self.options.side_effects { - match &*i.sym { - "clearInterval" | "clearTimeout" | "setInterval" | "setTimeout" - | "Boolean" | "Date" | "decodeURI" | "decodeURIComponent" | "encodeURI" - | "encodeURIComponent" | "escape" | "eval" | "EvalError" | "isFinite" - | "isNaN" | "JSON" | "parseFloat" | "parseInt" | "RegExp" - | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" - | "unescape" | "URIError" | "atob" | "globalThis" | "Object" | "Array" - | "Number" | "NaN" | "Symbol" => { - tracing::debug!("Dropping a reference to a global variable"); - *e = Expr::Invalid(Invalid { span: DUMMY_SP }); - return; - } - _ => {} + if self.options.side_effects + || (self.options.unused && opts.drop_global_refs_if_unused) + { + if is_global_var(&i.sym) { + tracing::debug!("Dropping a reference to a global variable"); + *e = Expr::Invalid(Invalid { span: DUMMY_SP }); + return; } } } else { @@ -179,6 +173,7 @@ impl Pure<'_> { &mut **arg, DropOpts { drop_str_lit: true, + drop_global_refs_if_unused: true, drop_zero: true, ..opts }, @@ -270,6 +265,7 @@ impl Pure<'_> { &mut bin.left, DropOpts { drop_zero: true, + drop_global_refs_if_unused: true, drop_str_lit: true, ..opts }, @@ -278,6 +274,7 @@ impl Pure<'_> { &mut bin.right, DropOpts { drop_zero: true, + drop_global_refs_if_unused: true, drop_str_lit: true, ..opts }, @@ -392,6 +389,9 @@ impl Pure<'_> { #[derive(Debug, Default, Clone, Copy)] pub(super) struct DropOpts { + /// If true and `unused` option is enabled, references to global variables + /// will be dropped, even if `side_effects` is false. + pub drop_global_refs_if_unused: bool, pub drop_zero: bool, pub drop_str_lit: bool, } diff --git a/crates/swc_ecma_minifier/src/compress/pure/mod.rs b/crates/swc_ecma_minifier/src/compress/pure/mod.rs index 35e940e201c..224b94a3cb6 100644 --- a/crates/swc_ecma_minifier/src/compress/pure/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/pure/mod.rs @@ -334,6 +334,7 @@ impl VisitMut for Pure<'_> { &mut s.expr, DropOpts { drop_zero: true, + drop_global_refs_if_unused: true, drop_str_lit: false, }, ); @@ -447,6 +448,7 @@ impl VisitMut for Pure<'_> { e, DropOpts { drop_zero: true, + drop_global_refs_if_unused: true, drop_str_lit: true, ..Default::default() }, @@ -527,6 +529,7 @@ impl VisitMut for Pure<'_> { &mut **e, DropOpts { drop_zero: false, + drop_global_refs_if_unused: false, drop_str_lit: true, }, ); diff --git a/crates/swc_ecma_minifier/src/compress/util/mod.rs b/crates/swc_ecma_minifier/src/compress/util/mod.rs index ad174bea8fa..989c4c1bdec 100644 --- a/crates/swc_ecma_minifier/src/compress/util/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/util/mod.rs @@ -714,3 +714,42 @@ impl VisitMut for UnreachableHandler { n.init.visit_mut_with(self); } } + +pub(super) fn is_global_var(s: &str) -> bool { + matches!( + s, + "clearInterval" + | "clearTimeout" + | "setInterval" + | "setTimeout" + | "Boolean" + | "Date" + | "decodeURI" + | "decodeURIComponent" + | "encodeURI" + | "encodeURIComponent" + | "escape" + | "eval" + | "EvalError" + | "isFinite" + | "isNaN" + | "JSON" + | "parseFloat" + | "parseInt" + | "RegExp" + | "RangeError" + | "ReferenceError" + | "SyntaxError" + | "TypeError" + | "unescape" + | "URIError" + | "atob" + | "globalThis" + | "String" + | "Object" + | "Array" + | "Number" + | "NaN" + | "Symbol" + ) +} diff --git a/crates/swc_ecma_minifier/src/debug.rs b/crates/swc_ecma_minifier/src/debug.rs index c9cfadd68ff..2beec52ad87 100644 --- a/crates/swc_ecma_minifier/src/debug.rs +++ b/crates/swc_ecma_minifier/src/debug.rs @@ -1,4 +1,6 @@ -use std::{env, process::Command}; +#![cfg_attr(not(debug_assertions), allow(unused))] + +use std::{env, fmt::Debug, mem::forget, process::Command}; use once_cell::sync::Lazy; use swc_common::{sync::Lrc, SourceMap, SyntaxContext}; @@ -125,11 +127,30 @@ pub(crate) fn invoke(module: &Module) { ) } +#[cfg(debug_assertions)] +struct Ctx<'a> { + v: &'a dyn Debug, +} + +#[cfg(debug_assertions)] +impl Drop for Ctx<'_> { + fn drop(&mut self) { + eprintln!("Context: {:?}", self.v); + } +} + pub(crate) struct AssertValid; impl Visit for AssertValid { noop_visit_type!(); + #[cfg(debug_assertions)] + fn visit_expr(&mut self, n: &Expr) { + let ctx = Ctx { v: n }; + n.visit_children_with(self); + forget(ctx); + } + fn visit_invalid(&mut self, _: &Invalid) { panic!("Invalid node found"); } @@ -138,6 +159,13 @@ impl Visit for AssertValid { p.body.visit_with(self); } + #[cfg(debug_assertions)] + fn visit_stmt(&mut self, n: &Stmt) { + let ctx = Ctx { v: n }; + n.visit_children_with(self); + forget(ctx); + } + fn visit_tpl(&mut self, l: &Tpl) { l.visit_children_with(self); diff --git a/crates/swc_ecma_minifier/tests/TODO.txt b/crates/swc_ecma_minifier/tests/TODO.txt index 9a492a67d80..9a8966bf058 100644 --- a/crates/swc_ecma_minifier/tests/TODO.txt +++ b/crates/swc_ecma_minifier/tests/TODO.txt @@ -133,31 +133,19 @@ dead_code/return_assignment/input.js dead_code/unsafe_builtin/input.js destructuring/anon_func_with_destructuring_args/input.js destructuring/arrow_func_with_destructuring_args/input.js -destructuring/destructure_empty_array_3/input.js destructuring/destructuring_dont_evaluate_with_undefined_as_default_assignment/input.js -destructuring/empty_object_destructuring_3/input.js -destructuring/empty_object_destructuring_4/input.js -destructuring/empty_object_destructuring_misc/input.js destructuring/export_unreferenced_declarations_2/input.js destructuring/issue_3205_2/input.js destructuring/issue_3205_3/input.js destructuring/issue_3205_4/input.js destructuring/issue_3205_5/input.js -destructuring/issue_t111_1/input.js -destructuring/issue_t111_2a/input.js -destructuring/issue_t111_2b/input.js -destructuring/issue_t111_2c/input.js -destructuring/issue_t111_3/input.js destructuring/mangle_destructuring_assign_toplevel_false/input.js destructuring/mangle_destructuring_assign_toplevel_true/input.js destructuring/mangle_destructuring_decl/input.js destructuring/mangle_destructuring_decl_array/input.js destructuring/mangle_destructuring_decl_collapse_vars/input.js destructuring/unused_destructuring_arrow_param/input.js -destructuring/unused_destructuring_decl_1/input.js -destructuring/unused_destructuring_decl_5/input.js destructuring/unused_destructuring_getter_side_effect_2/input.js -destructuring/unused_destructuring_multipass/input.js drop_unused/chained_3/input.js drop_unused/defun_lambda_same_name/input.js drop_unused/delete_assign_1/input.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js index 6b503a67520..7d3117787b7 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js @@ -269,10 +269,10 @@ }), wrapperPageComponent((authConfig = authConfig1, function(PageComponent) { var _pageConfig = PageComponent.pageConfig, pageConfig = void 0 === _pageConfig ? {} : _pageConfig; return _auth.withAuth(function(props) { - var auth = props.auth, setAuth = props.setAuth, rest = swcHelpers.objectWithoutProperties(props, [ + var auth = props.auth, rest = (props.setAuth, swcHelpers.objectWithoutProperties(props, [ "auth", "setAuth" - ]), pageConfigAuth = pageConfig.auth; + ])), pageConfigAuth = pageConfig.auth; if (pageConfigAuth && !Array.isArray(pageConfigAuth)) throw new Error("pageConfig.auth must be an array"); return Array.isArray(pageConfigAuth) && pageConfigAuth.length && !Object.keys(auth).filter(function(item) { return !!pageConfigAuth.includes(item) && auth[item]; @@ -830,10 +830,10 @@ }); }), promise; }, _proto.resolveAsync = function() { - var _this4 = this, _this$props = this.props, __chunkExtractor = _this$props.__chunkExtractor, forwardedRef = _this$props.forwardedRef, props = (0, objectWithoutPropertiesLoose.Z)(_this$props, [ + var _this4 = this, _this$props = this.props, props = (_this$props.__chunkExtractor, _this$props.forwardedRef, (0, objectWithoutPropertiesLoose.Z)(_this$props, [ "__chunkExtractor", "forwardedRef" - ]), promise = this.getCache(); + ])), promise = this.getCache(); return promise || ((promise = ctor.requireAsync(props)).status = STATUS_PENDING, this.setCache(promise), promise.then(function() { promise.status = "RESOLVED"; }, function(error) { @@ -844,11 +844,11 @@ }), promise.status = STATUS_REJECTED; })), promise; }, _proto.render = function() { - var _this$props2 = this.props, forwardedRef = _this$props2.forwardedRef, propFallback = _this$props2.fallback, __chunkExtractor = _this$props2.__chunkExtractor, props = (0, objectWithoutPropertiesLoose.Z)(_this$props2, [ + var _this$props2 = this.props, forwardedRef = _this$props2.forwardedRef, propFallback = _this$props2.fallback, props = (_this$props2.__chunkExtractor, (0, objectWithoutPropertiesLoose.Z)(_this$props2, [ "forwardedRef", "fallback", "__chunkExtractor" - ]), _this$state = this.state, error = _this$state.error, loading = _this$state.loading, result = _this$state.result; + ])), _this$state = this.state, error = _this$state.error, loading = _this$state.loading, result = _this$state.result; if (options.suspense && (this.getCache() || this.loadAsync()).status === STATUS_PENDING) throw this.loadAsync(); if (error) throw error; var fallback = propFallback || options.fallback || null; diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/emotion/react/1/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/issues/emotion/react/1/output.js index bca0b808070..6330efa8642 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/emotion/react/1/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/emotion/react/1/output.js @@ -618,7 +618,7 @@ styles: styles, next: cursor }; - }, emotion_element_99289b21_browser_esm_hasOwnProperty = Object.prototype.hasOwnProperty, EmotionCacheContext = (0, react.createContext)("undefined" != typeof HTMLElement ? function(options) { + }, EmotionCacheContext = (Object.prototype.hasOwnProperty, (0, react.createContext)("undefined" != typeof HTMLElement ? function(options) { var key = options.key; if ("css" === key) { var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); @@ -674,7 +674,7 @@ return cache.sheet.hydrate(nodesToHydrate), cache; }({ key: "css" - }) : null); + }) : null)); EmotionCacheContext.Provider; var emotion_element_99289b21_browser_esm_ThemeContext = (0, react.createContext)({}); __webpack_require__(8679); diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-instancesearch/004/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-instancesearch/004/output.js index 6203000c827..cdb2d2b98ff 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-instancesearch/004/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-instancesearch/004/output.js @@ -173,9 +173,9 @@ export default function createInstantSearchManager(param1) { }, helper = algoliasearchHelper(searchClient, indexName, swcHelpers.objectSpread({}, HIGHLIGHT_TAGS)); addAlgoliaAgents(searchClient), helper.on("search", function() { stalledSearchTimer || (stalledSearchTimer = setTimeout(function() { - var _ref = store.getState(), resultsFacetValues = _ref.resultsFacetValues, partialState = swcHelpers.objectWithoutProperties(_ref, [ + var _ref = store.getState(), partialState = (_ref.resultsFacetValues, swcHelpers.objectWithoutProperties(_ref, [ "resultsFacetValues" - ]); + ])); store.setState(swcHelpers.objectSpread({}, partialState, { isSearchStalled: !0 })); diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js index 01abc2243d4..00b2e628e01 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js @@ -55,11 +55,9 @@ BigInt("0x1000000000000"), BigInt("0x100000000000000"), BigInt("0x10000000000000000") - ]; - a1 = new Uint16Array([ + ], bytesToNumber = (a1 = new Uint16Array([ 65484 - ]), 255 === (b1 = new Uint8Array(a1.buffer, a1.byteOffset, a1.byteLength))[0] || b1[0]; - var bytesToNumber = function(bytes, _temp) { + ]), 255 === (b1 = new Uint8Array(a1.buffer, a1.byteOffset, a1.byteLength))[0] || b1[0], function(bytes, _temp) { var _ref = void 0 === _temp ? {} : _temp, _ref$signed = _ref.signed, _ref$le = _ref.le, le = void 0 !== _ref$le && _ref$le; bytes = toUint8(bytes); var fn = le ? "reduce" : "reduceRight", number = (bytes[fn] ? bytes[fn] : Array.prototype[fn]).call(bytes, function(total, byte, i) { @@ -71,7 +69,7 @@ (number = BigInt(number)) > max && (number -= max, number -= max, number -= BigInt(2)); } return Number(number); - }, numberToBytes = function(number, _temp2) { + }), numberToBytes = function(number, _temp2) { var _ref2$le = (void 0 === _temp2 ? {} : _temp2).le, le = void 0 !== _ref2$le && _ref2$le; ("bigint" != typeof number && "number" != typeof number || "number" == typeof number && number != number) && (number = 0); for(var byteCount = Math.ceil((number = BigInt(number)).toString(2).length / 8), bytes = new Uint8Array(new ArrayBuffer(byteCount)), i = 0; i < byteCount; i++){ 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 d23519477a3..ff380fbbf5c 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[785],{840:function(a,b,c){var d;!function(g,B,Q,l){"use strict";var m,R=["","webkit","Moz","MS","ms","o"],C=B.createElement("div"),S=Math.round,T=Math.abs,U=Date.now;function V(a,b,c){return setTimeout(G(a,c),b)}function W(a,c,b){return!!Array.isArray(a)&&(D(a,b[c],b),!0)}function D(a,c,d){var b;if(a)if(a.forEach)a.forEach(c,d);else if(l!==a.length)for(b=0;b\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=na(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=oa(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=sa(j,k),a.distance=ra(j,k),la(b,a),a.offsetDirection=qa(a.deltaX,a.deltaY);var d=pa(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?ua(c.pointers,e):1,a.rotation=c?ta(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,ma(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function la(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 ma(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=pa(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=qa(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 na(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ra(b,c,a){a||(a=ha);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function sa(b,c,a){a||(a=ha);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function ta(a,b){return sa(b[1],b[0],ia)+sa(a[1],a[0],ia)}function ua(a,b){return ra(b[0],b[1],ia)/ra(a[0],a[1],ia)}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(ea(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(ea(this.element),this.evWin,this.domHandler)}};var va={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=va[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 wa={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},xa={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=wa[a.type.toLowerCase().replace("ms","")],f=xa[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 ya={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 za(b,d){var a=ba(b.touches),c=ba(b.changedTouches);return 12&d&&(a=ca(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ya[c.type];if(1===a&&(this.started=!0),this.started){var b=za.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 Ba(h,g){var b=ba(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ba(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 Ea(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+Ma(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+Ma(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=Na(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[Ia]},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[Ga]},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[Ia]},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=Na(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[Ha]},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.PI,Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),nb=new h(4),h!=Float32Array&&(nb[0]=0,nb[1]=0,nb[2]=0,nb[3]=0);const Ga=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function Ha(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 Ia(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 Ja(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 Ka(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 La(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function Ma(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 Na(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}ob=new h(2),h!=Float32Array&&(ob[0]=0,ob[1]=0),pb=new h(3),h!=Float32Array&&(pb[0]=0,pb[1]=0,pb[2]=0);const n=Math.PI,Oa=n/4,Pa=n/180,Qa=180/n;function Ra(a){return Math.pow(2,a)}function Sa([b,a]){return Na(Number.isFinite(b)),Na(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*Pa+n)/(2*n),512*(n+Math.log(Math.tan(Oa+.5*(a*Pa))))/(2*n)]}function Ta([a,b]){return[(a/512*(2*n)-n)*Qa,2*(Math.atan(Math.exp(b/512*(2*n)-n))-Oa)*Qa]}function Ua(a){return 2*Math.atan(.5/a)*Qa}function Va(a){return .5/Math.tan(.5*a*Pa)}function Wa(i,c,j=0){const[a,b,e]=i;if(Na(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=Ca(c,[a,b,e,1]);return k}const f=Ca(c,[a,b,0,1]),g=Ca(c,[a,b,1,1]),d=f[2],h=g[2];return Ma([],f,g,d===h?0:((j||0)-d)/(h-d))}const Xa=Math.PI/180;function Ya(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=Ca(e,[c,0,1,1]),f=Ca(e,[c,a.height,1,1]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=Ma([],b,f,i),g=Ta(j);return g[2]=d,g}class Za{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=Ua(a=1.5):null===b?b=Ua(a):null===a&&(a=Va(b));const r=Ra(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){Na(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*Pa),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=Pa*Math.tan(c*Pa)/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=Sa([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],k=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=Ua(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=Ua(d));const b=.5*a*Pa,c=Va(a),e=h*Pa;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=Ba();return Ia(e,e,[0,0,-I]),a=e,b=e,m=-G*Pa,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*Pa,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,Ja(e,e,[l/=F,l,l]),E&&Ia(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=Ba();Ha(G,G,K),Ha(G,G,L),this.viewProjectionMatrix=G;const d=Ba();Ja(d,d,[I/2,-J/2,1]),Ia(d,d,[1,-1,0]),Ha(d,d,G);const H=(b=Ba(),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 Za&&a.width===this.width&&a.height===this.height&&Ka(a.projectionMatrix,this.projectionMatrix)&&Ka(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 Na(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),Ca(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=Wa([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]=Sa(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=Ta(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return Sa(a)}unprojectFlat(a){return Ta(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=Wa(d,this.pixelUnprojectionMatrix),f=Sa(c),g=La([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=La([],this.center,g);return Ta(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 Na(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=Sa([q,Fa(t,-85.051129,85.051129)]),d=Sa([s,Fa(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])];Na(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=Ta(w),l=Math.min(p,Ga(Math.abs(Math.min(i,j))));return Na(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new Za({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*Xa:Math.atan(.5/a.altitude),l=(90-a.pitch)*Xa;return k>l-.01?(f=Ya(a,0,d),g=Ya(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const $a=["longitude","latitude","zoom"],_a={curve:1.414,speed:1.2};function ab(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=Ra(l),y=h.zoom,z=[h.longitude,h.latitude],A=Ra(y-l),r=Sa(w),B=Sa(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(){!bb||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),eb?(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(){bb&&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;db.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}(),gb=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),tb="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=fb.getInstance(),d=new sb(b,c,this);tb.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=tb.get(this))[a].apply(b,arguments)}});var ub=void 0!==o.ResizeObserver?o.ResizeObserver:O;function vb(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function wb(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 Bb(a,c){if(a){if("string"==typeof a)return Cb(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 Cb(a,c)}}function Cb(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(vb(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 xb(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(Eb(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:Eb(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;Gb(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){Gb(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(Eb(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 Hb(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function Ib(a,b){if(a===b)return!0;if(Hb(a)&&Hb(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function Jb(a,b,c){return Math.max(b,Math.min(c,a))}function Kb(a,c,b){return Hb(a)?a.map(function(a,d){return Kb(a,c[d],b)}):b*c+(1-b)*a}function Lb(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function Mb(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 Nb(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)),Lb(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 Za(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=Jb(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=Jb(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=Da(b+180,360)-180),(c< -180||c>180)&&(c=Da(c+180,360)-180);const f=Ga(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=Ta([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 Za(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new Za(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 Jb(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=Jb(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 Qb(a){return a[0].toLowerCase()+a.slice(1)}function Rb(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 Sb(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(Tb,{value:Yb(Yb({},b),{},{viewport:b.viewport||$b(Yb({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:_b,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=Qb(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},_b,{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(ac,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bc(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(!Ib(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){Lb(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}}]),a}();function cc(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function dc(a,b){return(dc=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function ec(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&&dc(b,a)}function fc(a){return(fc="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 gc(b,a){if(a&&("object"===fc(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return cc(b)}function hc(a){return(hc=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var ic={longitude:1,bearing:1};function jc(a){return Number.isFinite(a)||Array.isArray(a)}function kc(b,c,a){return b in ic&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function lc(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=mc(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 mc(a,c){if(a){if("string"==typeof a)return nc(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 nc(a,c)}}function nc(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 tc(a,c){if(a){if("string"==typeof a)return uc(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 uc(a,c)}}function uc(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 vb(this,d),g(cc(a=e.call(this)),"propNames",oc),a.props=Object.assign({},rc,b),a}xb(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=lc(pc);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];Lb(jc(g)&&jc(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=kc(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=lc(qc);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]=kc(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,o={}){var c,d,e;const a={},{startZoom:p,startCenterXY:q,uDelta:r,w0:s,u1:k,S:t,rho:l,rho2:u,r0:b}=ab(h,i,o);if(k<.01){for(const f of $a){const v=h[f],w=i[f];a[f]=Ea(v,w,j)}return a}const m=j*t,x=p+Ga(1/(Math.cosh(b)/Math.cosh(b+l*m))),g=(c=[],d=r,e=s*((Math.cosh(b)*Math.tanh(b+l*m)-Math.sinh(b))/u)/k,c[0]=d[0]*e,c[1]=d[1]*e,c);La(g,g,q);const n=Ta(g);return a.longitude=n[0],a.latitude=n[1],a.zoom=x,a}(c,d,e,this.props),a=lc(qc);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=Kb(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}=ab(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 vc=["longitude","latitude","zoom","bearing","pitch"],D=function(b){ec(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=hc(c);if(d){var e=hc(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return gc(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return vb(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||vc,b.around&&(c.around=b.around),c}return xb(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new Za(g).unproject(this.around);Object.assign(e,c,{around:new Za(c).project(h),aroundLngLat:h})}var i,b=sc(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];Lb(jc(f)&&jc(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=kc(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=sc(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=Kb(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var h=Aa(new Za(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:Kb(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]:{};vb(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 xb(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),h=(f=this.state.easing)(g=i),b.transitionEasing=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){Lb(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 Pb(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 wc={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=wc[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 xc=k().Manager;var e=k();const yc=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,zc={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},Ac={doubletap:["tap"]},Bc={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"]},Cc={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"},Dc={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,document;let Y=!1;try{const l={get passive(){return Y=!0,!0}};G.addEventListener("test",l,l),G.removeEventListener("test",l,l)}catch(Ec){}const Fc=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:Gc}=s,Hc="wheel";class Ic{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=Gc.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===Hc&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(Fc&&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:Hc,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:Jc}=s,Kc="pointermove",Lc="pointerover",Mc="pointerout",Nc="pointerleave";class Oc{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=Jc.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===Kc&&(this.enableMoveEvent=b),a===Lc&&(this.enableOverEvent=b),a===Mc&&(this.enableOutEvent=b),a===Nc&&(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:Lc,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:Mc,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:Nc,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:Kc,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1;break;default:}}}const{KEY_EVENTS:Pc}=s,Qc="keydown",Rc="keyup";class Sc{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=Pc.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===Qc&&(this.enableDownEvent=b),a===Rc&&(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:Qc,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:Rc,srcEvent:a,key:a.key,target:a.target}))}}const Tc="contextmenu";class Uc{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===Tc&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:Tc,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const Vc={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},Wc={srcElement:"root",priority:0};class Xc{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({},Wc,a):Wc;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;){if(b[d].priority>=c.priority)break;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&&zc[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 Ic(a,this._onOtherEvent,{enable:!1}),this.moveInput=new Oc(a,this._onOtherEvent,{enable:!1}),this.keyInput=new Sc(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new Uc(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=Ac[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=Dc[b]||b;let a=j.get(c);!a&&(a=new Xc(this),j.set(c,a),a.recognizerName=Cc[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=Dc[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=Bc[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function Zc(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 $c(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&&hd.call(this,"onMouseEnter",a),h&&hd.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function ld(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=fd.call(this,b)).features=gd.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)(Ub),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new Yc(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=ed(ed({},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,Wb(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 ed(ed({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||$b(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(ed(ed(ed({},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:id.bind(a),pointermove:kd.bind(a),pointerup:jd.bind(a),pointerleave:hd.bind(a,"onMouseOut"),click:ld.bind(a),anyclick:ld.bind(a),dblclick:hd.bind(a,"onDblClick"),wheel:hd.bind(a,"onWheel"),contextmenu:hd.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),Vb(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return xa(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ya(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 ed(ed({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(Tb,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,wa({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var md=m;function nd(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)nd(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)nd(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 nd(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)nd(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=rd(rd({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ba;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 td(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(Ub),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 ud(b){var a=b.instance,c=td(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){ec(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=hc(d);if(e){var c=hc(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return gc(this,a)});function a(){var b;vb(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 Bd(b/100*c)/c*100};function Dd(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 ea=Object.assign({},ca,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),fa=Object.assign({},da,{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=td(wd(wd({},d),{},{onDragStart:zd})),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=xd(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=yd(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=yd(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=Wb(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(Bd(v),"px, ").concat(Bd(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 Fd(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=ga,u.defaultProps=ha,c.memo(u);var ia=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string)])}),ja=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=td(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 Nd(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=oa,y.defaultProps=pa,c.memo(y);var qa=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ra=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=td(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=na(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=oa(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=sa(j,k),a.distance=ra(j,k),la(b,a),a.offsetDirection=qa(a.deltaX,a.deltaY);var d=pa(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?ua(c.pointers,e):1,a.rotation=c?ta(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,ma(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function la(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 ma(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=pa(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=qa(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 na(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ra(b,c,a){a||(a=ha);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function sa(b,c,a){a||(a=ha);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function ta(a,b){return sa(b[1],b[0],ia)+sa(a[1],a[0],ia)}function ua(a,b){return ra(b[0],b[1],ia)/ra(a[0],a[1],ia)}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(ea(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(ea(this.element),this.evWin,this.domHandler)}};var va={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=va[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 wa={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},xa={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=wa[a.type.toLowerCase().replace("ms","")],f=xa[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 ya={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 za(b,d){var a=ba(b.touches),c=ba(b.changedTouches);return 12&d&&(a=ca(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ya[c.type];if(1===a&&(this.started=!0),this.started){var b=za.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 Ba(h,g){var b=ba(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ba(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 Ea(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+Ma(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+Ma(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=Na(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[Ia]},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[Ga]},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[Ia]},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=Na(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[Ha]},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)}),nb=new h(4),h!=Float32Array&&(nb[0]=0,nb[1]=0,nb[2]=0,nb[3]=0);const Ga=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function Ha(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 Ia(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 Ja(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 Ka(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 La(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function Ma(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 Na(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}ob=new h(2),h!=Float32Array&&(ob[0]=0,ob[1]=0),pb=new h(3),h!=Float32Array&&(pb[0]=0,pb[1]=0,pb[2]=0);const n=Math.PI,Oa=n/4,Pa=n/180,Qa=180/n;function Ra(a){return Math.pow(2,a)}function Sa([b,a]){return Na(Number.isFinite(b)),Na(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*Pa+n)/(2*n),512*(n+Math.log(Math.tan(Oa+.5*(a*Pa))))/(2*n)]}function Ta([a,b]){return[(a/512*(2*n)-n)*Qa,2*(Math.atan(Math.exp(b/512*(2*n)-n))-Oa)*Qa]}function Ua(a){return 2*Math.atan(.5/a)*Qa}function Va(a){return .5/Math.tan(.5*a*Pa)}function Wa(i,c,j=0){const[a,b,e]=i;if(Na(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=Ca(c,[a,b,e,1]);return k}const f=Ca(c,[a,b,0,1]),g=Ca(c,[a,b,1,1]),d=f[2],h=g[2];return Ma([],f,g,d===h?0:((j||0)-d)/(h-d))}const Xa=Math.PI/180;function Ya(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=Ca(e,[c,0,1,1]),f=Ca(e,[c,a.height,1,1]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=Ma([],b,f,i),g=Ta(j);return g[2]=d,g}class Za{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=Ua(a=1.5):null===b?b=Ua(a):null===a&&(a=Va(b));const r=Ra(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){Na(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*Pa),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=Pa*Math.tan(c*Pa)/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=Sa([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],k=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=Ua(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=Ua(d));const b=.5*a*Pa,c=Va(a),e=h*Pa;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=Ba();return Ia(e,e,[0,0,-I]),a=e,b=e,m=-G*Pa,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*Pa,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,Ja(e,e,[l/=F,l,l]),E&&Ia(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=Ba();Ha(G,G,K),Ha(G,G,L),this.viewProjectionMatrix=G;const d=Ba();Ja(d,d,[I/2,-J/2,1]),Ia(d,d,[1,-1,0]),Ha(d,d,G);const H=(b=Ba(),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 Za&&a.width===this.width&&a.height===this.height&&Ka(a.projectionMatrix,this.projectionMatrix)&&Ka(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 Na(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),Ca(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=Wa([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]=Sa(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=Ta(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return Sa(a)}unprojectFlat(a){return Ta(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=Wa(d,this.pixelUnprojectionMatrix),f=Sa(c),g=La([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=La([],this.center,g);return Ta(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 Na(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=Sa([q,Fa(t,-85.051129,85.051129)]),d=Sa([s,Fa(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])];Na(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=Ta(w),l=Math.min(p,Ga(Math.abs(Math.min(i,j))));return Na(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new Za({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*Xa:Math.atan(.5/a.altitude),l=(90-a.pitch)*Xa;return k>l-.01?(f=Ya(a,0,d),g=Ya(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]}(this,a.z||0)}}const $a=["longitude","latitude","zoom"],_a={curve:1.414,speed:1.2};function ab(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=Ra(l),y=h.zoom,z=[h.longitude,h.latitude],A=Ra(y-l),r=Sa(w),B=Sa(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(){!bb||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),eb?(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(){bb&&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;db.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}(),gb=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),tb="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=fb.getInstance(),d=new sb(b,c,this);tb.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){O.prototype[a]=function(){var b;return(b=tb.get(this))[a].apply(b,arguments)}});var ub=void 0!==o.ResizeObserver?o.ResizeObserver:O;function vb(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function wb(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 Bb(a,c){if(a){if("string"==typeof a)return Cb(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 Cb(a,c)}}function Cb(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(vb(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 xb(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(Eb(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:Eb(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;Gb(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){Gb(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(Eb(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 Hb(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function Ib(a,b){if(a===b)return!0;if(Hb(a)&&Hb(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function Jb(a,b,c){return Math.max(b,Math.min(c,a))}function Kb(a,c,b){return Hb(a)?a.map(function(a,d){return Kb(a,c[d],b)}):b*c+(1-b)*a}function Lb(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function Mb(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 Nb(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)),Lb(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 Za(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=Jb(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=Jb(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=Da(b+180,360)-180),(c< -180||c>180)&&(c=Da(c+180,360)-180);const f=Ga(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=Ta([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 Za(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new Za(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 Jb(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=Jb(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 Qb(a){return a[0].toLowerCase()+a.slice(1)}function Rb(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 Sb(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(Tb,{value:Yb(Yb({},b),{},{viewport:b.viewport||$b(Yb({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:_b,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=Qb(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},_b,{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(ac,null))});j.supported=function(){return A()&&A().supported()},j.propTypes=T,j.defaultProps=U;var q=j;function bc(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(!Ib(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){Lb(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}}]),a}();function cc(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function dc(a,b){return(dc=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function ec(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&&dc(b,a)}function fc(a){return(fc="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 gc(b,a){if(a&&("object"===fc(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return cc(b)}function hc(a){return(hc=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var ic={longitude:1,bearing:1};function jc(a){return Number.isFinite(a)||Array.isArray(a)}function kc(b,c,a){return b in ic&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function lc(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=mc(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 mc(a,c){if(a){if("string"==typeof a)return nc(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 nc(a,c)}}function nc(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 tc(a,c){if(a){if("string"==typeof a)return uc(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 uc(a,c)}}function uc(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 vb(this,d),g(cc(a=e.call(this)),"propNames",oc),a.props=Object.assign({},rc,b),a}xb(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=lc(pc);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];Lb(jc(g)&&jc(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=kc(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=lc(qc);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]=kc(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,o={}){var c,d,e;const a={},{startZoom:p,startCenterXY:q,uDelta:r,w0:s,u1:k,S:t,rho:l,rho2:u,r0:b}=ab(h,i,o);if(k<.01){for(const f of $a){const v=h[f],w=i[f];a[f]=Ea(v,w,j)}return a}const m=j*t,x=p+Ga(1/(Math.cosh(b)/Math.cosh(b+l*m))),g=(c=[],d=r,e=s*((Math.cosh(b)*Math.tanh(b+l*m)-Math.sinh(b))/u)/k,c[0]=d[0]*e,c[1]=d[1]*e,c);La(g,g,q);const n=Ta(g);return a.longitude=n[0],a.latitude=n[1],a.zoom=x,a}(c,d,e,this.props),a=lc(qc);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=Kb(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}=ab(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 vc=["longitude","latitude","zoom","bearing","pitch"],D=function(b){ec(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=hc(c);if(d){var e=hc(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return gc(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return vb(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||vc,b.around&&(c.around=b.around),c}return xb(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new Za(g).unproject(this.around);Object.assign(e,c,{around:new Za(c).project(h),aroundLngLat:h})}var i,b=sc(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];Lb(jc(f)&&jc(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=kc(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=sc(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=Kb(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var h=Aa(new Za(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:Kb(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]:{};vb(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 xb(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),h=(f=this.state.easing)(g=i),b.transitionEasing=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){Lb(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 Pb(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 wc={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=wc[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 xc=k().Manager;var e=k();const yc=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,zc={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},Ac={doubletap:["tap"]},Bc={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"]},Cc={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"},Dc={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(Ec){}const Fc=-1!==X.indexOf("firefox"),{WHEEL_EVENTS:Gc}=s,Hc="wheel";class Ic{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=Gc.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===Hc&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;G.WheelEvent&&(Fc&&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:Hc,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:Jc}=s,Kc="pointermove",Lc="pointerover",Mc="pointerout",Nc="pointerleave";class Oc{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=Jc.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===Kc&&(this.enableMoveEvent=b),a===Lc&&(this.enableOverEvent=b),a===Mc&&(this.enableOutEvent=b),a===Nc&&(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:Lc,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:Mc,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:Nc,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:Kc,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1;break;default:}}}const{KEY_EVENTS:Pc}=s,Qc="keydown",Rc="keyup";class Sc{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=Pc.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===Qc&&(this.enableDownEvent=b),a===Rc&&(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:Qc,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:Rc,srcEvent:a,key:a.key,target:a.target}))}}const Tc="contextmenu";class Uc{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===Tc&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:Tc,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const Vc={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},Wc={srcElement:"root",priority:0};class Xc{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({},Wc,a):Wc;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;){if(b[d].priority>=c.priority)break;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&&zc[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 Ic(a,this._onOtherEvent,{enable:!1}),this.moveInput=new Oc(a,this._onOtherEvent,{enable:!1}),this.keyInput=new Sc(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new Uc(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=Ac[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=Dc[b]||b;let a=j.get(c);!a&&(a=new Xc(this),j.set(c,a),a.recognizerName=Cc[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=Dc[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=Bc[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function Zc(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 $c(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&&hd.call(this,"onMouseEnter",a),h&&hd.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function ld(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=fd.call(this,b)).features=gd.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)(Ub),u=(0,c.useMemo)(function(){return b.controller||new Z},[]),v=(0,c.useMemo)(function(){return new Yc(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=ed(ed({},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,Wb(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 ed(ed({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||$b(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(ed(ed(ed({},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:id.bind(a),pointermove:kd.bind(a),pointerup:jd.bind(a),pointerleave:hd.bind(a,"onMouseOut"),click:ld.bind(a),anyclick:ld.bind(a),dblclick:hd.bind(a,"onDblClick"),wheel:hd.bind(a,"onWheel"),contextmenu:hd.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),Vb(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return xa(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||ya(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 ed(ed({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(Tb,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(q,wa({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});m.supported=q.supported,m.propTypes=$,m.defaultProps=_;var md=m;function nd(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)nd(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)nd(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 nd(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)nd(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=rd(rd({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}}(a,d,b),e.current=b,null}).propTypes=ba;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 td(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(Ub),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 ud(b){var a=b.instance,c=td(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var H=function(b){ec(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=hc(d);if(e){var c=hc(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return gc(this,a)});function a(){var b;vb(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 Bd(b/100*c)/c*100};function Dd(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 ea=Object.assign({},ca,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),fa=Object.assign({},da,{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=td(wd(wd({},d),{},{onDragStart:zd})),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=xd(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=yd(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=yd(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=Wb(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(Bd(v),"px, ").concat(Bd(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 Fd(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=ga,u.defaultProps=ha,c.memo(u);var ia=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string)])}),ja=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function v(a){var b=td(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 Nd(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=oa,y.defaultProps=pa,c.memo(y);var qa=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),ra=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function z(a){var d=td(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