From c4850997a292f9bc6c057b28e002d427db6587c8 Mon Sep 17 00:00:00 2001 From: Austaras Date: Mon, 3 Oct 2022 16:58:38 +0800 Subject: [PATCH] feat(es/minifier): Inline vars initialized before the declaration (#6027) --- .../objectRestAssignment.2.minified.js | 8 +- .../variadicTuples1.2.minified.js | 24 +++--- .../src/analyzer/storage/normal.rs | 6 +- .../tests/benches-full/echarts.js | 6 +- .../tests/benches-full/victory.js | 4 +- .../tests/fixture/issues/2257/full/output.js | 4 +- .../1606726a.10299989c08cb523/output.js | 4 +- .../d6e1aeb5-38a8d7ae57119c23/output.js | 79 +++++++++---------- .../chunks/357-72bd409f1472b1b8/output.js | 50 ++++++------ .../8a28b14e.d8fbda268ed281a1/output.js | 4 +- .../fixture/next/react-pdf-renderer/output.js | 26 +++--- .../next/styled-components/1/output.js | 4 +- .../tests/fixture/simple/inline/5/input.js | 20 +++++ .../tests/fixture/simple/inline/5/output.js | 10 +++ .../785-e1932cc99ac3bb67/output.js | 2 +- .../tests/projects/output/react-dom-17.0.2.js | 30 +++---- 16 files changed, 154 insertions(+), 127 deletions(-) create mode 100644 crates/swc_ecma_minifier/tests/fixture/simple/inline/5/input.js create mode 100644 crates/swc_ecma_minifier/tests/fixture/simple/inline/5/output.js diff --git a/crates/swc/tests/tsc-references/objectRestAssignment.2.minified.js b/crates/swc/tests/tsc-references/objectRestAssignment.2.minified.js index 541bff7971e..14fb77a837d 100644 --- a/crates/swc/tests/tsc-references/objectRestAssignment.2.minified.js +++ b/crates/swc/tests/tsc-references/objectRestAssignment.2.minified.js @@ -2,13 +2,13 @@ let ka, other, complex, overEmit; import _extends from "@swc/helpers/src/_extends.mjs"; import _object_without_properties from "@swc/helpers/src/_object_without_properties.mjs"; -_object_without_properties((_complex = complex).x, [ +_object_without_properties(complex.x, [ "ka" -]), _object_without_properties(_complex, [ +]), _object_without_properties(complex, [ "x", "y" -]), { x: { ka } , y: other } = _complex; -var _complex, { a: [{}, ...y] , b: { z } } = overEmit; +]), { x: { ka } , y: other } = complex; +var { a: [{}, ...y] , b: { z } } = overEmit; _extends({}, overEmit.a[0]), _object_without_properties(overEmit.b, [ "z" ]), _object_without_properties(overEmit, [ diff --git a/crates/swc/tests/tsc-references/variadicTuples1.2.minified.js b/crates/swc/tests/tsc-references/variadicTuples1.2.minified.js index 61c61904d58..30dd8f25af6 100644 --- a/crates/swc/tests/tsc-references/variadicTuples1.2.minified.js +++ b/crates/swc/tests/tsc-references/variadicTuples1.2.minified.js @@ -10,16 +10,16 @@ function curry(f) { return f.apply(void 0, _to_consumable_array(_$a).concat(_to_consumable_array(b))); }; } -u = [ - 10, - !0 -], [ +[ 1 ].concat(_to_consumable_array([ "hello" ]), [ 2 -], _to_consumable_array(u), [ +], _to_consumable_array([ + 10, + !0 +]), [ 3 ]), concat([], []), concat([ "hello" @@ -33,15 +33,15 @@ u = [ 1, 2, 3 -]), u1 = [ - 4, - 5, - 6 -], _to_consumable_array([ +]), _to_consumable_array([ 1, 2, 3 -]).concat(_to_consumable_array(u1)), ft1([ +]).concat(_to_consumable_array([ + 4, + 5, + 6 +])), ft1([ "hello", 42 ]), ft2([ @@ -67,7 +67,7 @@ u = [ "def" ] ]); -var u, u1, fn1 = function(a1, b, c, d) { +var fn1 = function(a1, b, c, d) { return 0; }; curry(fn1), curry(fn1, 1), curry(fn1, 1, "abc"), curry(fn1, 1, "abc", !0), curry(fn1, 1, "abc", !0, [ diff --git a/crates/swc_ecma_minifier/src/analyzer/storage/normal.rs b/crates/swc_ecma_minifier/src/analyzer/storage/normal.rs index 5c8660aee6c..46a193faf38 100644 --- a/crates/swc_ecma_minifier/src/analyzer/storage/normal.rs +++ b/crates/swc_ecma_minifier/src/analyzer/storage/normal.rs @@ -146,7 +146,7 @@ impl Storage for ProgramData { .vars .entry(i.to_id()) .and_modify(|v| { - if has_init && v.declared { + if has_init && (v.declared || v.var_initialized) { trace_op!("declare_decl(`{}`): Already declared", i); v.mutated = true; @@ -224,9 +224,11 @@ impl ProgramData { let e = self.vars.entry(i.clone()).or_insert_with(|| { // trace!("insert({}{:?})", i.0, i.1); + let simple_assign = ctx.is_exact_reassignment && !ctx.is_op_assign; + VarUsageInfo { is_fn_local: true, - used_above_decl: true, + used_above_decl: !simple_assign, ..Default::default() } }); diff --git a/crates/swc_ecma_minifier/tests/benches-full/echarts.js b/crates/swc_ecma_minifier/tests/benches-full/echarts.js index d3a1d0bc8bd..02448f4eb77 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/echarts.js +++ b/crates/swc_ecma_minifier/tests/benches-full/echarts.js @@ -4417,7 +4417,7 @@ target.registerClass = function(clz) { var componentFullType = clz.type || clz.prototype.type; if (componentFullType) { - componentType = componentFullType, assert(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentType), 'componentType "' + componentType + '" illegal'), clz.prototype.type = componentFullType; + assert(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentFullType), 'componentType "' + componentFullType + '" illegal'), clz.prototype.type = componentFullType; var componentTypeInfo, container, componentType, componentTypeInfo1 = parseClassType(componentFullType); componentTypeInfo1.sub ? componentTypeInfo1.sub !== IS_CONTAINER && (((container = storage[(componentTypeInfo = componentTypeInfo1).main]) && container[IS_CONTAINER] || ((container = storage[componentTypeInfo.main] = {})[IS_CONTAINER] = !0), container)[componentTypeInfo1.sub] = clz) : (storage[componentTypeInfo1.main] && console.warn(componentTypeInfo1.main + ' exists.'), storage[componentTypeInfo1.main] = clz); } @@ -16744,7 +16744,7 @@ var displayable = list[i], svgProxy = getSvgProxy(displayable), svgElement = getSvgElement(displayable); !displayable.invisible && ((displayable.__dirty || !svgElement) && (svgProxy && svgProxy.brush(displayable), (svgElement = getSvgElement(displayable)) && displayable.style && (gradientManager.update(displayable.style.fill), gradientManager.update(displayable.style.stroke), patternManager.update(displayable.style.fill), patternManager.update(displayable.style.stroke), shadowManager.update(svgElement, displayable)), displayable.__dirty = 0), svgElement && newVisibleList.push(displayable)); } - for(var diff = (oldArr = visibleList, newArr = newVisibleList, function(oldArr, newArr, equals) { + for(var diff = function(oldArr, newArr, equals) { equals || (equals = function(a, b) { return a === b; }), oldArr = oldArr.slice(); @@ -16797,7 +16797,7 @@ }(); if (ret) return ret; } - }(oldArr, newArr, void 0)), i = 0; i < diff.length; i++){ + }(visibleList, newVisibleList, void 0), i = 0; i < diff.length; i++){ var item = diff[i]; if (item.removed) for(var k = 0; k < item.count; k++){ var oldArr, newArr, child, parent, child1, displayable = visibleList[item.indices[k]], svgElement = getSvgElement(displayable); diff --git a/crates/swc_ecma_minifier/tests/benches-full/victory.js b/crates/swc_ecma_minifier/tests/benches-full/victory.js index e7d44328568..9cb303e36fb 100644 --- a/crates/swc_ecma_minifier/tests/benches-full/victory.js +++ b/crates/swc_ecma_minifier/tests/benches-full/victory.js @@ -16569,7 +16569,7 @@ function VictoryTransition(props, context) { !function(instance, Constructor) { if (!(instance instanceof Constructor)) throw TypeError("Cannot call a class as a function"); - }(this, VictoryTransition), self1 = this, (_this = (call = (VictoryTransition.__proto__ || Object.getPrototypeOf(VictoryTransition)).call(this, props, context)) && ("object" == typeof call || "function" == typeof call) ? call : _assertThisInitialized(self1)).state = { + }(this, VictoryTransition), (_this = (call = (VictoryTransition.__proto__ || Object.getPrototypeOf(VictoryTransition)).call(this, props, context)) && ("object" == typeof call || "function" == typeof call) ? call : _assertThisInitialized(this)).state = { nodesShouldLoad: !1, nodesDoneLoad: !1 }; @@ -16783,7 +16783,7 @@ function addEvents(props) { !function(instance, Constructor) { if (!(instance instanceof Constructor)) throw TypeError("Cannot call a class as a function"); - }(this, addEvents), self1 = this, _this = (call = (addEvents.__proto__ || Object.getPrototypeOf(addEvents)).call(this, props)) && ("object" == typeof call || "function" == typeof call) ? call : _assertThisInitialized(self1); + }(this, addEvents), _this = (call = (addEvents.__proto__ || Object.getPrototypeOf(addEvents)).call(this, props)) && ("object" == typeof call || "function" == typeof call) ? call : _assertThisInitialized(this); var self1, call, _this, getScopedEvents = _events__WEBPACK_IMPORTED_MODULE_10__.default.getScopedEvents.bind(_assertThisInitialized(_this)), boundGetEvents = _events__WEBPACK_IMPORTED_MODULE_10__.default.getEvents.bind(_assertThisInitialized(_this)); _this.state = {}, _this.getEvents = function(p, target, eventKey) { return boundGetEvents(p, target, eventKey, getScopedEvents); diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js b/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js index 41da42fbf31..3556fb92587 100644 --- a/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/issues/2257/full/output.js @@ -9783,8 +9783,8 @@ if (ok) { var path = createPath(location), encodedPath = encodePath(basename + path); if (getHashPath() !== encodedPath) { - ignorePath = path, path1 = encodedPath, window.location.hash = path1; - var path1, prevIndex = allPaths.lastIndexOf(createPath(history.location)), nextPaths = allPaths.slice(0, prevIndex + 1); + ignorePath = path, window.location.hash = encodedPath; + var prevIndex = allPaths.lastIndexOf(createPath(history.location)), nextPaths = allPaths.slice(0, prevIndex + 1); nextPaths.push(path), allPaths = nextPaths, setState({ action: action, location: location diff --git a/crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js b/crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js index 53936aed4f0..5f4728debc7 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js @@ -2563,9 +2563,9 @@ }(view.dom, coords, box))) return null; } if (result.safari) for(var p = elt; node && p; p = parentNode(p))p.draggable && (node = offset = null); - if (dom = elt, coords1 = coords, elt = (parent = dom.parentNode) && /^li$/i.test(parent.nodeName) && coords1.left < dom.getBoundingClientRect().left ? parent : dom, node) { + if (elt = (parent = (dom = elt).parentNode) && /^li$/i.test(parent.nodeName) && coords.left < dom.getBoundingClientRect().left ? parent : dom, node) { if (result.gecko && 1 == node.nodeType && (offset = Math.min(offset, node.childNodes.length)) < node.childNodes.length) { - var dom, coords1, parent, box$1, next = node.childNodes[offset]; + var dom, parent, box$1, next = node.childNodes[offset]; "IMG" == next.nodeName && (box$1 = next.getBoundingClientRect()).right <= coords.left && box$1.bottom > coords.top && offset++; } node == view.dom && offset == node.childNodes.length - 1 && 1 == node.lastChild.nodeType && coords.top > node.lastChild.getBoundingClientRect().bottom ? pos = view.state.doc.content.size : (0 == offset || 1 != node.nodeType || "BR" != node.childNodes[offset - 1].nodeName) && (pos = function(view, node, offset, coords) { diff --git a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js index 813e18d2ea6..00387ab95d9 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js @@ -7842,46 +7842,8 @@ for(i = payload.length; i--;)size += payload[i].byteLength; for(result = new Uint8Array(size + 8), new DataView(result.buffer, result.byteOffset, result.byteLength).setUint32(0, result.byteLength), result.set(type, 4), i = 0, size = 8; i < payload.length; i++)result.set(payload[i], size), size += payload[i].byteLength; return result; - }, dinf = function() { - return box(types.dinf, box(types.dref, DREF)); - }, esds = function(track) { - return box(types.esds, new Uint8Array([ - 0x00, - 0x00, - 0x00, - 0x00, - 0x03, - 0x19, - 0x00, - 0x00, - 0x00, - 0x04, - 0x11, - 0x40, - 0x15, - 0x00, - 0x06, - 0x00, - 0x00, - 0x00, - 0xda, - 0xc0, - 0x00, - 0x00, - 0xda, - 0xc0, - 0x05, - 0x02, - track.audioobjecttype << 3 | track.samplingfrequencyindex >>> 1, - track.samplingfrequencyindex << 7 | track.channelcount << 3, - 0x06, - 0x01, - 0x02 - ])); }, ftyp = function() { return box(types.ftyp, MAJOR_BRAND, MINOR_VERSION, MAJOR_BRAND, AVC1_BRAND); - }, hdlr = function(type) { - return box(types.hdlr, HDLR_TYPES[type]); }, mdat = function(data) { return box(types.mdat, data); }, mdhd = function(track) { @@ -7913,7 +7875,8 @@ ]); return track.samplerate && (result[12] = track.samplerate >>> 24 & 0xff, result[13] = track.samplerate >>> 16 & 0xff, result[14] = track.samplerate >>> 8 & 0xff, result[15] = 0xff & track.samplerate), box(types.mdhd, result); }, mdia = function(track) { - return box(types.mdia, mdhd(track), hdlr(track.type), minf(track)); + var type; + return box(types.mdia, mdhd(track), (type = track.type, box(types.hdlr, HDLR_TYPES[type])), minf(track)); }, mfhd = function(sequenceNumber) { return box(types.mfhd, new Uint8Array([ 0x00, @@ -7926,7 +7889,7 @@ 0xff & sequenceNumber ])); }, minf = function(track) { - return box(types.minf, "video" === track.type ? box(types.vmhd, VMHD) : box(types.smhd, SMHD), dinf(), stbl(track)); + return box(types.minf, "video" === track.type ? box(types.vmhd, VMHD) : box(types.smhd, SMHD), box(types.dinf, box(types.dref, DREF)), stbl(track)); }, moof = function(sequenceNumber, tracks) { for(var trackFragments = [], i = tracks.length; i--;)trackFragments[i] = traf(tracks[i]); return box.apply(null, [ @@ -8220,7 +8183,39 @@ 0xff & track.samplerate, 0x00, 0x00 - ]), esds(track)); + ]), box(types.esds, new Uint8Array([ + 0x00, + 0x00, + 0x00, + 0x00, + 0x03, + 0x19, + 0x00, + 0x00, + 0x00, + 0x04, + 0x11, + 0x40, + 0x15, + 0x00, + 0x06, + 0x00, + 0x00, + 0x00, + 0xda, + 0xc0, + 0x00, + 0x00, + 0xda, + 0xc0, + 0x05, + 0x02, + track.audioobjecttype << 3 | track.samplingfrequencyindex >>> 1, + track.samplingfrequencyindex << 7 | track.channelcount << 3, + 0x06, + 0x01, + 0x02 + ]))); }, tkhd = function(track) { var result = new Uint8Array([ 0x00, @@ -9318,7 +9313,7 @@ }; }; TimestampRolloverStream$1.prototype = new Stream(); - var videoSample, audioSample, audioTrun, videoTrun, trunHeader, box, dinf, esds, ftyp, mdat, mfhd, minf, moof, moov, mvex, mvhd, trak, tkhd, mdia, mdhd, hdlr, sdtp, stbl, stsd, traf, trex, trun$1, types, MAJOR_BRAND, MINOR_VERSION, AVC1_BRAND, VIDEO_HDLR, AUDIO_HDLR, HDLR_TYPES, VMHD, SMHD, DREF, STCO, STSC, STSZ, STTS, silence, secondsToVideoTs, secondsToAudioTs, videoTsToSeconds, audioTsToSeconds, audioTsToVideoTs, videoTsToAudioTs, metadataTsToSeconds, _MetadataStream, timestampRolloverStream = { + var videoSample, audioSample, audioTrun, videoTrun, trunHeader, box, ftyp, mdat, mfhd, minf, moof, moov, mvex, mvhd, trak, tkhd, mdia, mdhd, sdtp, stbl, stsd, traf, trex, trun$1, types, MAJOR_BRAND, MINOR_VERSION, AVC1_BRAND, VIDEO_HDLR, AUDIO_HDLR, HDLR_TYPES, VMHD, SMHD, DREF, STCO, STSC, STSZ, STTS, silence, secondsToVideoTs, secondsToAudioTs, videoTsToSeconds, audioTsToSeconds, audioTsToVideoTs, videoTsToAudioTs, metadataTsToSeconds, _MetadataStream, timestampRolloverStream = { TimestampRolloverStream: TimestampRolloverStream$1, handleRollover: handleRollover$1 }, percentEncode$1 = function(bytes, start, end) { diff --git a/crates/swc_ecma_minifier/tests/fixture/next/octokit/static/chunks/357-72bd409f1472b1b8/output.js b/crates/swc_ecma_minifier/tests/fixture/next/octokit/static/chunks/357-72bd409f1472b1b8/output.js index c4cb23ea6e5..1cd6a996555 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/octokit/static/chunks/357-72bd409f1472b1b8/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/octokit/static/chunks/357-72bd409f1472b1b8/output.js @@ -95,11 +95,11 @@ return e = error, this.trigger("error", e), null; } } - }, DLList$1 = DLList, Events$1 = Events, Queues = class { + }, Queues = class { constructor(num_priorities){ - this.Events = new Events$1(this), this._length = 0, this._lists = (function() { + this.Events = new Events(this), this._length = 0, this._lists = (function() { var j, results; - for(results = [], j = 1; 1 <= num_priorities ? j <= num_priorities : j >= num_priorities; 1 <= num_priorities ? ++j : --j)results.push(new DLList$1(()=>this.incr(), ()=>this.decr())); + for(results = [], j = 1; 1 <= num_priorities ? j <= num_priorities : j >= num_priorities; 1 <= num_priorities ? ++j : --j)results.push(new DLList(()=>this.incr(), ()=>this.decr())); return results; }).call(this); } @@ -129,21 +129,21 @@ return this.getFirst(this._lists.slice(priority).reverse()).shift(); } }, BottleneckError = class extends Error { - }, NUM_PRIORITIES = 10, DEFAULT_PRIORITY = 5, parser$1 = parser, BottleneckError$1 = BottleneckError, Job = class { + }, Job = class { constructor(task, args, options, jobDefaults, rejectOnDrop, Events, _states, Promise1){ - this.task = task, this.args = args, this.rejectOnDrop = rejectOnDrop, this.Events = Events, this._states = _states, this.Promise = Promise1, this.options = parser$1.load(options, jobDefaults), this.options.priority = this._sanitizePriority(this.options.priority), this.options.id === jobDefaults.id && (this.options.id = `${this.options.id}-${this._randomIndex()}`), this.promise = new this.Promise((_resolve, _reject)=>{ + this.task = task, this.args = args, this.rejectOnDrop = rejectOnDrop, this.Events = Events, this._states = _states, this.Promise = Promise1, this.options = parser.load(options, jobDefaults), this.options.priority = this._sanitizePriority(this.options.priority), this.options.id === jobDefaults.id && (this.options.id = `${this.options.id}-${this._randomIndex()}`), this.promise = new this.Promise((_resolve, _reject)=>{ this._resolve = _resolve, this._reject = _reject; }), this.retryCount = 0; } _sanitizePriority(priority) { var sProperty; - return (sProperty = ~~priority !== priority ? DEFAULT_PRIORITY : priority) < 0 ? 0 : sProperty > NUM_PRIORITIES - 1 ? NUM_PRIORITIES - 1 : sProperty; + return (sProperty = ~~priority !== priority ? 5 : priority) < 0 ? 0 : sProperty > 9 ? 9 : sProperty; } _randomIndex() { return Math.random().toString(36).slice(2); } doDrop({ error , message ="This job has been dropped by Bottleneck" } = {}) { - return !!this._states.remove(this.options.id) && (this.rejectOnDrop && this._reject(null != error ? error : new BottleneckError$1(message)), this.Events.trigger("dropped", { + return !!this._states.remove(this.options.id) && (this.rejectOnDrop && this._reject(null != error ? error : new BottleneckError(message)), this.Events.trigger("dropped", { args: this.args, options: this.options, task: this.task, @@ -152,7 +152,7 @@ } _assertStatus(expected) { var status; - if (!((status = this._states.jobStatus(this.options.id)) === expected || "DONE" === expected && null === status)) throw new BottleneckError$1(`Invalid job status ${status}, expected ${expected}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`); + if (!((status = this._states.jobStatus(this.options.id)) === expected || "DONE" === expected && null === status)) throw new BottleneckError(`Invalid job status ${status}, expected ${expected}. Please open an issue at https://github.com/SGrondin/bottleneck/issues`); } doReceive() { return this._states.start(this.options.id), this.Events.trigger("received", { @@ -193,7 +193,7 @@ args: this.args, options: this.options, retryCount: this.retryCount - }, error = new BottleneckError$1(`This job timed out after ${this.options.expiration} ms.`), this._onFailure(error, eventInfo, clearGlobalState, run, free); + }, error = new BottleneckError(`This job timed out after ${this.options.expiration} ms.`), this._onFailure(error, eventInfo, clearGlobalState, run, free); } async _onFailure(error, eventInfo, clearGlobalState, run, free) { var retry, retryAfter; @@ -202,9 +202,9 @@ doDone(eventInfo) { return this._assertStatus("EXECUTING"), this._states.next(this.options.id), this.Events.trigger("done", eventInfo); } - }, parser$2 = parser, BottleneckError$2 = BottleneckError, LocalDatastore = class { + }, LocalDatastore = class { constructor(instance, storeOptions, storeInstanceOptions){ - this.instance = instance, this.storeOptions = storeOptions, this.clientId = this.instance._randomIndex(), parser$2.load(storeInstanceOptions, storeInstanceOptions, this), this._nextRequest = this._lastReservoirRefresh = this._lastReservoirIncrease = Date.now(), this._running = 0, this._done = 0, this._unblockTime = 0, this.ready = this.Promise.resolve(), this.clients = {}, this._startHeartbeat(); + this.instance = instance, this.storeOptions = storeOptions, this.clientId = this.instance._randomIndex(), parser.load(storeInstanceOptions, storeInstanceOptions, this), this._nextRequest = this._lastReservoirRefresh = this._lastReservoirIncrease = Date.now(), this._running = 0, this._done = 0, this._unblockTime = 0, this.ready = this.Promise.resolve(), this.clients = {}, this._startHeartbeat(); } _startHeartbeat() { var base; @@ -229,7 +229,7 @@ return null != (ref = this.storeOptions.penalty) ? ref : 15 * this.storeOptions.minTime || 5000; } async __updateSettings__(options) { - return await this.yieldLoop(), parser$2.overwrite(options, options, this.storeOptions), this._startHeartbeat(), this.instance._drainAll(this.computeCapacity()), !0; + return await this.yieldLoop(), parser.overwrite(options, options, this.storeOptions), this._startHeartbeat(), this.instance._drainAll(this.computeCapacity()), !0; } async __running__() { return await this.yieldLoop(), this._running; @@ -283,7 +283,7 @@ } async __submit__(queueLength, weight) { var blocked, now, reachedHWM; - if (await this.yieldLoop(), null != this.storeOptions.maxConcurrent && weight > this.storeOptions.maxConcurrent) throw new BottleneckError$2(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${this.storeOptions.maxConcurrent}`); + if (await this.yieldLoop(), null != this.storeOptions.maxConcurrent && weight > this.storeOptions.maxConcurrent) throw new BottleneckError(`Impossible to add a job having a weight of ${weight} to a limiter having a maxConcurrent setting of ${this.storeOptions.maxConcurrent}`); return now = Date.now(), reachedHWM = null != this.storeOptions.highWater && queueLength === this.storeOptions.highWater && !this.check(weight, now), (blocked = this.strategyIsBlock() && (reachedHWM || this.isBlocked(now))) && (this._unblockTime = now + this.computePenalty(), this._nextRequest = this._unblockTime + this.storeOptions.minTime, this.instance._dropAllQueued()), { reachedHWM, blocked, @@ -295,7 +295,7 @@ running: this._running }; } - }, BottleneckError$3 = BottleneckError, States = class { + }, States = class { constructor(status1){ this.status = status1, this._jobs = {}, this.counts = this.status.map(function() { return 0; @@ -319,16 +319,16 @@ statusJobs(status) { var k, pos, ref, results; if (null == status) return Object.keys(this._jobs); - if ((pos = this.status.indexOf(status)) < 0) throw new BottleneckError$3(`status must be one of ${this.status.join(', ')}`); + if ((pos = this.status.indexOf(status)) < 0) throw new BottleneckError(`status must be one of ${this.status.join(', ')}`); for(k in ref = this._jobs, results = [], ref)ref[k] === pos && results.push(k); return results; } statusCounts() { return this.counts.reduce((acc, v, i)=>(acc[this.status[i]] = v, acc), {}); } - }, DLList$2 = DLList, Sync = class { + }, Sync = class { constructor(name, Promise1){ - this.schedule = this.schedule.bind(this), this.name = name, this.Promise = Promise1, this._running = 0, this._queue = new DLList$2(); + this.schedule = this.schedule.bind(this), this.name = name, this.Promise = Promise1, this._running = 0, this._queue = new DLList(); } isEmpty() { return 0 === this._queue.length; @@ -365,12 +365,12 @@ version: version } }), require$$2 = ()=>console.log('You must import the full version of Bottleneck in order to use this feature.'), require$$3 = ()=>console.log('You must import the full version of Bottleneck in order to use this feature.'), require$$4 = ()=>console.log('You must import the full version of Bottleneck in order to use this feature.'); - parser$3 = parser, Events$2 = Events, RedisConnection$1 = require$$2, IORedisConnection$1 = require$$3, Scripts$1 = require$$4, Group = (function() { + Group = (function() { class Group { constructor(limiterOptions = {}){ - this.deleteKey = this.deleteKey.bind(this), this.limiterOptions = limiterOptions, parser$3.load(this.limiterOptions, this.defaults, this), this.Events = new Events$2(this), this.instances = {}, this.Bottleneck = Bottleneck_1, this._startAutoCleanup(), this.sharedConnection = null != this.connection, null == this.connection && ("redis" === this.limiterOptions.datastore ? this.connection = new RedisConnection$1(Object.assign({}, this.limiterOptions, { + this.deleteKey = this.deleteKey.bind(this), this.limiterOptions = limiterOptions, parser.load(this.limiterOptions, this.defaults, this), this.Events = new Events(this), this.instances = {}, this.Bottleneck = Bottleneck_1, this._startAutoCleanup(), this.sharedConnection = null != this.connection, null == this.connection && ("redis" === this.limiterOptions.datastore ? this.connection = new require$$2(Object.assign({}, this.limiterOptions, { Events: this.Events - })) : "ioredis" === this.limiterOptions.datastore && (this.connection = new IORedisConnection$1(Object.assign({}, this.limiterOptions, { + })) : "ioredis" === this.limiterOptions.datastore && (this.connection = new require$$3(Object.assign({}, this.limiterOptions, { Events: this.Events })))); } @@ -389,7 +389,7 @@ var deleted, instance; return instance = this.instances[key], this.connection && (deleted = await this.connection.__runCommand__([ 'del', - ...Scripts$1.allKeys(`${this.id}-${key}`) + ...require$$4.allKeys(`${this.id}-${key}`) ])), null != instance && (delete this.instances[key], await instance.disconnect()), null != instance || deleted > 0; } limiters() { @@ -432,7 +432,7 @@ }, this.timeout / 2)).unref ? base.unref() : void 0; } updateSettings(options = {}) { - if (parser$3.overwrite(options, this.defaults, this), parser$3.overwrite(options, options, this.limiterOptions), null != options.timeout) return this._startAutoCleanup(); + if (parser.overwrite(options, this.defaults, this), parser.overwrite(options, options, this.limiterOptions), null != options.timeout) return this._startAutoCleanup(); } disconnect(flush = !0) { var ref; @@ -445,10 +445,10 @@ Promise: Promise, id: "group-key" }, Group; - }).call(commonjsGlobal), parser$4 = parser, Events$3 = Events, Batcher = (function() { + }).call(commonjsGlobal), Batcher = (function() { class Batcher { constructor(options = {}){ - this.options = options, parser$4.load(this.options, this.defaults, this), this.Events = new Events$3(this), this._arr = [], this._resetPromise(), this._lastFlush = Date.now(); + this.options = options, parser.load(this.options, this.defaults, this), this.Events = new Events(this), this._arr = [], this._resetPromise(), this._lastFlush = Date.now(); } _resetPromise() { return this._promise = new this.Promise((res, rej)=>this._resolve = res); @@ -467,7 +467,7 @@ Promise: Promise }, Batcher; }).call(commonjsGlobal); - var DLList, Events, DLList$1, Events$1, Queues, BottleneckError, BottleneckError$1, DEFAULT_PRIORITY, Job, NUM_PRIORITIES, parser$1, BottleneckError$2, LocalDatastore, parser$2, BottleneckError$3, States, DLList$2, Sync, Events$2, Group, IORedisConnection$1, RedisConnection$1, Scripts$1, parser$3, Batcher, Events$3, parser$4, require$$4$1 = ()=>console.log('You must import the full version of Bottleneck in order to use this feature.'), require$$8 = version$2 && version$2.default || version$2, splice = [].splice, Bottleneck_1 = (function() { + var DLList, Events, Queues, BottleneckError, Job, LocalDatastore, States, Sync, Group, Batcher, require$$4$1 = ()=>console.log('You must import the full version of Bottleneck in order to use this feature.'), require$$8 = version$2 && version$2.default || version$2, splice = [].splice, Bottleneck_1 = (function() { class Bottleneck { constructor(options = {}, ...invalid){ var storeInstanceOptions, storeOptions; diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js index c0135cfba40..33cfc3f7960 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/output.js @@ -5111,8 +5111,8 @@ }), fold.collapseChildren = this.collapseChildren, fold; }, this.addSubFold = function(fold) { if (!this.range.isEqual(fold)) { - range = fold, anchor = this.start, consumePoint(range.start, anchor), consumePoint(range.end, anchor); - for(var range, anchor, row = fold.start.row, column = fold.start.column, i = 0, cmp = -1; i < this.subFolds.length && 1 == (cmp = this.subFolds[i].range.compare(row, column)); i++); + anchor = this.start, consumePoint(fold.start, anchor), consumePoint(fold.end, anchor); + for(var anchor, row = fold.start.row, column = fold.start.column, i = 0, cmp = -1; i < this.subFolds.length && 1 == (cmp = this.subFolds[i].range.compare(row, column)); i++); var afterStart = this.subFolds[i], firstConsumed = 0; if (0 == cmp) { if (afterStart.range.containsRange(fold)) return afterStart.addSubFold(fold); diff --git a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js index 2b78dbdb2e2..2b5f0a72d0a 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/react-pdf-renderer/output.js @@ -2291,17 +2291,17 @@ return t.type === e; }; }, tL = tN(T.Svg), tU = tN(T.Text), tz = function e(t, r) { - if (n = t, tU(n) && !n.lines) { - var n, i = t.box.width - (t.box.paddingRight + t.box.paddingLeft), o = t.box.height - (t.box.paddingTop + t.box.paddingBottom); - t.lines = tM(t, i, o, r); + if (tU(t) && !t.lines) { + var n = t.box.width - (t.box.paddingRight + t.box.paddingLeft), i = t.box.height - (t.box.paddingTop + t.box.paddingBottom); + t.lines = tM(t, n, i, r); } if (!tL(t) && !tU(t)) { if (!t.children) return t; - var a = function(t) { + var o = function(t) { return e(t, r); - }, u = t.children.map(a); + }, a = t.children.map(o); return Object.assign({}, t, { - children: u + children: a }); } return t; @@ -2605,11 +2605,11 @@ return a.isNil(e) ? null : a.compose(rG, rq, rW, rz, function e(t, r) { return function(n) { var i = q.default.Node.createWithConfig(rO), o = Object.assign({}, n); - if (o[rT] = i, rL(o), u = n, !rF(u) && !rR(u) && !rP(u) && n.children) { - var u, l = a.compose(function(e) { + if (o[rT] = i, rL(o), !rF(n) && !rR(n) && !rP(n) && n.children) { + var u = a.compose(function(e) { return i.insertChild(e[rT], i.getChildCount()), e; }, e(t, r)); - o.children = n.children.map(l); + o.children = n.children.map(u); } return rU(o, t, r), o; }; @@ -15994,12 +15994,12 @@ }), r > 2) ? "one of ".concat(t, " ").concat(e.slice(0, r - 1).join(", "), ", or ") + e[r - 1] : 2 === r ? "one of ".concat(t, " ").concat(e[0], " or ").concat(e[1]) : "of ".concat(t, " ").concat(e[0]); } s("ERR_AMBIGUOUS_ARGUMENT", 'The "%s" argument is ambiguous. %s', TypeError), s("ERR_INVALID_ARG_TYPE", function(e, t, i) { - if ((void 0 === a && (a = r(313)), a("string" == typeof e, "'name' must be a string"), "string" == typeof t && (o = "not ", t.substr(!u || u < 0 ? 0 : +u, o.length) === o)) ? (p = "must not be", t = t.replace(/^not /, "")) : p = "must be", l = e, s = " argument", (void 0 === f || f > l.length) && (f = l.length), l.substring(f - s.length, f) === s) h = "The ".concat(e, " ").concat(p, " ").concat(c(t, "type")); + if ((void 0 === a && (a = r(313)), a("string" == typeof e, "'name' must be a string"), "string" == typeof t && (o = "not ", t.substr(!u || u < 0 ? 0 : +u, o.length) === o)) ? (d = "must not be", t = t.replace(/^not /, "")) : d = "must be", l = " argument", (void 0 === s || s > e.length) && (s = e.length), e.substring(s - l.length, s) === l) p = "The ".concat(e, " ").concat(d, " ").concat(c(t, "type")); else { - var o, u, l, s, f, d, p, h, y = ("number" != typeof d && (d = 0), d + 1 > e.length || -1 === e.indexOf(".", d)) ? "argument" : "property"; - h = 'The "'.concat(e, '" ').concat(y, " ").concat(p, " ").concat(c(t, "type")); + var o, u, l, s, f, d, p, h = ("number" != typeof f && (f = 0), f + 1 > e.length || -1 === e.indexOf(".", f)) ? "argument" : "property"; + p = 'The "'.concat(e, '" ').concat(h, " ").concat(d, " ").concat(c(t, "type")); } - return h + ". Received type ".concat(n(i)); + return p + ". Received type ".concat(n(i)); }, TypeError), s("ERR_INVALID_ARG_VALUE", function(e, t) { var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "is invalid"; void 0 === u && (u = r(650)); diff --git a/crates/swc_ecma_minifier/tests/fixture/next/styled-components/1/output.js b/crates/swc_ecma_minifier/tests/fixture/next/styled-components/1/output.js index 7ddf2f1a880..ed37ef2aa87 100644 --- a/crates/swc_ecma_minifier/tests/fixture/next/styled-components/1/output.js +++ b/crates/swc_ecma_minifier/tests/fixture/next/styled-components/1/output.js @@ -4868,11 +4868,11 @@ })); }, s; }(function qe(e, t, n) { - var o = N(e), i = !ke(e), a = t.attrs, c = void 0 === a ? w : a, d = t.componentId, h = void 0 === d ? (e1 = t.displayName, t1 = t.parentComponentId, Ye[n1 = "string" != typeof e1 ? "sc" : Te(e1)] = (Ye[n1] || 0) + 1, r = n1 + "-" + xe("5.3.5" + n1 + Ye[n1]), t1 ? t1 + "-" + r : r) : d, p = t.displayName, f = void 0 === p ? (e2 = e, ke(e2) ? "styled." + e2 : "Styled(" + _(e2) + ")") : p, g = t.displayName && t.componentId ? Te(t.displayName) + "-" + t.componentId : t.componentId || h, S = o && e.attrs ? Array.prototype.concat(e.attrs, c).filter(Boolean) : c, A = t.shouldForwardProp; + var o = N(e), i = !ke(e), a = t.attrs, c = void 0 === a ? w : a, d = t.componentId, h = void 0 === d ? (e1 = t.displayName, t1 = t.parentComponentId, Ye[n1 = "string" != typeof e1 ? "sc" : Te(e1)] = (Ye[n1] || 0) + 1, r = n1 + "-" + xe("5.3.5" + n1 + Ye[n1]), t1 ? t1 + "-" + r : r) : d, p = t.displayName, f = void 0 === p ? ke(e) ? "styled." + e : "Styled(" + _(e) + ")" : p, g = t.displayName && t.componentId ? Te(t.displayName) + "-" + t.componentId : t.componentId || h, S = o && e.attrs ? Array.prototype.concat(e.attrs, c).filter(Boolean) : c, A = t.shouldForwardProp; o && e.shouldForwardProp && (A = t.shouldForwardProp ? function(n, r, o) { return e.shouldForwardProp(n, r, o) && t.shouldForwardProp(n, r, o); } : e.shouldForwardProp); - var e1, t1, n1, r, e2, C, I = new se(n, g, o ? e.componentStyle : void 0), P = I.isStatic && 0 === c.length, O = function(e, t) { + var e1, t1, n1, r, C, I = new se(n, g, o ? e.componentStyle : void 0), P = I.isStatic && 0 === c.length, O = function(e, t) { return function(e, t, n, r) { var e1, r1, o, o1, s, o2 = e.attrs, i = e.componentStyle, a = e.defaultProps, c = e.foldedComponentIds, d = e.shouldForwardProp, h = e.styledComponentId, p = e.target, f = (void 0 === (e1 = Re(t, (0, react.useContext)(Ge), a) || E) && (e1 = E), r1 = v({}, t, { theme: e1 diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/inline/5/input.js b/crates/swc_ecma_minifier/tests/fixture/simple/inline/5/input.js new file mode 100644 index 00000000000..02aaae06845 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/simple/inline/5/input.js @@ -0,0 +1,20 @@ +export function foo() { + b = 1; + console.log(2); + console.log(b); + + for (var b, c = 0; c < 10; c++) { + console.log(c); + } +} + +export function bar() { + function x() { + b = 1; + } + + for (var b = 10, c = 0; c < 10; c++) { + /*#__NOINLINE__*/ x(); + console.log(b, c); + } +} diff --git a/crates/swc_ecma_minifier/tests/fixture/simple/inline/5/output.js b/crates/swc_ecma_minifier/tests/fixture/simple/inline/5/output.js new file mode 100644 index 00000000000..4533c3df508 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/simple/inline/5/output.js @@ -0,0 +1,10 @@ +export function foo() { + console.log(2), console.log(1); + for(var c = 0; c < 10; c++)console.log(c); +} +export function bar() { + function x() { + b = 1; + } + for(var b = 10, c = 0; c < 10; c++)x(), console.log(b, c); +} 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 35a103da6c1..0c6503e9045 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(t,e,n){var r;!function(i,o,a,s){"use strict";var c,u=["","webkit","Moz","MS","ms","o"],l=o.createElement("div"),h=Math.round,p=Math.abs,f=Date.now;function d(t,e,n){return setTimeout(O(t,n),e)}function v(t,e,n){return!!Array.isArray(t)&&(g(t,n[e],n),!0)}function g(t,e,n){var r;if(t){if(t.forEach)t.forEach(e,n);else if(s!==t.length)for(r=0;r\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=i.console&&(i.console.warn||i.console.log);return o&&o.call(i.console,r,n),t.apply(this,arguments)}}c="function"!=typeof Object.assign?function(t){if(t===s||null===t)throw TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n-1}function T(t){return t.trim().split(/\s+/g)}function k(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var r=0;rk(i,a)&&r.push(t[o]),i[o]=a,o++}return n&&(r=e?r.sort(function(t,n){return t[e]>n[e]}):r.sort()),r}function C(t,e){for(var n,r,i=e[0].toUpperCase()+e.slice(1),o=0;o1&&!i.firstMultiple?i.firstMultiple=q(r):1===a&&(i.firstMultiple=!1),c=i.firstInput,l=(u=i.firstMultiple)?u.center:c.center,h=r.center=H(o),r.timeStamp=f(),r.deltaTime=r.timeStamp-c.timeStamp,r.angle=K(l,h),r.distance=X(l,h),d=i,g=(v=r).center,m=d.offsetDelta||{},b=d.prevDelta||{},y=d.prevInput||{},(1===v.eventType||4===y.eventType)&&(b=d.prevDelta={x:y.deltaX||0,y:y.deltaY||0},m=d.offsetDelta={x:g.x,y:g.y}),v.deltaX=b.x+(g.x-m.x),v.deltaY=b.y+(g.y-m.y),r.offsetDirection=Y(r.deltaX,r.deltaY),w=W(r.deltaTime,r.deltaX,r.deltaY),r.overallVelocityX=w.x,r.overallVelocityY=w.y,r.overallVelocity=p(w.x)>p(w.y)?w.x:w.y,r.scale=u?(O=u.pointers,X(o[0],o[1],B)/X(O[0],O[1],B)):1,r.rotation=u?(E=u.pointers,K(o[1],o[0],B)+K(E[1],E[0],B)):0,r.maxPointers=i.prevInput?r.pointers.length>i.prevInput.maxPointers?r.pointers.length:i.prevInput.maxPointers:r.pointers.length,function(t,e){var n,r,i,o,a=t.lastInterval||e,c=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(c>25||s===a.velocity)){var u=e.deltaX-a.deltaX,l=e.deltaY-a.deltaY,h=W(c,u,l);r=h.x,i=h.y,n=p(h.x)>p(h.y)?h.x:h.y,o=Y(u,l),t.lastInterval=e}else n=a.velocity,r=a.velocityX,i=a.velocityY,o=a.direction;e.velocity=n,e.velocityX=r,e.velocityY=i,e.direction=o}(i,r),_=t.element,j(r.srcEvent.target,_)&&(_=r.srcEvent.target),r.target=_,t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function q(t){for(var e=[],n=0;n=p(e)?t<0?2:4:e<0?8:16}function X(t,e,n){n||(n=V);var r=e[n[0]]-t[n[0]],i=e[n[1]]-t[n[1]];return Math.sqrt(r*r+i*i)}function K(t,e,n){n||(n=V);var r=e[n[0]]-t[n[0]];return 180*Math.atan2(e[n[1]]-t[n[1]],r)/Math.PI}Z.prototype={handler:function(){},init:function(){this.evEl&&P(this.element,this.evEl,this.domHandler),this.evTarget&&P(this.target,this.evTarget,this.domHandler),this.evWin&&P(A(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&M(this.element,this.evEl,this.domHandler),this.evTarget&&M(this.target,this.evTarget,this.domHandler),this.evWin&&M(A(this.element),this.evWin,this.domHandler)}};var G={mousedown:1,mousemove:2,mouseup:4};function $(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,Z.apply(this,arguments)}w($,Z,{handler:function(t){var e=G[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:F,srcEvent:t}))}});var J={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:z,3:"pen",4:F,5:"kinect"},tt="pointerdown",te="pointermove pointerup pointercancel";function tn(){this.evEl=tt,this.evWin=te,Z.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}i.MSPointerEvent&&!i.PointerEvent&&(tt="MSPointerDown",te="MSPointerMove MSPointerUp MSPointerCancel"),w(tn,Z,{handler:function(t){var e=this.store,n=!1,r=J[t.type.toLowerCase().replace("ms","")],i=Q[t.pointerType]||t.pointerType,o=k(e,t.pointerId,"pointerId");1&r&&(0===t.button||i==z)?o<0&&(e.push(t),o=e.length-1):12&r&&(n=!0),!(o<0)&&(e[o]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:i,srcEvent:t}),n&&e.splice(o,1))}});var tr={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ti(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Z.apply(this,arguments)}function to(t,e){var n=x(t.touches),r=x(t.changedTouches);return 12&e&&(n=D(n.concat(r),"identifier",!0)),[n,r]}w(ti,Z,{handler:function(t){var e=tr[t.type];if(1===e&&(this.started=!0),this.started){var n=to.call(this,t,e);12&e&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:z,srcEvent:t})}}});var ta={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ts(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},Z.apply(this,arguments)}function tc(t,e){var n=x(t.touches),r=this.targetIds;if(3&e&&1===n.length)return r[n[0].identifier]=!0,[n,n];var i,o,a=x(t.changedTouches),s=[],c=this.target;if(o=n.filter(function(t){return j(t.target,c)}),1===e)for(i=0;i-1&&r.splice(t,1)},2500)}}function tp(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,r=0;r-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function r(n){e.manager.emit(n,t)}n<8&&r(e.options.event+tP(n)),r(e.options.event),t.additionalEvent&&r(t.additionalEvent),n>=8&&r(e.options.event+tP(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=32},canEmit:function(){for(var t=0;te.threshold&&i&e.direction},attrTest:function(t){return tS.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=tM(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),w(tk,tS,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[tb]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),w(tx,t_,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[tg]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,r=t.distancee.time;if(this._input=t,r&&n&&(!(12&t.eventType)||i)){if(1&t.eventType)this.reset(),this._timer=d(function(){this.state=8,this.tryEmit()},e.time,this);else if(4&t.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=f(),this.manager.emit(this.options.event,this._input)))}}),w(tD,tS,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[tb]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),w(tC,tS,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return tT.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:24&n&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&p(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=tM(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),w(tR,t_,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[tm]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,r=t.distance1)for(var n=1;nt.length)&&(e=t.length);for(var n=0,r=Array(e);nn?n:t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),s=new d(4),d!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0,s[3]=0);const y=Math.log2||function(t){return Math.log(t)*Math.LOG2E};function w(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],u=e[6],l=e[7],h=e[8],p=e[9],f=e[10],d=e[11],v=e[12],g=e[13],m=e[14],b=e[15],y=n[0],w=n[1],O=n[2],E=n[3];return t[0]=y*r+w*s+O*h+E*v,t[1]=y*i+w*c+O*p+E*g,t[2]=y*o+w*u+O*f+E*m,t[3]=y*a+w*l+O*d+E*b,y=n[4],w=n[5],O=n[6],E=n[7],t[4]=y*r+w*s+O*h+E*v,t[5]=y*i+w*c+O*p+E*g,t[6]=y*o+w*u+O*f+E*m,t[7]=y*a+w*l+O*d+E*b,y=n[8],w=n[9],O=n[10],E=n[11],t[8]=y*r+w*s+O*h+E*v,t[9]=y*i+w*c+O*p+E*g,t[10]=y*o+w*u+O*f+E*m,t[11]=y*a+w*l+O*d+E*b,y=n[12],w=n[13],O=n[14],E=n[15],t[12]=y*r+w*s+O*h+E*v,t[13]=y*i+w*c+O*p+E*g,t[14]=y*o+w*u+O*f+E*m,t[15]=y*a+w*l+O*d+E*b,t}function O(t,e,n){var r,i,o,a,s,c,u,l,h,p,f,d,v=n[0],g=n[1],m=n[2];return e===t?(t[12]=e[0]*v+e[4]*g+e[8]*m+e[12],t[13]=e[1]*v+e[5]*g+e[9]*m+e[13],t[14]=e[2]*v+e[6]*g+e[10]*m+e[14],t[15]=e[3]*v+e[7]*g+e[11]*m+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],u=e[6],l=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=c,t[6]=u,t[7]=l,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=r*v+s*g+h*m+e[12],t[13]=i*v+c*g+p*m+e[13],t[14]=o*v+u*g+f*m+e[14],t[15]=a*v+l*g+d*m+e[15]),t}function E(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function _(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],u=t[7],l=t[8],h=t[9],p=t[10],f=t[11],d=t[12],v=t[13],g=t[14],m=t[15],b=e[0],y=e[1],w=e[2],O=e[3],E=e[4],_=e[5],P=e[6],M=e[7],j=e[8],S=e[9],T=e[10],k=e[11],x=e[12],D=e[13],C=e[14],R=e[15];return Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(r-y)<=1e-6*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-w)<=1e-6*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(o-O)<=1e-6*Math.max(1,Math.abs(o),Math.abs(O))&&Math.abs(a-E)<=1e-6*Math.max(1,Math.abs(a),Math.abs(E))&&Math.abs(s-_)<=1e-6*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(c-P)<=1e-6*Math.max(1,Math.abs(c),Math.abs(P))&&Math.abs(u-M)<=1e-6*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(l-j)<=1e-6*Math.max(1,Math.abs(l),Math.abs(j))&&Math.abs(h-S)<=1e-6*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(p-T)<=1e-6*Math.max(1,Math.abs(p),Math.abs(T))&&Math.abs(f-k)<=1e-6*Math.max(1,Math.abs(f),Math.abs(k))&&Math.abs(d-x)<=1e-6*Math.max(1,Math.abs(d),Math.abs(x))&&Math.abs(v-D)<=1e-6*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(g-C)<=1e-6*Math.max(1,Math.abs(g),Math.abs(C))&&Math.abs(m-R)<=1e-6*Math.max(1,Math.abs(m),Math.abs(R))}function P(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}function M(t,e,n,r){var i=e[0],o=e[1];return t[0]=i+r*(n[0]-i),t[1]=o+r*(n[1]-o),t}function j(t,e){if(!t)throw Error(e||"@math.gl/web-mercator: assertion failed.")}c=new d(2),d!=Float32Array&&(c[0]=0,c[1]=0),u=new d(3),d!=Float32Array&&(u[0]=0,u[1]=0,u[2]=0);const S=Math.PI,T=S/4,k=S/180,x=180/S;function D(t){return Math.pow(2,t)}function C([t,e]){j(Number.isFinite(t)),j(Number.isFinite(e)&&e>=-90&&e<=90,"invalid latitude");const n=512*(S+Math.log(Math.tan(T+.5*(e*k))))/(2*S);return[512*(t*k+S)/(2*S),n]}function R([t,e]){const n=2*(Math.atan(Math.exp(e/512*(2*S)-S))-T);return[(t/512*(2*S)-S)*x,n*x]}function A(t){return 2*Math.atan(.5/t)*x}function I(t){return .5/Math.tan(.5*t*k)}function L(t,e,n=0){const[r,i,o]=t;if(j(Number.isFinite(r)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(o)){const a=g(e,[r,i,o,1]);return a}const s=g(e,[r,i,0,1]),c=g(e,[r,i,1,1]),u=s[2],l=c[2];return M([],s,c,u===l?0:((n||0)-u)/(l-u))}const N=Math.PI/180;function z(t,e,n){const{pixelUnprojectionMatrix:r}=t,i=g(r,[e,0,1,1]),o=g(r,[e,t.height,1,1]),a=n*t.distanceScales.unitsPerMeter[2],s=(a-i[2])/(o[2]-i[2]),c=M([],i,o,s),u=R(c);return u[2]=n,u}class F{constructor({width:t,height:e,latitude:n=0,longitude:r=0,zoom:i=0,pitch:o=0,bearing:a=0,altitude:s=null,fovy:c=null,position:u=null,nearZMultiplier:l=.02,farZMultiplier:h=1.01}={width:1,height:1}){t=t||1,e=e||1,null===c&&null===s?c=A(s=1.5):null===c?c=A(s):null===s&&(s=I(c));const p=D(i);s=Math.max(.75,s);const f=function({latitude:t,longitude:e,highPrecision:n=!1}){j(Number.isFinite(t)&&Number.isFinite(e));const r={},i=Math.cos(t*k),o=512/360,a=o/i,s=512/4003e4/i;if(r.unitsPerMeter=[s,s,s],r.metersPerUnit=[1/s,1/s,1/s],r.unitsPerDegree=[o,a,s],r.degreesPerUnit=[1/o,1/a,1/s],n){const c=k*Math.tan(t*k)/i,u=512/4003e4*c,l=u/a*s;r.unitsPerDegree2=[0,o*c/2,u],r.unitsPerMeter2=[l,0,l]}return r}({longitude:r,latitude:n}),d=C([r,n]);if(d[2]=0,u){var g,m,b;b=d,g=[],m=f.unitsPerMeter,g[0]=u[0]*m[0],g[1]=u[1]*m[1],g[2]=u[2]*m[2],b[0]=d[0]+g[0],b[1]=d[1]+g[1],b[2]=d[2]+g[2]}this.projectionMatrix=function({width:t,height:e,pitch:n,altitude:r,fovy:i,nearZMultiplier:o,farZMultiplier:a}){var s,c,u;const{fov:l,aspect:h,near:p,far:f}=function({width:t,height:e,fovy:n=A(1.5),altitude:r,pitch:i=0,nearZMultiplier:o=1,farZMultiplier:a=1}){void 0!==r&&(n=A(r));const s=.5*n*k,c=I(n),u=i*k,l=Math.sin(s)*c/Math.sin(Math.min(Math.max(Math.PI/2-u-s,.01),Math.PI-.01)),h=Math.sin(u)*l+c;return{fov:2*s,aspect:t/e,focalDistance:c,near:o,far:h*a}}({width:t,height:e,altitude:r,fovy:i,pitch:n,nearZMultiplier:o,farZMultiplier:a}),d=(s=[],u=1/Math.tan(l/2),s[0]=u/h,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=u,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,null!=f&&f!==1/0?(c=1/(p-f),s[10]=(f+p)*c,s[14]=2*f*p*c):(s[10]=-1,s[14]=-2*p),s);return d}({width:t,height:e,pitch:o,fovy:c,nearZMultiplier:l,farZMultiplier:h}),this.viewMatrix=function({height:t,pitch:e,bearing:n,altitude:r,scale:i,center:o=null}){var a,s,c,u,l,h,p,f,d,g,m,b,y,w,_,P,M,j,S,T,x,D,C,R,A;const I=v();return O(I,I,[0,0,-r]),a=I,c=Math.sin(s=-e*k),u=Math.cos(s),l=I[4],h=I[5],p=I[6],f=I[7],d=I[8],g=I[9],m=I[10],b=I[11],I!==a&&(a[0]=I[0],a[1]=I[1],a[2]=I[2],a[3]=I[3],a[12]=I[12],a[13]=I[13],a[14]=I[14],a[15]=I[15]),a[4]=l*u+d*c,a[5]=h*u+g*c,a[6]=p*u+m*c,a[7]=f*u+b*c,a[8]=d*u-l*c,a[9]=g*u-h*c,a[10]=m*u-p*c,a[11]=b*u-f*c,y=I,_=Math.sin(w=n*k),P=Math.cos(w),M=I[0],j=I[1],S=I[2],T=I[3],x=I[4],D=I[5],C=I[6],R=I[7],I!==y&&(y[8]=I[8],y[9]=I[9],y[10]=I[10],y[11]=I[11],y[12]=I[12],y[13]=I[13],y[14]=I[14],y[15]=I[15]),y[0]=M*P+x*_,y[1]=j*P+D*_,y[2]=S*P+C*_,y[3]=T*P+R*_,y[4]=x*P-M*_,y[5]=D*P-j*_,y[6]=C*P-S*_,y[7]=R*P-T*_,E(I,I,[i/=t,i,i]),o&&O(I,I,((A=[])[0]=-o[0],A[1]=-o[1],A[2]=-o[2],A)),I}({height:e,scale:p,center:d,pitch:o,bearing:a,altitude:s}),this.width=t,this.height=e,this.scale=p,this.latitude=n,this.longitude=r,this.zoom=i,this.pitch=o,this.bearing=a,this.altitude=s,this.fovy=c,this.center=d,this.meterOffset=u||[0,0,0],this.distanceScales=f,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 t,e,n,r,i,o,a,s,c,u,l,h,p,f,d,g,m,b,y,_,P,M,j,S,T,k,x,D,C,R;const{width:A,height:I,projectionMatrix:L,viewMatrix:N}=this,z=v();w(z,z,L),w(z,z,N),this.viewProjectionMatrix=z;const F=v();E(F,F,[A/2,-I/2,1]),O(F,F,[1,-1,0]),w(F,F,z);const V=(t=v(),e=F[0],n=F[1],r=F[2],i=F[3],o=F[4],a=F[5],s=F[6],c=F[7],u=F[8],l=F[9],h=F[10],p=F[11],f=F[12],d=F[13],g=F[14],m=F[15],b=e*a-n*o,y=e*s-r*o,_=e*c-i*o,P=n*s-r*a,M=n*c-i*a,j=r*c-i*s,S=u*d-l*f,T=u*g-h*f,k=u*m-p*f,x=l*g-h*d,D=l*m-p*d,(R=b*(C=h*m-p*g)-y*D+_*x+P*k-M*T+j*S)?(R=1/R,t[0]=(a*C-s*D+c*x)*R,t[1]=(r*D-n*C-i*x)*R,t[2]=(d*j-g*M+m*P)*R,t[3]=(h*M-l*j-p*P)*R,t[4]=(s*k-o*C-c*T)*R,t[5]=(e*C-r*k+i*T)*R,t[6]=(g*_-f*j-m*y)*R,t[7]=(u*j-h*_+p*y)*R,t[8]=(o*D-a*k+c*S)*R,t[9]=(n*k-e*D-i*S)*R,t[10]=(f*M-d*_+m*b)*R,t[11]=(l*_-u*M-p*b)*R,t[12]=(a*T-o*x-s*S)*R,t[13]=(e*x-n*T+r*S)*R,t[14]=(d*y-f*P-g*b)*R,t[15]=(u*P-l*y+h*b)*R,t):null);if(!V)throw Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=F,this.pixelUnprojectionMatrix=V}equals(t){return t instanceof F&&t.width===this.width&&t.height===this.height&&_(t.projectionMatrix,this.projectionMatrix)&&_(t.viewMatrix,this.viewMatrix)}project(t,{topLeft:e=!0}={}){const n=this.projectPosition(t),r=function(t,e){const[n,r,i=0]=t;return j(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),g(e,[n,r,i,1])}(n,this.pixelProjectionMatrix),[i,o]=r,a=e?o:this.height-o;return 2===t.length?[i,a]:[i,a,r[2]]}unproject(t,{topLeft:e=!0,targetZ:n}={}){const[r,i,o]=t,a=e?i:this.height-i,s=n&&n*this.distanceScales.unitsPerMeter[2],c=L([r,a,o],this.pixelUnprojectionMatrix,s),[u,l,h]=this.unprojectPosition(c);return Number.isFinite(o)?[u,l,h]:Number.isFinite(n)?[u,l,n]:[u,l]}projectPosition(t){const[e,n]=C(t),r=(t[2]||0)*this.distanceScales.unitsPerMeter[2];return[e,n,r]}unprojectPosition(t){const[e,n]=R(t),r=(t[2]||0)*this.distanceScales.metersPerUnit[2];return[e,n,r]}projectFlat(t){return C(t)}unprojectFlat(t){return R(t)}getMapCenterByLngLatPosition({lngLat:t,pos:e}){var n;const r=L(e,this.pixelUnprojectionMatrix),i=C(t),o=P([],i,((n=[])[0]=-r[0],n[1]=-r[1],n)),a=P([],this.center,o);return R(a)}getLocationAtPoint({lngLat:t,pos:e}){return this.getMapCenterByLngLatPosition({lngLat:t,pos:e})}fitBounds(t,e={}){const{width:n,height:r}=this,{longitude:i,latitude:o,zoom:a}=function({width:t,height:e,bounds:n,minExtent:r=0,maxZoom:i=24,padding:o=0,offset:a=[0,0]}){const[[s,c],[u,l]]=n;if(Number.isFinite(o)){const h=o;o={top:h,bottom:h,left:h,right:h}}else j(Number.isFinite(o.top)&&Number.isFinite(o.bottom)&&Number.isFinite(o.left)&&Number.isFinite(o.right));const p=C([s,b(l,-85.051129,85.051129)]),f=C([u,b(c,-85.051129,85.051129)]),d=[Math.max(Math.abs(f[0]-p[0]),r),Math.max(Math.abs(f[1]-p[1]),r)],v=[t-o.left-o.right-2*Math.abs(a[0]),e-o.top-o.bottom-2*Math.abs(a[1])];j(v[0]>0&&v[1]>0);const g=v[0]/d[0],m=v[1]/d[1],w=(o.right-o.left)/2/g,O=(o.bottom-o.top)/2/m,E=[(f[0]+p[0])/2+w,(f[1]+p[1])/2+O],_=R(E),P=Math.min(i,y(Math.abs(Math.min(g,m))));return j(Number.isFinite(P)),{longitude:_[0],latitude:_[1],zoom:P}}(Object.assign({width:n,height:r,bounds:t},e));return new F({width:n,height:r,longitude:i,latitude:o,zoom:a})}getBounds(t){const e=this.getBoundingRegion(t),n=Math.min(...e.map(t=>t[0])),r=Math.max(...e.map(t=>t[0])),i=Math.min(...e.map(t=>t[1])),o=Math.max(...e.map(t=>t[1]));return[[n,i],[r,o]]}getBoundingRegion(t={}){return function(t,e=0){let n,r;const{width:i,height:o,unproject:a}=t,s={targetZ:e},c=a([0,o],s),u=a([i,o],s),l=t.fovy?.5*t.fovy*N:Math.atan(.5/t.altitude),h=(90-t.pitch)*N;return l>h-.01?(n=z(t,0,e),r=z(t,i,e)):(n=a([0,0],s),r=a([i,0],s)),[c,u,r,n]}(this,t.z||0)}}const V=["longitude","latitude","zoom"],B={curve:1.414,speed:1.2};function Z(t,e,n){var r;n=Object.assign({},B,n);const i=n.curve,o=t.zoom,a=[t.longitude,t.latitude],s=D(o),c=e.zoom,u=[e.longitude,e.latitude],l=D(c-o),h=C(a),p=C(u),f=((r=[])[0]=p[0]-h[0],r[1]=p[1]-h[1],r),d=Math.max(t.width,t.height),v=d/l,g=Math.hypot(f[0],f[1])*s,m=Math.max(g,.01),b=i*i,y=(v*v-d*d+b*b*m*m)/(2*d*b*m),w=(v*v-d*d-b*b*m*m)/(2*v*b*m),O=Math.log(Math.sqrt(y*y+1)-y),E=Math.log(Math.sqrt(w*w+1)-w);return{startZoom:o,startCenterXY:h,uDelta:f,w0:d,u1:g,S:(E-O)/i,rho:i,rho2:b,r0:O,r1:E}}var U=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var n=-1;return t.some(function(t,r){return t[0]===e&&(n=r,!0)}),n}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var n=t(this.__entries__,e),r=this.__entries__[n];return r&&r[1]},e.prototype.set=function(e,n){var r=t(this.__entries__,e);~r?this.__entries__[r][1]=n:this.__entries__.push([e,n])},e.prototype.delete=function(e){var n=this.__entries__,r=t(n,e);~r&&n.splice(r,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var n=0,r=this.__entries__;n0},t.prototype.connect_=function(){q&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),X?(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)},t.prototype.disconnect_=function(){q&&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)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;Y.some(function(t){return!!~n.indexOf(t)})&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),G=function(t,e){for(var n=0,r=Object.keys(e);n0},t}(),ta="undefined"!=typeof WeakMap?new WeakMap:new U,ts=function t(e){if(!(this instanceof t))throw TypeError("Cannot call a class as a function.");if(!arguments.length)throw TypeError("1 argument required, but only 0 present.");var n=K.getInstance(),r=new to(e,n,this);ta.set(this,r)};["observe","unobserve","disconnect"].forEach(function(t){ts.prototype[t]=function(){var e;return(e=ta.get(this))[t].apply(e,arguments)}});var tc=void 0!==H.ResizeObserver?H.ResizeObserver:ts;function tu(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}function tl(t,e){for(var n=0;n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function tg(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n1&&void 0!==arguments[1]?arguments[1]:"component";t.debug&&p.checkPropTypes(tw,t,"prop",e)}var t_=function(){function t(e){var n=this;if(tu(this,t),a(this,"props",tO),a(this,"width",0),a(this,"height",0),a(this,"_fireLoadEvent",function(){n.props.onLoad({type:"load",target:n._map})}),a(this,"_handleError",function(t){n.props.onError(t)}),!e.mapboxgl)throw Error("Mapbox not available");this.mapboxgl=e.mapboxgl,t.initialized||(t.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(e)}return th(t,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(t){return this._update(this.props,t),this}},{key:"redraw",value:function(){var t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(e){this._map=t.savedMap;var n=this._map.getContainer(),r=e.container;for(r.classList.add("mapboxgl-map");n.childNodes.length>0;)r.appendChild(n.childNodes[0]);this._map._container=r,t.savedMap=null,e.mapStyle&&this._map.setStyle(tb(e.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(e){if(e.reuseMaps&&t.savedMap)this._reuse(e);else{if(e.gl){var n=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=n,e.gl}}var r={container:e.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:tb(e.mapStyle),interactive:!1,trackResize:!1,attributionControl:e.attributionControl,preserveDrawingBuffer:e.preserveDrawingBuffer};e.transformRequest&&(r.transformRequest=e.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},r,e.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!t.savedMap?(t.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(t){var e=this;t=Object.assign({},tO,t),tE(t,"Mapbox"),this.mapboxgl.accessToken=t.mapboxApiAccessToken||tO.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=t.mapboxApiUrl,this._create(t);var n=t.container;Object.defineProperty(n,"offsetWidth",{configurable:!0,get:function(){return e.width}}),Object.defineProperty(n,"clientWidth",{configurable:!0,get:function(){return e.width}}),Object.defineProperty(n,"offsetHeight",{configurable:!0,get:function(){return e.height}}),Object.defineProperty(n,"clientHeight",{configurable:!0,get:function(){return e.height}});var r=this._map.getCanvas();r&&(r.style.outline="none"),this._updateMapViewport({},t),this._updateMapSize({},t),this.props=t}},{key:"_update",value:function(t,e){if(this._map){tE(e=Object.assign({},this.props,e),"Mapbox");var n=this._updateMapViewport(t,e),r=this._updateMapSize(t,e);this._updateMapStyle(t,e),!e.asyncRender&&(n||r)&&this.redraw(),this.props=e}}},{key:"_updateMapStyle",value:function(t,e){t.mapStyle!==e.mapStyle&&this._map.setStyle(tb(e.mapStyle),{diff:!e.preventStyleDiffing})}},{key:"_updateMapSize",value:function(t,e){var n=t.width!==e.width||t.height!==e.height;return n&&(this.width=e.width,this.height=e.height,this._map.resize()),n}},{key:"_updateMapViewport",value:function(t,e){var n=this._getViewState(t),r=this._getViewState(e),i=r.latitude!==n.latitude||r.longitude!==n.longitude||r.zoom!==n.zoom||r.pitch!==n.pitch||r.bearing!==n.bearing||r.altitude!==n.altitude;return i&&(this._map.jumpTo(this._viewStateToMapboxProps(r)),r.altitude!==n.altitude&&(this._map.transform.altitude=r.altitude)),i}},{key:"_getViewState",value:function(t){var e=t.viewState||t,n=e.longitude,r=e.latitude,i=e.zoom,o=e.pitch,a=e.bearing,s=e.altitude;return{longitude:n,latitude:r,zoom:i,pitch:void 0===o?0:o,bearing:void 0===a?0:a,altitude:void 0===s?1.5:s}}},{key:"_checkStyleSheet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==tp)try{var e=tp.createElement("div");if(e.className="mapboxgl-map",e.style.display="none",tp.body.appendChild(e),!("static"!==window.getComputedStyle(e).position)){var n=tp.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(t,"/mapbox-gl.css")),tp.head.appendChild(n)}}catch(r){}}},{key:"_viewStateToMapboxProps",value:function(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}}}]),t}();a(t_,"initialized",!1),a(t_,"propTypes",tw),a(t_,"defaultProps",tO),a(t_,"savedMap",null);var tP=n(6158),tM=n.n(tP);function tj(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function tS(t,e,n){return Math.max(e,Math.min(n,t))}function tT(t,e,n){return tj(t)?t.map(function(t,r){return tT(t,e[r],n)}):n*e+(1-n)*t}function tk(t,e){if(!t)throw Error(e||"react-map-gl: assertion failed.")}function tx(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function tD(t){for(var e=1;e0,"`scale` must be a positive number");var i=this._state,o=i.startZoom,a=i.startZoomLngLat;Number.isFinite(o)||(o=this._viewportProps.zoom,a=this._unproject(n)||this._unproject(e)),tk(a,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var s=this._calculateNewZoom({scale:r,startZoom:o||0}),c=new F(Object.assign({},this._viewportProps,{zoom:s})).getMapCenterByLngLatPosition({lngLat:a,pos:e}),u=f(c,2),l=u[0],h=u[1];return this._getUpdatedMapState({zoom:s,longitude:l,latitude:h})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(e){return new t(Object.assign({},this._viewportProps,this._state,e))}},{key:"_applyConstraints",value:function(t){var e=t.maxZoom,n=t.minZoom,r=t.zoom;t.zoom=tS(r,n,e);var i=t.maxPitch,o=t.minPitch,a=t.pitch;return t.pitch=tS(a,o,i),Object.assign(t,function({width:t,height:e,longitude:n,latitude:r,zoom:i,pitch:o=0,bearing:a=0}){(n<-180||n>180)&&(n=m(n+180,360)-180),(a<-180||a>180)&&(a=m(a+180,360)-180);const s=y(e/512);if(i<=s)i=s,r=0;else{const c=e/2/Math.pow(2,i),u=R([0,c])[1];if(rl&&(r=l)}}return{width:t,height:e,longitude:n,latitude:r,zoom:i,pitch:o,bearing:a}}(t)),t}},{key:"_unproject",value:function(t){var e=new F(this._viewportProps);return t&&e.unproject(t)}},{key:"_calculateNewLngLat",value:function(t){var e=t.startPanLngLat,n=t.pos;return new F(this._viewportProps).getMapCenterByLngLatPosition({lngLat:e,pos:n})}},{key:"_calculateNewZoom",value:function(t){var e=t.scale,n=t.startZoom,r=this._viewportProps,i=r.maxZoom;return tS(n+Math.log2(e),r.minZoom,i)}},{key:"_calculateNewPitchAndBearing",value:function(t){var e=t.deltaScaleX,n=t.deltaScaleY,r=t.startBearing,i=t.startPitch;n=tS(n,-1,1);var o=this._viewportProps,a=o.minPitch,s=o.maxPitch,c=i;return n>0?c=i+n*(s-i):n<0&&(c=i-n*(a-i)),{pitch:c,bearing:r+180*e}}},{key:"_getRotationParams",value:function(t,e){var n=t[0]-e[0],r=t[1]-e[1],i=t[1],o=e[1],a=this._viewportProps,s=a.width,c=a.height,u=0;return r>0?Math.abs(c-o)>5&&(u=r/(o-c)*1.2):r<0&&o>5&&(u=1-i/o),{deltaScaleX:n/s,deltaScaleY:u=Math.min(1,Math.max(-1,u))}}}]),t}();function tI(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function tL(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},n=c.current&&c.current.getMap();return n&&n.queryRenderedFeatures(t,e)}}},[]);var g=(0,h.useCallback)(function(t){var e=t.target;e===p.current&&e.scrollTo(0,0)},[]),m=v&&h.createElement(tz,{value:tZ(tZ({},d),{},{viewport:d.viewport||tq(tZ({map:v,props:t},a)),map:v,container:d.container||l.current})},h.createElement("div",{key:"map-overlays",className:"overlays",ref:p,style:tH,onScroll:g},t.children)),b=t.className,y=t.width,w=t.height,O=t.style,E=t.visibilityConstraints,_=Object.assign({position:"relative"},O,{width:y,height:w}),P=t.visible&&function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tC;for(var n in e){var r,i=n.slice(0,3),o=(r=n.slice(3))[0].toLowerCase()+r.slice(1);if("min"===i&&t[o]e[n])return!1}return!0}(t.viewState||t,E),M=Object.assign({},tH,{visibility:P?"inherit":"hidden"});return h.createElement("div",{key:"map-container",ref:l,style:_},h.createElement("div",{key:"map-mapbox",ref:u,style:M,className:b}),m,!r&&!t.disableTokenWarning&&h.createElement(tX,null))});function tG(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}(this.propNames||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(!function t(e,n){if(e===n)return!0;if(tj(e)&&tj(n)){if(e.length!==n.length)return!1;for(var r=0;r=Math.abs(e-n)}(t[i],e[i]))return!1}}catch(o){r.e(o)}finally{r.f()}return!0}},{key:"initializeProps",value:function(t,e){return{start:t,end:e}}},{key:"interpolateProps",value:function(t,e,n){tk(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(t,e){return e.transitionDuration}}]),t}();function tJ(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function tQ(t,e){return(tQ=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function t0(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&tQ(t,e)}function t1(t){return(t1="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function t2(t,e){if(e&&("object"===t1(e)||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return tJ(t)}function t4(t){return(t4=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var t3={longitude:1,bearing:1};function t5(t){return Number.isFinite(t)||Array.isArray(t)}function t8(t,e,n){return t in t3&&Math.abs(n-e)>180&&(n=n<0?n+360:n-360),n}function t6(t,e){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return t7(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t7(t,e)}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function t7(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function ei(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:{};return tu(this,r),a(tJ(t=n.call(this)),"propNames",t9),t.props=Object.assign({},en,e),t}th(r,[{key:"initializeProps",value:function(t,e){var n,r={},i={},o=t6(et);try{for(o.s();!(n=o.n()).done;){var a=n.value,s=t[a],c=e[a];tk(t5(s)&&t5(c),"".concat(a," must be supplied for transition")),r[a]=s,i[a]=t8(a,s,c)}}catch(u){o.e(u)}finally{o.f()}var l,h=t6(ee);try{for(h.s();!(l=h.n()).done;){var p=l.value,f=t[p]||0,d=e[p]||0;r[p]=f,i[p]=t8(p,f,d)}}catch(v){h.e(v)}finally{h.f()}return{start:r,end:i}}},{key:"interpolateProps",value:function(t,e,n){var r,i=function(t,e,n,r={}){var i,o,a,s;const c={},{startZoom:u,startCenterXY:l,uDelta:h,w0:p,u1:f,S:d,rho:v,rho2:g,r0:m}=Z(t,e,r);if(f<.01){for(const b of V){const w=t[b],O=e[b];c[b]=(i=w,o=O,(a=n)*o+(1-a)*i)}return c}const E=n*d,_=Math.cosh(m)/Math.cosh(m+v*E),M=p*((Math.cosh(m)*Math.tanh(m+v*E)-Math.sinh(m))/g)/f,j=u+y(1/_),S=((s=[])[0]=h[0]*M,s[1]=h[1]*M,s);P(S,S,l);const T=R(S);return c.longitude=T[0],c.latitude=T[1],c.zoom=j,c}(t,e,n,this.props),o=t6(ee);try{for(o.s();!(r=o.n()).done;){var a=r.value;i[a]=tT(t[a],e[a],n)}}catch(s){o.e(s)}finally{o.f()}return i}},{key:"getDuration",value:function(t,e){var n=e.transitionDuration;return"auto"===n&&(n=function(t,e,n={}){let r;n=Object.assign({},B,n);const{screenSpeed:i,speed:o,maxDuration:a}=n,{S:s,rho:c}=Z(t,e,n),u=1e3*s;return r=Number.isFinite(i)?u/(i/c):u/o,Number.isFinite(a)&&r>a?0:r}(t,e,this.props)),n}}])}(t$);var eo=["longitude","latitude","zoom","bearing","pitch"],ea=function(t){t0(r,t);var e,n=(e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,n=t4(r);if(e){var i=t4(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return t2(this,t)});function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return tu(this,r),t=n.call(this),Array.isArray(e)&&(e={transitionProps:e}),t.propNames=e.transitionProps||eo,e.around&&(t.around=e.around),t}return th(r,[{key:"initializeProps",value:function(t,e){var n={},r={};if(this.around){n.around=this.around;var i=new F(t).unproject(this.around);Object.assign(r,e,{around:new F(e).project(i),aroundLngLat:i})}var o,a=er(this.propNames);try{for(a.s();!(o=a.n()).done;){var s=o.value,c=t[s],u=e[s];tk(t5(c)&&t5(u),"".concat(s," must be supplied for transition")),n[s]=c,r[s]=t8(s,c,u)}}catch(l){a.e(l)}finally{a.f()}return{start:n,end:r}}},{key:"interpolateProps",value:function(t,e,n){var r,i={},o=er(this.propNames);try{for(o.s();!(r=o.n()).done;){var a=r.value;i[a]=tT(t[a],e[a],n)}}catch(s){o.e(s)}finally{o.f()}if(e.around){var c=new F(Object.assign({},e,i)).getMapCenterByLngLatPosition({lngLat:e.aroundLngLat,pos:tT(t.around,e.around,n)}),u=f(c,2),l=u[0],h=u[1];i.longitude=l,i.latitude=h}return i}}]),r}(t$),es=function(){},ec={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},eu={transitionDuration:0,transitionEasing:function(t){return t},transitionInterpolator:new ea,transitionInterruption:ec.BREAK,onTransitionStart:es,onTransitionInterrupt:es,onTransitionEnd:es},el=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};tu(this,t),a(this,"_animationFrame",null),a(this,"_onTransitionFrame",function(){e._animationFrame=requestAnimationFrame(e._onTransitionFrame),e._updateViewport()}),this.props=null,this.onViewportChange=n.onViewportChange||es,this.onStateChange=n.onStateChange||es,this.time=n.getTime||Date.now}return th(t,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(t){var e=this.props;if(this.props=t,!e||this._shouldIgnoreViewportChange(e,t))return!1;if(this._isTransitionEnabled(t)){var n=Object.assign({},e),r=Object.assign({},t);if(this._isTransitionInProgress()&&(e.onTransitionInterrupt(),this.state.interruption===ec.SNAP_TO_END?Object.assign(n,this.state.endProps):Object.assign(n,this.state.propsInTransition),this.state.interruption===ec.UPDATE)){var i,o,a=this.time(),s=(a-this.state.startTime)/this.state.duration;r.transitionDuration=this.state.duration-(a-this.state.startTime),r.transitionEasing=(o=(i=this.state.easing)(s),function(t){return 1/(1-o)*(i(t*(1-s)+s)-o)}),r.transitionInterpolator=n.transitionInterpolator}return r.onTransitionStart(),this._triggerTransition(n,r),!0}return this._isTransitionInProgress()&&(e.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(t){var e=t.transitionDuration,n=t.transitionInterpolator;return(e>0||"auto"===e)&&Boolean(n)}},{key:"_isUpdateDueToCurrentTransition",value:function(t){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(t,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(t,e){return!t||(this._isTransitionInProgress()?this.state.interruption===ec.IGNORE||this._isUpdateDueToCurrentTransition(e):!this._isTransitionEnabled(e)||e.transitionInterpolator.arePropsEqual(t,e))}},{key:"_triggerTransition",value:function(t,e){tk(this._isTransitionEnabled(e)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var n=e.transitionInterpolator,r=n.getDuration?n.getDuration(t,e):e.transitionDuration;if(0!==r){var i=e.transitionInterpolator.initializeProps(t,e),o={inTransition:!0,isZooming:t.zoom!==e.zoom,isPanning:t.longitude!==e.longitude||t.latitude!==e.latitude,isRotating:t.bearing!==e.bearing||t.pitch!==e.pitch};this.state={duration:r,easing:e.transitionEasing,interpolator:e.transitionInterpolator,interruption:e.transitionInterruption,startTime:this.time(),startProps:i.start,endProps:i.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(o)}}},{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 t=this.time(),e=this.state,n=e.startTime,r=e.duration,i=e.easing,o=e.interpolator,a=e.startProps,s=e.endProps,c=!1,u=(t-n)/r;u>=1&&(u=1,c=!0),u=i(u);var l=o.interpolateProps(a,s,u),h=new tA(Object.assign({},this.props,l));this.state.propsInTransition=h.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),t}();a(el,"defaultProps",eu);var eh=n(840),ep=n.n(eh);const ef={mousedown:1,mousemove:2,mouseup:4};!function(t){const e=t.prototype.handler;t.prototype.handler=function(t){const n=this.store;t.button>0&&"pointerdown"===t.type&&!function(t,e){for(let n=0;ne.pointerId===t.pointerId)&&n.push(t),e.call(this,t)}}(ep().PointerEventInput),ep().MouseInput.prototype.handler=function(t){let e=ef[t.type];1&e&&t.button>=0&&(this.pressed=!0),2&e&&0===t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:"mouse",srcEvent:t}))};const ed=ep().Manager;var ev=ep();const eg=ev?[[ev.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[ev.Rotate,{enable:!1}],[ev.Pinch,{enable:!1}],[ev.Swipe,{enable:!1}],[ev.Pan,{threshold:0,enable:!1}],[ev.Press,{enable:!1}],[ev.Tap,{event:"doubletap",taps:2,enable:!1}],[ev.Tap,{event:"anytap",enable:!1}],[ev.Tap,{enable:!1}]]:null,em={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},eb={doubletap:["tap"]},ey={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},ew={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},eO={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"},eE={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},e_="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",eP="undefined"!=typeof window?window:n.g;void 0!==n.g?n.g:window;let eM=!1;try{const ej={get passive(){return eM=!0,!0}};eP.addEventListener("test",ej,ej),eP.removeEventListener("test",ej,ej)}catch(eS){}const eT=-1!==e_.indexOf("firefox"),{WHEEL_EVENTS:ek}=ew,ex="wheel";class eD{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.events=ek.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(e=>t.addEventListener(e,this.handleEvent,!!eM&&{passive:!1}))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===ex&&(this.options.enable=e)}handleEvent(t){if(!this.options.enable)return;let e=t.deltaY;eP.WheelEvent&&(eT&&t.deltaMode===eP.WheelEvent.DOM_DELTA_PIXEL&&(e/=eP.devicePixelRatio),t.deltaMode===eP.WheelEvent.DOM_DELTA_LINE&&(e*=40));const n={x:t.clientX,y:t.clientY};0!==e&&e%4.000244140625==0&&(e=Math.floor(e/4.000244140625)),t.shiftKey&&e&&(e*=.25),this._onWheel(t,-e,n)}_onWheel(t,e,n){this.callback({type:ex,center:n,delta:e,srcEvent:t,pointerType:"mouse",target:t.target})}}const{MOUSE_EVENTS:eC}=ew,eR="pointermove",eA="pointerover",eI="pointerout",eL="pointerleave";class eN{constructor(t,e,n={}){this.element=t,this.callback=e,this.pressed=!1,this.options=Object.assign({enable:!0},n),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=eC.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===eR&&(this.enableMoveEvent=e),t===eA&&(this.enableOverEvent=e),t===eI&&(this.enableOutEvent=e),t===eL&&(this.enableLeaveEvent=e)}handleEvent(t){this.handleOverEvent(t),this.handleOutEvent(t),this.handleLeaveEvent(t),this.handleMoveEvent(t)}handleOverEvent(t){this.enableOverEvent&&"mouseover"===t.type&&this.callback({type:eA,srcEvent:t,pointerType:"mouse",target:t.target})}handleOutEvent(t){this.enableOutEvent&&"mouseout"===t.type&&this.callback({type:eI,srcEvent:t,pointerType:"mouse",target:t.target})}handleLeaveEvent(t){this.enableLeaveEvent&&"mouseleave"===t.type&&this.callback({type:eL,srcEvent:t,pointerType:"mouse",target:t.target})}handleMoveEvent(t){if(this.enableMoveEvent)switch(t.type){case"mousedown":t.button>=0&&(this.pressed=!0);break;case"mousemove":0===t.which&&(this.pressed=!1),this.pressed||this.callback({type:eR,srcEvent:t,pointerType:"mouse",target:t.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:ez}=ew,eF="keydown",eV="keyup";class eB{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=ez.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),t.tabIndex=n.tabIndex||0,t.style.outline="none",this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===eF&&(this.enableDownEvent=e),t===eV&&(this.enableUpEvent=e)}handleEvent(t){const e=t.target||t.srcElement;("INPUT"!==e.tagName||"text"!==e.type)&&"TEXTAREA"!==e.tagName&&(this.enableDownEvent&&"keydown"===t.type&&this.callback({type:eF,srcEvent:t,key:t.key,target:t.target}),this.enableUpEvent&&"keyup"===t.type&&this.callback({type:eV,srcEvent:t,key:t.key,target:t.target}))}}const eZ="contextmenu";class eU{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.handleEvent=this.handleEvent.bind(this),t.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(t,e){t===eZ&&(this.options.enable=e)}handleEvent(t){this.options.enable&&this.callback({type:eZ,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}}const eq={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},eH={srcElement:"root",priority:0};class eW{constructor(t){this.eventManager=t,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(t,e,n,r=!1,i=!1){const{handlers:o,handlersByElement:a}=this;n&&("object"!=typeof n||n.addEventListener)&&(n={srcElement:n}),n=n?Object.assign({},eH,n):eH;let s=a.get(n.srcElement);s||(s=[],a.set(n.srcElement,s));const c={type:t,handler:e,srcElement:n.srcElement,priority:n.priority};r&&(c.once=!0),i&&(c.passive=!0),o.push(c),this._active=this._active||!c.passive;let u=s.length-1;for(;u>=0&&!(s[u].priority>=c.priority);)u--;s.splice(u+1,0,c)}remove(t,e){const{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){const o=n[i];if(o.type===t&&o.handler===e){n.splice(i,1);const a=r.get(o.srcElement);a.splice(a.indexOf(o),1),0===a.length&&r.delete(o.srcElement)}}this._active=n.some(t=>!t.passive)}handleEvent(t){if(this.isEmpty())return;const e=this._normalizeEvent(t);let n=t.srcEvent.target;for(;n&&n!==e.rootElement;){if(this._emit(e,n),e.handled)return;n=n.parentNode}this._emit(e,"root")}_emit(t,e){const n=this.handlersByElement.get(e);if(n){let r=!1;const i=()=>{t.handled=!0},o=()=>{t.handled=!0,r=!0},a=[];for(let s=0;s{const e=this.manager.get(t);e&&em[t].forEach(t=>{e.recognizeWith(t)})}),e.recognizerOptions){const i=this.manager.get(r);if(i){const o=e.recognizerOptions[r];delete o.enable,i.set(o)}}for(const[a,s]of(this.wheelInput=new eD(t,this._onOtherEvent,{enable:!1}),this.moveInput=new eN(t,this._onOtherEvent,{enable:!1}),this.keyInput=new eB(t,this._onOtherEvent,{enable:!1,tabIndex:e.tabIndex}),this.contextmenuInput=new eU(t,this._onOtherEvent,{enable:!1}),this.events))s.isEmpty()||(this._toggleRecognizer(s.recognizerName,!0),this.manager.on(a,s.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(t,e,n){this._addEventHandler(t,e,n,!1)}once(t,e,n){this._addEventHandler(t,e,n,!0)}watch(t,e,n){this._addEventHandler(t,e,n,!1,!0)}off(t,e){this._removeEventHandler(t,e)}_toggleRecognizer(t,e){const{manager:n}=this;if(!n)return;const r=n.get(t);if(r&&r.options.enable!==e){r.set({enable:e});const i=eb[t];i&&!this.options.recognizers&&i.forEach(i=>{const o=n.get(i);e?(o.requireFailure(t),r.dropRequireFailure(i)):o.dropRequireFailure(t)})}this.wheelInput.enableEventType(t,e),this.moveInput.enableEventType(t,e),this.keyInput.enableEventType(t,e),this.contextmenuInput.enableEventType(t,e)}_addEventHandler(t,e,n,r,i){if("string"!=typeof t){for(const o in n=e,t)this._addEventHandler(o,t[o],n,r,i);return}const{manager:a,events:s}=this,c=eE[t]||t;let u=s.get(c);!u&&(u=new eW(this),s.set(c,u),u.recognizerName=eO[c]||c,a&&a.on(c,u.handleEvent)),u.add(t,e,n,r,i),u.isEmpty()||this._toggleRecognizer(u.recognizerName,!0)}_removeEventHandler(t,e){if("string"!=typeof t){for(const n in t)this._removeEventHandler(n,t[n]);return}const{events:r}=this,i=eE[t]||t,o=r.get(i);if(o&&(o.remove(t,e),o.isEmpty())){const{recognizerName:a}=o;let s=!1;for(const c of r.values())if(c.recognizerName===a&&!c.isEmpty()){s=!0;break}s||this._toggleRecognizer(a,!1)}}_onBasicInput(t){const{srcEvent:e}=t,n=ey[e.type];n&&this.manager.emit(n,t)}_onOtherEvent(t){this.manager.emit(t.type,t)}}function eK(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function eG(t){for(var e=1;e0),a=o&&!this.state.isHovering,s=!o&&this.state.isHovering;(r||a)&&(t.features=e,r&&r(t)),a&&e9.call(this,"onMouseEnter",t),s&&e9.call(this,"onMouseLeave",t),(a||s)&&this.setState({isHovering:o})}}function nr(t){var e=this.props,n=e.onClick,r=e.onNativeClick,i=e.onDblClick,o=e.doubleClickZoom,a=[],s=i||o;switch(t.type){case"anyclick":a.push(r),s||a.push(n);break;case"click":s&&a.push(n)}(a=a.filter(Boolean)).length&&((t=e6.call(this,t)).features=e7.call(this,t.point),a.forEach(function(e){return e(t)}))}var ni=(0,h.forwardRef)(function(t,e){var n,a,s=(0,h.useContext)(tN),c=(0,h.useMemo)(function(){return t.controller||new e1},[]),u=(0,h.useMemo)(function(){return new eX(null,{touchAction:t.touchAction,recognizerOptions:t.eventRecognizerOptions})},[]),l=(0,h.useRef)(null),p=(0,h.useRef)(null),f=(0,h.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;f.props=t,f.map=p.current&&p.current.getMap(),f.setState=function(e){f.state=e4(e4({},f.state),e),l.current.style.cursor=t.getCursor(f.state)};var d=!0,v=function(t,e,r){if(d){n=[t,e,r];return}var i=f.props,o=i.onViewStateChange,a=i.onViewportChange;Object.defineProperty(t,"position",{get:function(){return[0,0,tV(f.map,t)]}}),o&&o({viewState:t,interactionState:e,oldViewState:r}),a&&a(t,e,r)};(0,h.useImperativeHandle)(e,function(){return{getMap:p.current&&p.current.getMap,queryRenderedFeatures:p.current&&p.current.queryRenderedFeatures}},[]);var g=(0,h.useMemo)(function(){return e4(e4({},s),{},{eventManager:u,container:s.container||l.current})},[s,l.current]);g.onViewportChange=v,g.viewport=s.viewport||tq(f),f.viewport=g.viewport;var m=function(t){var e=t.isDragging,n=void 0!==e&&e;if(n!==f.state.isDragging&&f.setState({isDragging:n}),d){a=t;return}var r=f.props.onInteractionStateChange;r&&r(t)},b=function(){f.width&&f.height&&c.setOptions(e4(e4(e4({},f.props),f.props.viewState),{},{isInteractive:Boolean(f.props.onViewStateChange||f.props.onViewportChange),onViewportChange:v,onStateChange:m,eventManager:u,width:f.width,height:f.height}))},y=function(t){var e=t.width,n=t.height;f.width=e,f.height=n,b(),f.props.onResize({width:e,height:n})};(0,h.useEffect)(function(){return u.setElement(l.current),u.on({pointerdown:nt.bind(f),pointermove:nn.bind(f),pointerup:ne.bind(f),pointerleave:e9.bind(f,"onMouseOut"),click:nr.bind(f),anyclick:nr.bind(f),dblclick:e9.bind(f,"onDblClick"),wheel:e9.bind(f,"onWheel"),contextmenu:e9.bind(f,"onContextMenu")}),function(){u.destroy()}},[]),tF(function(){if(n){var t;v.apply(void 0,function(t){if(Array.isArray(t))return i(t)}(t=n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}a&&m(a)}),b();var w=t.width,O=t.height,E=t.style,_=t.getCursor,P=(0,h.useMemo)(function(){return e4(e4({position:"relative"},E),{},{width:w,height:O,cursor:_(f.state)})},[E,w,O,_,f.state]);return n&&f._child||(f._child=h.createElement(tz,{value:g},h.createElement("div",{key:"event-canvas",ref:l,style:P},h.createElement(tK,r({},t,{width:"100%",height:"100%",style:null,onResize:y,ref:p}))))),d=!1,f._child});ni.supported=tK.supported,ni.propTypes=e3,ni.defaultProps=e8;var no=ni;p.string.isRequired,p.string,p.oneOf(["fill","line","symbol","circle","fill-extrusion","raster","background","heatmap","hillshade","sky"]).isRequired,p.string,p.string,p.string;var na={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},ns={captureScroll:p.bool,captureDrag:p.bool,captureClick:p.bool,captureDoubleClick:p.bool,capturePointerMove:p.bool};function nc(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=(0,h.useContext)(tN),n=(0,h.useRef)(null),r=(0,h.useRef)({props:t,state:{},context:e,containerRef:n}).current;return r.props=t,r.context=e,(0,h.useEffect)(function(){return function(t){var e=t.containerRef.current,n=t.context.eventManager;if(e&&n){var r={wheel:function(e){var n=t.props;n.captureScroll&&e.stopPropagation(),n.onScroll&&n.onScroll(e,t)},panstart:function(e){var n=t.props;n.captureDrag&&e.stopPropagation(),n.onDragStart&&n.onDragStart(e,t)},anyclick:function(e){var n=t.props;n.captureClick&&e.stopPropagation(),n.onNativeClick&&n.onNativeClick(e,t)},click:function(e){var n=t.props;n.captureClick&&e.stopPropagation(),n.onClick&&n.onClick(e,t)},dblclick:function(e){var n=t.props;n.captureDoubleClick&&e.stopPropagation(),n.onDoubleClick&&n.onDoubleClick(e,t)},pointermove:function(e){var n=t.props;n.capturePointerMove&&e.stopPropagation(),n.onPointerMove&&n.onPointerMove(e,t)}};return n.watch(r,e),function(){n.off(r)}}}(r)},[e.eventManager]),r}function nu(t){var e=t.instance,n=nc(t),r=n.context,i=n.containerRef;return e._context=r,e._containerRef=i,e._render()}var nl=function(t){t0(i,t);var e,n=(e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,n=t4(i);if(e){var r=t4(this).constructor;t=Reflect.construct(n,arguments,r)}else t=n.apply(this,arguments);return t2(this,t)});function i(){var t;tu(this,i);for(var e=arguments.length,r=Array(e),o=0;o2&&void 0!==arguments[2]?arguments[2]:"x";if(null===t)return e;var r="x"===n?t.offsetWidth:t.offsetHeight;return ny(e/100*r)/r*100};function nO(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}var nE=Object.assign({},nf,{className:p.string,longitude:p.number.isRequired,latitude:p.number.isRequired,style:p.object}),n_=Object.assign({},nd,{className:""});function nP(t){var e,n,r,i,o,s,c,u=(n=(e=f((0,h.useState)(null),2))[0],r=e[1],o=(i=f((0,h.useState)(null),2))[0],s=i[1],(c=nc(np(np({},t),{},{onDragStart:nm}))).callbacks=t,c.state.dragPos=n,c.state.setDragPos=r,c.state.dragOffset=o,c.state.setDragOffset=s,(0,h.useEffect)(function(){return function(t){var e=t.context.eventManager;if(e&&t.state.dragPos){var n={panmove:function(e){return function(t,e){var n=e.props,r=e.callbacks,i=e.state,o=e.context;t.stopPropagation();var a=nv(t);i.setDragPos(a);var s=i.dragOffset;if(r.onDrag&&s){var c=Object.assign({},t);c.lngLat=ng(a,s,n,o),r.onDrag(c)}}(e,t)},panend:function(e){return function(t,e){var n=e.props,r=e.callbacks,i=e.state,o=e.context;t.stopPropagation();var a=i.dragPos,s=i.dragOffset;if(i.setDragPos(null),i.setDragOffset(null),r.onDragEnd&&a&&s){var c=Object.assign({},t);c.lngLat=ng(a,s,n,o),r.onDragEnd(c)}}(e,t)},pancancel:function(e){var n;return n=t.state,void(e.stopPropagation(),n.setDragPos(null),n.setDragOffset(null))}};return e.watch(n),function(){e.off(n)}}}(c)},[c.context.eventManager,Boolean(n)]),c),l=u.state,p=u.containerRef,d=t.children,v=t.className,g=t.draggable,m=t.style,b=l.dragPos,y=function(t){var e=t.props,n=t.state,r=t.context,i=e.longitude,o=e.latitude,a=e.offsetLeft,s=e.offsetTop,c=n.dragPos,u=n.dragOffset,l=r.viewport,h=r.map;if(c&&u)return[c[0]+u[0],c[1]+u[1]];var p=tV(h,{longitude:i,latitude:o}),d=l.project([i,o,p]),v=f(d,2),g=v[0],m=v[1];return[g+=a,m+=s]}(u),w=f(y,2),O=w[0],E=w[1],_="translate(".concat(ny(O),"px, ").concat(ny(E),"px)"),P=g?b?"grabbing":"grab":"auto",M=(0,h.useMemo)(function(){var t=function(t){for(var e=1;e0){var g=p,m=v;for(p=0;p<=1;p+=.5)d=(f=n-p*a)+a,(v=Math.max(0,u-f)+Math.max(0,d-i+u))0){var E=h,_=O;for(h=0;h<=1;h+=b)w=(y=e-h*o)+o,(O=Math.max(0,u-y)+Math.max(0,w-r+u))<_&&(_=O,E=h);h=E}return nj.find(function(t){var e=nM[t];return e.x===h&&e.y===p})||s}({x:r,y:i,anchor:o,padding:s,width:S.width,height:S.height,selfWidth:e.clientWidth,selfHeight:e.clientHeight}):o),z=(c=M.current,l=(u=f(L,3))[0],p=u[1],d=u[2],v=t.offsetLeft,g=t.offsetTop,m=t.sortByDepth,y=nw(c,-(100*(b=nM[N]).x)),w=nw(c,-(100*b.y),"y"),O={position:"absolute",transform:"\n translate(".concat(y,"%, ").concat(w,"%)\n translate(").concat(ny(l+v),"px, ").concat(ny(p+g),"px)\n "),display:void 0,zIndex:void 0},m&&(d>1||d<-1||l<0||l>S.width||p<0||p>S.height?O.display="none":O.zIndex=Math.floor((1-d)/2*1e5)),O),F=(0,h.useCallback)(function(t){_.props.onClose();var e=_.context.eventManager;e&&e.once("click",function(t){return t.stopPropagation()},t.target)},[]);return h.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(N," ").concat(k),style:z,ref:M},h.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:C}}),h.createElement("div",{key:"content",ref:E,className:"mapboxgl-popup-content"},R&&h.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:F},"\xd7"),A))}function nx(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}nk.propTypes=nS,nk.defaultProps=nT,h.memo(nk);var nD=Object.assign({},ns,{toggleLabel:p.string,className:p.string,style:p.object,compact:p.bool,customAttribution:p.oneOfType([p.string,p.arrayOf(p.string)])}),nC=Object.assign({},na,{className:"",toggleLabel:"Toggle Attribution"});function nR(t){var e=nc(t),n=e.context,r=e.containerRef,i=(0,h.useRef)(null),o=f((0,h.useState)(!1),2),s=o[0],c=o[1];(0,h.useEffect)(function(){var e,o,a,s,c,u;return n.map&&(o={customAttribution:t.customAttribution},a=n.map,s=r.current,c=i.current,(u=new(tM()).AttributionControl(o))._map=a,u._container=s,u._innerContainer=c,u._updateAttributions(),u._updateEditLink(),a.on("styledata",u._updateData),a.on("sourcedata",u._updateData),e=u),function(){return e&&void(e._map.off("styledata",e._updateData),e._map.off("sourcedata",e._updateData))}},[n.map]);var u=void 0===t.compact?n.viewport.width<=640:t.compact;(0,h.useEffect)(function(){!u&&s&&c(!1)},[u]);var l=(0,h.useCallback)(function(){return c(function(t){return!t})},[]),p=(0,h.useMemo)(function(){return function(t){for(var e=1;ea)return 1}return 0}(o.map.version,"1.6.0")>=0?2:1:2},[o.map]),n=o.viewport.bearing,r={transform:"rotate(".concat(-n,"deg)")},2===e?h.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:r}):h.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:r})))))}function nG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}nK.propTypes=nH,nK.defaultProps=nW,h.memo(nK);var n$=Object.assign({},ns,{className:p.string,style:p.object,maxWidth:p.number,unit:p.oneOf(["imperial","metric","nautical"])}),nJ=Object.assign({},na,{className:"",maxWidth:100,unit:"metric"});function nQ(t){var e=nc(t),n=e.context,r=e.containerRef,i=f((0,h.useState)(null),2),o=i[0],s=i[1];(0,h.useEffect)(function(){if(n.map){var t=new(tM()).ScaleControl;t._map=n.map,t._container=r.current,s(t)}},[n.map]),o&&(o.options=t,o._onMove());var c=(0,h.useMemo)(function(){return function(t){for(var e=1;e\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=i.console&&(i.console.warn||i.console.log);return o&&o.call(i.console,r,n),t.apply(this,arguments)}}c="function"!=typeof Object.assign?function(t){if(t===s||null===t)throw TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n-1}function T(t){return t.trim().split(/\s+/g)}function k(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var r=0;rk(i,a)&&r.push(t[o]),i[o]=a,o++}return n&&(r=e?r.sort(function(t,n){return t[e]>n[e]}):r.sort()),r}function C(t,e){for(var n,r,i=e[0].toUpperCase()+e.slice(1),o=0;o1&&!i.firstMultiple?i.firstMultiple=q(r):1===a&&(i.firstMultiple=!1),c=i.firstInput,l=(u=i.firstMultiple)?u.center:c.center,h=r.center=H(o),r.timeStamp=f(),r.deltaTime=r.timeStamp-c.timeStamp,r.angle=K(l,h),r.distance=X(l,h),d=i,g=(v=r).center,m=d.offsetDelta||{},b=d.prevDelta||{},y=d.prevInput||{},(1===v.eventType||4===y.eventType)&&(b=d.prevDelta={x:y.deltaX||0,y:y.deltaY||0},m=d.offsetDelta={x:g.x,y:g.y}),v.deltaX=b.x+(g.x-m.x),v.deltaY=b.y+(g.y-m.y),r.offsetDirection=Y(r.deltaX,r.deltaY),w=W(r.deltaTime,r.deltaX,r.deltaY),r.overallVelocityX=w.x,r.overallVelocityY=w.y,r.overallVelocity=p(w.x)>p(w.y)?w.x:w.y,r.scale=u?(O=u.pointers,X(o[0],o[1],B)/X(O[0],O[1],B)):1,r.rotation=u?(E=u.pointers,K(o[1],o[0],B)+K(E[1],E[0],B)):0,r.maxPointers=i.prevInput?r.pointers.length>i.prevInput.maxPointers?r.pointers.length:i.prevInput.maxPointers:r.pointers.length,function(t,e){var n,r,i,o,a=t.lastInterval||e,c=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(c>25||s===a.velocity)){var u=e.deltaX-a.deltaX,l=e.deltaY-a.deltaY,h=W(c,u,l);r=h.x,i=h.y,n=p(h.x)>p(h.y)?h.x:h.y,o=Y(u,l),t.lastInterval=e}else n=a.velocity,r=a.velocityX,i=a.velocityY,o=a.direction;e.velocity=n,e.velocityX=r,e.velocityY=i,e.direction=o}(i,r),_=t.element,j(r.srcEvent.target,_)&&(_=r.srcEvent.target),r.target=_,t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function q(t){for(var e=[],n=0;n=p(e)?t<0?2:4:e<0?8:16}function X(t,e,n){n||(n=V);var r=e[n[0]]-t[n[0]],i=e[n[1]]-t[n[1]];return Math.sqrt(r*r+i*i)}function K(t,e,n){n||(n=V);var r=e[n[0]]-t[n[0]];return 180*Math.atan2(e[n[1]]-t[n[1]],r)/Math.PI}Z.prototype={handler:function(){},init:function(){this.evEl&&P(this.element,this.evEl,this.domHandler),this.evTarget&&P(this.target,this.evTarget,this.domHandler),this.evWin&&P(A(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&M(this.element,this.evEl,this.domHandler),this.evTarget&&M(this.target,this.evTarget,this.domHandler),this.evWin&&M(A(this.element),this.evWin,this.domHandler)}};var G={mousedown:1,mousemove:2,mouseup:4};function $(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,Z.apply(this,arguments)}w($,Z,{handler:function(t){var e=G[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:F,srcEvent:t}))}});var J={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:z,3:"pen",4:F,5:"kinect"},tt="pointerdown",te="pointermove pointerup pointercancel";function tn(){this.evEl=tt,this.evWin=te,Z.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}i.MSPointerEvent&&!i.PointerEvent&&(tt="MSPointerDown",te="MSPointerMove MSPointerUp MSPointerCancel"),w(tn,Z,{handler:function(t){var e=this.store,n=!1,r=J[t.type.toLowerCase().replace("ms","")],i=Q[t.pointerType]||t.pointerType,o=k(e,t.pointerId,"pointerId");1&r&&(0===t.button||i==z)?o<0&&(e.push(t),o=e.length-1):12&r&&(n=!0),!(o<0)&&(e[o]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:i,srcEvent:t}),n&&e.splice(o,1))}});var tr={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ti(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Z.apply(this,arguments)}function to(t,e){var n=x(t.touches),r=x(t.changedTouches);return 12&e&&(n=D(n.concat(r),"identifier",!0)),[n,r]}w(ti,Z,{handler:function(t){var e=tr[t.type];if(1===e&&(this.started=!0),this.started){var n=to.call(this,t,e);12&e&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:z,srcEvent:t})}}});var ta={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ts(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},Z.apply(this,arguments)}function tc(t,e){var n=x(t.touches),r=this.targetIds;if(3&e&&1===n.length)return r[n[0].identifier]=!0,[n,n];var i,o,a=x(t.changedTouches),s=[],c=this.target;if(o=n.filter(function(t){return j(t.target,c)}),1===e)for(i=0;i-1&&r.splice(t,1)},2500)}}function tp(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,r=0;r-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function r(n){e.manager.emit(n,t)}n<8&&r(e.options.event+tP(n)),r(e.options.event),t.additionalEvent&&r(t.additionalEvent),n>=8&&r(e.options.event+tP(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=32},canEmit:function(){for(var t=0;te.threshold&&i&e.direction},attrTest:function(t){return tS.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=tM(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),w(tk,tS,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[tb]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),w(tx,t_,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[tg]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,r=t.distancee.time;if(this._input=t,r&&n&&(!(12&t.eventType)||i)){if(1&t.eventType)this.reset(),this._timer=d(function(){this.state=8,this.tryEmit()},e.time,this);else if(4&t.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=f(),this.manager.emit(this.options.event,this._input)))}}),w(tD,tS,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[tb]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),w(tC,tS,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return tT.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:24&n&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&p(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=tM(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),w(tR,t_,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[tm]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,r=t.distance1)for(var n=1;nt.length)&&(e=t.length);for(var n=0,r=Array(e);nn?n:t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),s=new d(4),d!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0,s[3]=0);const y=Math.log2||function(t){return Math.log(t)*Math.LOG2E};function w(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],u=e[6],l=e[7],h=e[8],p=e[9],f=e[10],d=e[11],v=e[12],g=e[13],m=e[14],b=e[15],y=n[0],w=n[1],O=n[2],E=n[3];return t[0]=y*r+w*s+O*h+E*v,t[1]=y*i+w*c+O*p+E*g,t[2]=y*o+w*u+O*f+E*m,t[3]=y*a+w*l+O*d+E*b,y=n[4],w=n[5],O=n[6],E=n[7],t[4]=y*r+w*s+O*h+E*v,t[5]=y*i+w*c+O*p+E*g,t[6]=y*o+w*u+O*f+E*m,t[7]=y*a+w*l+O*d+E*b,y=n[8],w=n[9],O=n[10],E=n[11],t[8]=y*r+w*s+O*h+E*v,t[9]=y*i+w*c+O*p+E*g,t[10]=y*o+w*u+O*f+E*m,t[11]=y*a+w*l+O*d+E*b,y=n[12],w=n[13],O=n[14],E=n[15],t[12]=y*r+w*s+O*h+E*v,t[13]=y*i+w*c+O*p+E*g,t[14]=y*o+w*u+O*f+E*m,t[15]=y*a+w*l+O*d+E*b,t}function O(t,e,n){var r,i,o,a,s,c,u,l,h,p,f,d,v=n[0],g=n[1],m=n[2];return e===t?(t[12]=e[0]*v+e[4]*g+e[8]*m+e[12],t[13]=e[1]*v+e[5]*g+e[9]*m+e[13],t[14]=e[2]*v+e[6]*g+e[10]*m+e[14],t[15]=e[3]*v+e[7]*g+e[11]*m+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],u=e[6],l=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=c,t[6]=u,t[7]=l,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=r*v+s*g+h*m+e[12],t[13]=i*v+c*g+p*m+e[13],t[14]=o*v+u*g+f*m+e[14],t[15]=a*v+l*g+d*m+e[15]),t}function E(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function _(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],u=t[7],l=t[8],h=t[9],p=t[10],f=t[11],d=t[12],v=t[13],g=t[14],m=t[15],b=e[0],y=e[1],w=e[2],O=e[3],E=e[4],_=e[5],P=e[6],M=e[7],j=e[8],S=e[9],T=e[10],k=e[11],x=e[12],D=e[13],C=e[14],R=e[15];return Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(r-y)<=1e-6*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-w)<=1e-6*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(o-O)<=1e-6*Math.max(1,Math.abs(o),Math.abs(O))&&Math.abs(a-E)<=1e-6*Math.max(1,Math.abs(a),Math.abs(E))&&Math.abs(s-_)<=1e-6*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(c-P)<=1e-6*Math.max(1,Math.abs(c),Math.abs(P))&&Math.abs(u-M)<=1e-6*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(l-j)<=1e-6*Math.max(1,Math.abs(l),Math.abs(j))&&Math.abs(h-S)<=1e-6*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(p-T)<=1e-6*Math.max(1,Math.abs(p),Math.abs(T))&&Math.abs(f-k)<=1e-6*Math.max(1,Math.abs(f),Math.abs(k))&&Math.abs(d-x)<=1e-6*Math.max(1,Math.abs(d),Math.abs(x))&&Math.abs(v-D)<=1e-6*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(g-C)<=1e-6*Math.max(1,Math.abs(g),Math.abs(C))&&Math.abs(m-R)<=1e-6*Math.max(1,Math.abs(m),Math.abs(R))}function P(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}function M(t,e,n,r){var i=e[0],o=e[1];return t[0]=i+r*(n[0]-i),t[1]=o+r*(n[1]-o),t}function j(t,e){if(!t)throw Error(e||"@math.gl/web-mercator: assertion failed.")}c=new d(2),d!=Float32Array&&(c[0]=0,c[1]=0),u=new d(3),d!=Float32Array&&(u[0]=0,u[1]=0,u[2]=0);const S=Math.PI,T=S/4,k=S/180,x=180/S;function D(t){return Math.pow(2,t)}function C([t,e]){j(Number.isFinite(t)),j(Number.isFinite(e)&&e>=-90&&e<=90,"invalid latitude");const n=512*(S+Math.log(Math.tan(T+.5*(e*k))))/(2*S);return[512*(t*k+S)/(2*S),n]}function R([t,e]){const n=2*(Math.atan(Math.exp(e/512*(2*S)-S))-T);return[(t/512*(2*S)-S)*x,n*x]}function A(t){return 2*Math.atan(.5/t)*x}function I(t){return .5/Math.tan(.5*t*k)}function L(t,e,n=0){const[r,i,o]=t;if(j(Number.isFinite(r)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(o)){const a=g(e,[r,i,o,1]);return a}const s=g(e,[r,i,0,1]),c=g(e,[r,i,1,1]),u=s[2],l=c[2];return M([],s,c,u===l?0:((n||0)-u)/(l-u))}const N=Math.PI/180;function z(t,e,n){const{pixelUnprojectionMatrix:r}=t,i=g(r,[e,0,1,1]),o=g(r,[e,t.height,1,1]),a=n*t.distanceScales.unitsPerMeter[2],s=(a-i[2])/(o[2]-i[2]),c=M([],i,o,s),u=R(c);return u[2]=n,u}class F{constructor({width:t,height:e,latitude:n=0,longitude:r=0,zoom:i=0,pitch:o=0,bearing:a=0,altitude:s=null,fovy:c=null,position:u=null,nearZMultiplier:l=.02,farZMultiplier:h=1.01}={width:1,height:1}){t=t||1,e=e||1,null===c&&null===s?c=A(s=1.5):null===c?c=A(s):null===s&&(s=I(c));const p=D(i);s=Math.max(.75,s);const f=function({latitude:t,longitude:e,highPrecision:n=!1}){j(Number.isFinite(t)&&Number.isFinite(e));const r={},i=Math.cos(t*k),o=512/360,a=o/i,s=512/4003e4/i;if(r.unitsPerMeter=[s,s,s],r.metersPerUnit=[1/s,1/s,1/s],r.unitsPerDegree=[o,a,s],r.degreesPerUnit=[1/o,1/a,1/s],n){const c=k*Math.tan(t*k)/i,u=512/4003e4*c,l=u/a*s;r.unitsPerDegree2=[0,o*c/2,u],r.unitsPerMeter2=[l,0,l]}return r}({longitude:r,latitude:n}),d=C([r,n]);if(d[2]=0,u){var g,m,b;b=d,g=[],m=f.unitsPerMeter,g[0]=u[0]*m[0],g[1]=u[1]*m[1],g[2]=u[2]*m[2],b[0]=d[0]+g[0],b[1]=d[1]+g[1],b[2]=d[2]+g[2]}this.projectionMatrix=function({width:t,height:e,pitch:n,altitude:r,fovy:i,nearZMultiplier:o,farZMultiplier:a}){var s,c,u;const{fov:l,aspect:h,near:p,far:f}=function({width:t,height:e,fovy:n=A(1.5),altitude:r,pitch:i=0,nearZMultiplier:o=1,farZMultiplier:a=1}){void 0!==r&&(n=A(r));const s=.5*n*k,c=I(n),u=i*k,l=Math.sin(s)*c/Math.sin(Math.min(Math.max(Math.PI/2-u-s,.01),Math.PI-.01)),h=Math.sin(u)*l+c;return{fov:2*s,aspect:t/e,focalDistance:c,near:o,far:h*a}}({width:t,height:e,altitude:r,fovy:i,pitch:n,nearZMultiplier:o,farZMultiplier:a}),d=(s=[],u=1/Math.tan(l/2),s[0]=u/h,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=u,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,null!=f&&f!==1/0?(c=1/(p-f),s[10]=(f+p)*c,s[14]=2*f*p*c):(s[10]=-1,s[14]=-2*p),s);return d}({width:t,height:e,pitch:o,fovy:c,nearZMultiplier:l,farZMultiplier:h}),this.viewMatrix=function({height:t,pitch:e,bearing:n,altitude:r,scale:i,center:o=null}){var a,s,c,u,l,h,p,f,d,g,m,b,y,w,_,P,M,j,S,T,x,D,C,R,A;const I=v();return O(I,I,[0,0,-r]),a=I,c=Math.sin(s=-e*k),u=Math.cos(s),l=I[4],h=I[5],p=I[6],f=I[7],d=I[8],g=I[9],m=I[10],b=I[11],I!==a&&(a[0]=I[0],a[1]=I[1],a[2]=I[2],a[3]=I[3],a[12]=I[12],a[13]=I[13],a[14]=I[14],a[15]=I[15]),a[4]=l*u+d*c,a[5]=h*u+g*c,a[6]=p*u+m*c,a[7]=f*u+b*c,a[8]=d*u-l*c,a[9]=g*u-h*c,a[10]=m*u-p*c,a[11]=b*u-f*c,y=I,_=Math.sin(w=n*k),P=Math.cos(w),M=I[0],j=I[1],S=I[2],T=I[3],x=I[4],D=I[5],C=I[6],R=I[7],I!==y&&(y[8]=I[8],y[9]=I[9],y[10]=I[10],y[11]=I[11],y[12]=I[12],y[13]=I[13],y[14]=I[14],y[15]=I[15]),y[0]=M*P+x*_,y[1]=j*P+D*_,y[2]=S*P+C*_,y[3]=T*P+R*_,y[4]=x*P-M*_,y[5]=D*P-j*_,y[6]=C*P-S*_,y[7]=R*P-T*_,E(I,I,[i/=t,i,i]),o&&O(I,I,((A=[])[0]=-o[0],A[1]=-o[1],A[2]=-o[2],A)),I}({height:e,scale:p,center:d,pitch:o,bearing:a,altitude:s}),this.width=t,this.height=e,this.scale=p,this.latitude=n,this.longitude=r,this.zoom=i,this.pitch=o,this.bearing=a,this.altitude=s,this.fovy=c,this.center=d,this.meterOffset=u||[0,0,0],this.distanceScales=f,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 t,e,n,r,i,o,a,s,c,u,l,h,p,f,d,g,m,b,y,_,P,M,j,S,T,k,x,D,C,R;const{width:A,height:I,projectionMatrix:L,viewMatrix:N}=this,z=v();w(z,z,L),w(z,z,N),this.viewProjectionMatrix=z;const F=v();E(F,F,[A/2,-I/2,1]),O(F,F,[1,-1,0]),w(F,F,z);const V=(t=v(),e=F[0],n=F[1],r=F[2],i=F[3],o=F[4],a=F[5],s=F[6],c=F[7],u=F[8],l=F[9],h=F[10],p=F[11],f=F[12],d=F[13],g=F[14],m=F[15],b=e*a-n*o,y=e*s-r*o,_=e*c-i*o,P=n*s-r*a,M=n*c-i*a,j=r*c-i*s,S=u*d-l*f,T=u*g-h*f,k=u*m-p*f,x=l*g-h*d,D=l*m-p*d,(R=b*(C=h*m-p*g)-y*D+_*x+P*k-M*T+j*S)?(R=1/R,t[0]=(a*C-s*D+c*x)*R,t[1]=(r*D-n*C-i*x)*R,t[2]=(d*j-g*M+m*P)*R,t[3]=(h*M-l*j-p*P)*R,t[4]=(s*k-o*C-c*T)*R,t[5]=(e*C-r*k+i*T)*R,t[6]=(g*_-f*j-m*y)*R,t[7]=(u*j-h*_+p*y)*R,t[8]=(o*D-a*k+c*S)*R,t[9]=(n*k-e*D-i*S)*R,t[10]=(f*M-d*_+m*b)*R,t[11]=(l*_-u*M-p*b)*R,t[12]=(a*T-o*x-s*S)*R,t[13]=(e*x-n*T+r*S)*R,t[14]=(d*y-f*P-g*b)*R,t[15]=(u*P-l*y+h*b)*R,t):null);if(!V)throw Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=F,this.pixelUnprojectionMatrix=V}equals(t){return t instanceof F&&t.width===this.width&&t.height===this.height&&_(t.projectionMatrix,this.projectionMatrix)&&_(t.viewMatrix,this.viewMatrix)}project(t,{topLeft:e=!0}={}){const n=this.projectPosition(t),r=function(t,e){const[n,r,i=0]=t;return j(Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)),g(e,[n,r,i,1])}(n,this.pixelProjectionMatrix),[i,o]=r,a=e?o:this.height-o;return 2===t.length?[i,a]:[i,a,r[2]]}unproject(t,{topLeft:e=!0,targetZ:n}={}){const[r,i,o]=t,a=e?i:this.height-i,s=n&&n*this.distanceScales.unitsPerMeter[2],c=L([r,a,o],this.pixelUnprojectionMatrix,s),[u,l,h]=this.unprojectPosition(c);return Number.isFinite(o)?[u,l,h]:Number.isFinite(n)?[u,l,n]:[u,l]}projectPosition(t){const[e,n]=C(t),r=(t[2]||0)*this.distanceScales.unitsPerMeter[2];return[e,n,r]}unprojectPosition(t){const[e,n]=R(t),r=(t[2]||0)*this.distanceScales.metersPerUnit[2];return[e,n,r]}projectFlat(t){return C(t)}unprojectFlat(t){return R(t)}getMapCenterByLngLatPosition({lngLat:t,pos:e}){var n;const r=L(e,this.pixelUnprojectionMatrix),i=C(t),o=P([],i,((n=[])[0]=-r[0],n[1]=-r[1],n)),a=P([],this.center,o);return R(a)}getLocationAtPoint({lngLat:t,pos:e}){return this.getMapCenterByLngLatPosition({lngLat:t,pos:e})}fitBounds(t,e={}){const{width:n,height:r}=this,{longitude:i,latitude:o,zoom:a}=function({width:t,height:e,bounds:n,minExtent:r=0,maxZoom:i=24,padding:o=0,offset:a=[0,0]}){const[[s,c],[u,l]]=n;if(Number.isFinite(o)){const h=o;o={top:h,bottom:h,left:h,right:h}}else j(Number.isFinite(o.top)&&Number.isFinite(o.bottom)&&Number.isFinite(o.left)&&Number.isFinite(o.right));const p=C([s,b(l,-85.051129,85.051129)]),f=C([u,b(c,-85.051129,85.051129)]),d=[Math.max(Math.abs(f[0]-p[0]),r),Math.max(Math.abs(f[1]-p[1]),r)],v=[t-o.left-o.right-2*Math.abs(a[0]),e-o.top-o.bottom-2*Math.abs(a[1])];j(v[0]>0&&v[1]>0);const g=v[0]/d[0],m=v[1]/d[1],w=(o.right-o.left)/2/g,O=(o.bottom-o.top)/2/m,E=[(f[0]+p[0])/2+w,(f[1]+p[1])/2+O],_=R(E),P=Math.min(i,y(Math.abs(Math.min(g,m))));return j(Number.isFinite(P)),{longitude:_[0],latitude:_[1],zoom:P}}(Object.assign({width:n,height:r,bounds:t},e));return new F({width:n,height:r,longitude:i,latitude:o,zoom:a})}getBounds(t){const e=this.getBoundingRegion(t),n=Math.min(...e.map(t=>t[0])),r=Math.max(...e.map(t=>t[0])),i=Math.min(...e.map(t=>t[1])),o=Math.max(...e.map(t=>t[1]));return[[n,i],[r,o]]}getBoundingRegion(t={}){return function(t,e=0){let n,r;const{width:i,height:o,unproject:a}=t,s={targetZ:e},c=a([0,o],s),u=a([i,o],s),l=t.fovy?.5*t.fovy*N:Math.atan(.5/t.altitude),h=(90-t.pitch)*N;return l>h-.01?(n=z(t,0,e),r=z(t,i,e)):(n=a([0,0],s),r=a([i,0],s)),[c,u,r,n]}(this,t.z||0)}}const V=["longitude","latitude","zoom"],B={curve:1.414,speed:1.2};function Z(t,e,n){var r;n=Object.assign({},B,n);const i=n.curve,o=t.zoom,a=[t.longitude,t.latitude],s=D(o),c=e.zoom,u=[e.longitude,e.latitude],l=D(c-o),h=C(a),p=C(u),f=((r=[])[0]=p[0]-h[0],r[1]=p[1]-h[1],r),d=Math.max(t.width,t.height),v=d/l,g=Math.hypot(f[0],f[1])*s,m=Math.max(g,.01),b=i*i,y=(v*v-d*d+b*b*m*m)/(2*d*b*m),w=(v*v-d*d-b*b*m*m)/(2*v*b*m),O=Math.log(Math.sqrt(y*y+1)-y),E=Math.log(Math.sqrt(w*w+1)-w);return{startZoom:o,startCenterXY:h,uDelta:f,w0:d,u1:g,S:(E-O)/i,rho:i,rho2:b,r0:O,r1:E}}var U=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var n=-1;return t.some(function(t,r){return t[0]===e&&(n=r,!0)}),n}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var n=t(this.__entries__,e),r=this.__entries__[n];return r&&r[1]},e.prototype.set=function(e,n){var r=t(this.__entries__,e);~r?this.__entries__[r][1]=n:this.__entries__.push([e,n])},e.prototype.delete=function(e){var n=this.__entries__,r=t(n,e);~r&&n.splice(r,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var n=0,r=this.__entries__;n0},t.prototype.connect_=function(){q&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),X?(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)},t.prototype.disconnect_=function(){q&&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)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;Y.some(function(t){return!!~n.indexOf(t)})&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),G=function(t,e){for(var n=0,r=Object.keys(e);n0},t}(),ta="undefined"!=typeof WeakMap?new WeakMap:new U,ts=function t(e){if(!(this instanceof t))throw TypeError("Cannot call a class as a function.");if(!arguments.length)throw TypeError("1 argument required, but only 0 present.");var n=K.getInstance(),r=new to(e,n,this);ta.set(this,r)};["observe","unobserve","disconnect"].forEach(function(t){ts.prototype[t]=function(){var e;return(e=ta.get(this))[t].apply(e,arguments)}});var tc=void 0!==H.ResizeObserver?H.ResizeObserver:ts;function tu(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}function tl(t,e){for(var n=0;n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function tg(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n1&&void 0!==arguments[1]?arguments[1]:"component";t.debug&&p.checkPropTypes(tw,t,"prop",e)}var t_=function(){function t(e){var n=this;if(tu(this,t),a(this,"props",tO),a(this,"width",0),a(this,"height",0),a(this,"_fireLoadEvent",function(){n.props.onLoad({type:"load",target:n._map})}),a(this,"_handleError",function(t){n.props.onError(t)}),!e.mapboxgl)throw Error("Mapbox not available");this.mapboxgl=e.mapboxgl,t.initialized||(t.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(e)}return th(t,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(t){return this._update(this.props,t),this}},{key:"redraw",value:function(){var t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(e){this._map=t.savedMap;var n=this._map.getContainer(),r=e.container;for(r.classList.add("mapboxgl-map");n.childNodes.length>0;)r.appendChild(n.childNodes[0]);this._map._container=r,t.savedMap=null,e.mapStyle&&this._map.setStyle(tb(e.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(e){if(e.reuseMaps&&t.savedMap)this._reuse(e);else{if(e.gl){var n=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=n,e.gl}}var r={container:e.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:tb(e.mapStyle),interactive:!1,trackResize:!1,attributionControl:e.attributionControl,preserveDrawingBuffer:e.preserveDrawingBuffer};e.transformRequest&&(r.transformRequest=e.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},r,e.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!t.savedMap?(t.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(t){var e=this;t=Object.assign({},tO,t),tE(t,"Mapbox"),this.mapboxgl.accessToken=t.mapboxApiAccessToken||tO.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=t.mapboxApiUrl,this._create(t);var n=t.container;Object.defineProperty(n,"offsetWidth",{configurable:!0,get:function(){return e.width}}),Object.defineProperty(n,"clientWidth",{configurable:!0,get:function(){return e.width}}),Object.defineProperty(n,"offsetHeight",{configurable:!0,get:function(){return e.height}}),Object.defineProperty(n,"clientHeight",{configurable:!0,get:function(){return e.height}});var r=this._map.getCanvas();r&&(r.style.outline="none"),this._updateMapViewport({},t),this._updateMapSize({},t),this.props=t}},{key:"_update",value:function(t,e){if(this._map){tE(e=Object.assign({},this.props,e),"Mapbox");var n=this._updateMapViewport(t,e),r=this._updateMapSize(t,e);this._updateMapStyle(t,e),!e.asyncRender&&(n||r)&&this.redraw(),this.props=e}}},{key:"_updateMapStyle",value:function(t,e){t.mapStyle!==e.mapStyle&&this._map.setStyle(tb(e.mapStyle),{diff:!e.preventStyleDiffing})}},{key:"_updateMapSize",value:function(t,e){var n=t.width!==e.width||t.height!==e.height;return n&&(this.width=e.width,this.height=e.height,this._map.resize()),n}},{key:"_updateMapViewport",value:function(t,e){var n=this._getViewState(t),r=this._getViewState(e),i=r.latitude!==n.latitude||r.longitude!==n.longitude||r.zoom!==n.zoom||r.pitch!==n.pitch||r.bearing!==n.bearing||r.altitude!==n.altitude;return i&&(this._map.jumpTo(this._viewStateToMapboxProps(r)),r.altitude!==n.altitude&&(this._map.transform.altitude=r.altitude)),i}},{key:"_getViewState",value:function(t){var e=t.viewState||t,n=e.longitude,r=e.latitude,i=e.zoom,o=e.pitch,a=e.bearing,s=e.altitude;return{longitude:n,latitude:r,zoom:i,pitch:void 0===o?0:o,bearing:void 0===a?0:a,altitude:void 0===s?1.5:s}}},{key:"_checkStyleSheet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==tp)try{var e=tp.createElement("div");if(e.className="mapboxgl-map",e.style.display="none",tp.body.appendChild(e),!("static"!==window.getComputedStyle(e).position)){var n=tp.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),n.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(t,"/mapbox-gl.css")),tp.head.appendChild(n)}}catch(r){}}},{key:"_viewStateToMapboxProps",value:function(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}}}]),t}();a(t_,"initialized",!1),a(t_,"propTypes",tw),a(t_,"defaultProps",tO),a(t_,"savedMap",null);var tP=n(6158),tM=n.n(tP);function tj(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function tS(t,e,n){return Math.max(e,Math.min(n,t))}function tT(t,e,n){return tj(t)?t.map(function(t,r){return tT(t,e[r],n)}):n*e+(1-n)*t}function tk(t,e){if(!t)throw Error(e||"react-map-gl: assertion failed.")}function tx(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function tD(t){for(var e=1;e0,"`scale` must be a positive number");var i=this._state,o=i.startZoom,a=i.startZoomLngLat;Number.isFinite(o)||(o=this._viewportProps.zoom,a=this._unproject(n)||this._unproject(e)),tk(a,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var s=this._calculateNewZoom({scale:r,startZoom:o||0}),c=new F(Object.assign({},this._viewportProps,{zoom:s})).getMapCenterByLngLatPosition({lngLat:a,pos:e}),u=f(c,2),l=u[0],h=u[1];return this._getUpdatedMapState({zoom:s,longitude:l,latitude:h})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(e){return new t(Object.assign({},this._viewportProps,this._state,e))}},{key:"_applyConstraints",value:function(t){var e=t.maxZoom,n=t.minZoom,r=t.zoom;t.zoom=tS(r,n,e);var i=t.maxPitch,o=t.minPitch,a=t.pitch;return t.pitch=tS(a,o,i),Object.assign(t,function({width:t,height:e,longitude:n,latitude:r,zoom:i,pitch:o=0,bearing:a=0}){(n<-180||n>180)&&(n=m(n+180,360)-180),(a<-180||a>180)&&(a=m(a+180,360)-180);const s=y(e/512);if(i<=s)i=s,r=0;else{const c=e/2/Math.pow(2,i),u=R([0,c])[1];if(rl&&(r=l)}}return{width:t,height:e,longitude:n,latitude:r,zoom:i,pitch:o,bearing:a}}(t)),t}},{key:"_unproject",value:function(t){var e=new F(this._viewportProps);return t&&e.unproject(t)}},{key:"_calculateNewLngLat",value:function(t){var e=t.startPanLngLat,n=t.pos;return new F(this._viewportProps).getMapCenterByLngLatPosition({lngLat:e,pos:n})}},{key:"_calculateNewZoom",value:function(t){var e=t.scale,n=t.startZoom,r=this._viewportProps,i=r.maxZoom;return tS(n+Math.log2(e),r.minZoom,i)}},{key:"_calculateNewPitchAndBearing",value:function(t){var e=t.deltaScaleX,n=t.deltaScaleY,r=t.startBearing,i=t.startPitch;n=tS(n,-1,1);var o=this._viewportProps,a=o.minPitch,s=o.maxPitch,c=i;return n>0?c=i+n*(s-i):n<0&&(c=i-n*(a-i)),{pitch:c,bearing:r+180*e}}},{key:"_getRotationParams",value:function(t,e){var n=t[0]-e[0],r=t[1]-e[1],i=t[1],o=e[1],a=this._viewportProps,s=a.width,c=a.height,u=0;return r>0?Math.abs(c-o)>5&&(u=r/(o-c)*1.2):r<0&&o>5&&(u=1-i/o),{deltaScaleX:n/s,deltaScaleY:u=Math.min(1,Math.max(-1,u))}}}]),t}();function tI(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function tL(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{},n=c.current&&c.current.getMap();return n&&n.queryRenderedFeatures(t,e)}}},[]);var g=(0,h.useCallback)(function(t){var e=t.target;e===p.current&&e.scrollTo(0,0)},[]),m=v&&h.createElement(tz,{value:tZ(tZ({},d),{},{viewport:d.viewport||tq(tZ({map:v,props:t},a)),map:v,container:d.container||l.current})},h.createElement("div",{key:"map-overlays",className:"overlays",ref:p,style:tH,onScroll:g},t.children)),b=t.className,y=t.width,w=t.height,O=t.style,E=t.visibilityConstraints,_=Object.assign({position:"relative"},O,{width:y,height:w}),P=t.visible&&function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tC;for(var n in e){var r,i=n.slice(0,3),o=(r=n.slice(3))[0].toLowerCase()+r.slice(1);if("min"===i&&t[o]e[n])return!1}return!0}(t.viewState||t,E),M=Object.assign({},tH,{visibility:P?"inherit":"hidden"});return h.createElement("div",{key:"map-container",ref:l,style:_},h.createElement("div",{key:"map-mapbox",ref:u,style:M,className:b}),m,!r&&!t.disableTokenWarning&&h.createElement(tX,null))});function tG(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}(this.propNames||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(!function t(e,n){if(e===n)return!0;if(tj(e)&&tj(n)){if(e.length!==n.length)return!1;for(var r=0;r=Math.abs(e-n)}(t[i],e[i]))return!1}}catch(o){r.e(o)}finally{r.f()}return!0}},{key:"initializeProps",value:function(t,e){return{start:t,end:e}}},{key:"interpolateProps",value:function(t,e,n){tk(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(t,e){return e.transitionDuration}}]),t}();function tJ(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function tQ(t,e){return(tQ=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function t0(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&tQ(t,e)}function t1(t){return(t1="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function t2(t,e){if(e&&("object"===t1(e)||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return tJ(t)}function t4(t){return(t4=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var t3={longitude:1,bearing:1};function t5(t){return Number.isFinite(t)||Array.isArray(t)}function t8(t,e,n){return t in t3&&Math.abs(n-e)>180&&(n=n<0?n+360:n-360),n}function t6(t,e){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return t7(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t7(t,e)}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function t7(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o,a=!0,s=!1;return{s:function(){i=t[Symbol.iterator]()},n:function(){var t=i.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function ei(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&void 0!==arguments[0]?arguments[0]:{};return tu(this,r),a(tJ(t=n.call(this)),"propNames",t9),t.props=Object.assign({},en,e),t}th(r,[{key:"initializeProps",value:function(t,e){var n,r={},i={},o=t6(et);try{for(o.s();!(n=o.n()).done;){var a=n.value,s=t[a],c=e[a];tk(t5(s)&&t5(c),"".concat(a," must be supplied for transition")),r[a]=s,i[a]=t8(a,s,c)}}catch(u){o.e(u)}finally{o.f()}var l,h=t6(ee);try{for(h.s();!(l=h.n()).done;){var p=l.value,f=t[p]||0,d=e[p]||0;r[p]=f,i[p]=t8(p,f,d)}}catch(v){h.e(v)}finally{h.f()}return{start:r,end:i}}},{key:"interpolateProps",value:function(t,e,n){var r,i=function(t,e,n,r={}){var i,o,a,s;const c={},{startZoom:u,startCenterXY:l,uDelta:h,w0:p,u1:f,S:d,rho:v,rho2:g,r0:m}=Z(t,e,r);if(f<.01){for(const b of V){const w=t[b],O=e[b];c[b]=(i=w,o=O,(a=n)*o+(1-a)*i)}return c}const E=n*d,_=Math.cosh(m)/Math.cosh(m+v*E),M=p*((Math.cosh(m)*Math.tanh(m+v*E)-Math.sinh(m))/g)/f,j=u+y(1/_),S=((s=[])[0]=h[0]*M,s[1]=h[1]*M,s);P(S,S,l);const T=R(S);return c.longitude=T[0],c.latitude=T[1],c.zoom=j,c}(t,e,n,this.props),o=t6(ee);try{for(o.s();!(r=o.n()).done;){var a=r.value;i[a]=tT(t[a],e[a],n)}}catch(s){o.e(s)}finally{o.f()}return i}},{key:"getDuration",value:function(t,e){var n=e.transitionDuration;return"auto"===n&&(n=function(t,e,n={}){let r;n=Object.assign({},B,n);const{screenSpeed:i,speed:o,maxDuration:a}=n,{S:s,rho:c}=Z(t,e,n),u=1e3*s;return r=Number.isFinite(i)?u/(i/c):u/o,Number.isFinite(a)&&r>a?0:r}(t,e,this.props)),n}}])}(t$);var eo=["longitude","latitude","zoom","bearing","pitch"],ea=function(t){t0(r,t);var e,n=(e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,n=t4(r);if(e){var i=t4(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return t2(this,t)});function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return tu(this,r),t=n.call(this),Array.isArray(e)&&(e={transitionProps:e}),t.propNames=e.transitionProps||eo,e.around&&(t.around=e.around),t}return th(r,[{key:"initializeProps",value:function(t,e){var n={},r={};if(this.around){n.around=this.around;var i=new F(t).unproject(this.around);Object.assign(r,e,{around:new F(e).project(i),aroundLngLat:i})}var o,a=er(this.propNames);try{for(a.s();!(o=a.n()).done;){var s=o.value,c=t[s],u=e[s];tk(t5(c)&&t5(u),"".concat(s," must be supplied for transition")),n[s]=c,r[s]=t8(s,c,u)}}catch(l){a.e(l)}finally{a.f()}return{start:n,end:r}}},{key:"interpolateProps",value:function(t,e,n){var r,i={},o=er(this.propNames);try{for(o.s();!(r=o.n()).done;){var a=r.value;i[a]=tT(t[a],e[a],n)}}catch(s){o.e(s)}finally{o.f()}if(e.around){var c=new F(Object.assign({},e,i)).getMapCenterByLngLatPosition({lngLat:e.aroundLngLat,pos:tT(t.around,e.around,n)}),u=f(c,2),l=u[0],h=u[1];i.longitude=l,i.latitude=h}return i}}]),r}(t$),es=function(){},ec={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},eu={transitionDuration:0,transitionEasing:function(t){return t},transitionInterpolator:new ea,transitionInterruption:ec.BREAK,onTransitionStart:es,onTransitionInterrupt:es,onTransitionEnd:es},el=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};tu(this,t),a(this,"_animationFrame",null),a(this,"_onTransitionFrame",function(){e._animationFrame=requestAnimationFrame(e._onTransitionFrame),e._updateViewport()}),this.props=null,this.onViewportChange=n.onViewportChange||es,this.onStateChange=n.onStateChange||es,this.time=n.getTime||Date.now}return th(t,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(t){var e=this.props;if(this.props=t,!e||this._shouldIgnoreViewportChange(e,t))return!1;if(this._isTransitionEnabled(t)){var n=Object.assign({},e),r=Object.assign({},t);if(this._isTransitionInProgress()&&(e.onTransitionInterrupt(),this.state.interruption===ec.SNAP_TO_END?Object.assign(n,this.state.endProps):Object.assign(n,this.state.propsInTransition),this.state.interruption===ec.UPDATE)){var i,o,a=this.time(),s=(a-this.state.startTime)/this.state.duration;r.transitionDuration=this.state.duration-(a-this.state.startTime),r.transitionEasing=(o=(i=this.state.easing)(s),function(t){return 1/(1-o)*(i(t*(1-s)+s)-o)}),r.transitionInterpolator=n.transitionInterpolator}return r.onTransitionStart(),this._triggerTransition(n,r),!0}return this._isTransitionInProgress()&&(e.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(t){var e=t.transitionDuration,n=t.transitionInterpolator;return(e>0||"auto"===e)&&Boolean(n)}},{key:"_isUpdateDueToCurrentTransition",value:function(t){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(t,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(t,e){return!t||(this._isTransitionInProgress()?this.state.interruption===ec.IGNORE||this._isUpdateDueToCurrentTransition(e):!this._isTransitionEnabled(e)||e.transitionInterpolator.arePropsEqual(t,e))}},{key:"_triggerTransition",value:function(t,e){tk(this._isTransitionEnabled(e)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var n=e.transitionInterpolator,r=n.getDuration?n.getDuration(t,e):e.transitionDuration;if(0!==r){var i=e.transitionInterpolator.initializeProps(t,e),o={inTransition:!0,isZooming:t.zoom!==e.zoom,isPanning:t.longitude!==e.longitude||t.latitude!==e.latitude,isRotating:t.bearing!==e.bearing||t.pitch!==e.pitch};this.state={duration:r,easing:e.transitionEasing,interpolator:e.transitionInterpolator,interruption:e.transitionInterruption,startTime:this.time(),startProps:i.start,endProps:i.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(o)}}},{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 t=this.time(),e=this.state,n=e.startTime,r=e.duration,i=e.easing,o=e.interpolator,a=e.startProps,s=e.endProps,c=!1,u=(t-n)/r;u>=1&&(u=1,c=!0),u=i(u);var l=o.interpolateProps(a,s,u),h=new tA(Object.assign({},this.props,l));this.state.propsInTransition=h.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),t}();a(el,"defaultProps",eu);var eh=n(840),ep=n.n(eh);const ef={mousedown:1,mousemove:2,mouseup:4};!function(t){const e=t.prototype.handler;t.prototype.handler=function(t){const n=this.store;t.button>0&&"pointerdown"===t.type&&!function(t,e){for(let n=0;ne.pointerId===t.pointerId)&&n.push(t),e.call(this,t)}}(ep().PointerEventInput),ep().MouseInput.prototype.handler=function(t){let e=ef[t.type];1&e&&t.button>=0&&(this.pressed=!0),2&e&&0===t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:"mouse",srcEvent:t}))};const ed=ep().Manager;var ev=ep();const eg=ev?[[ev.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[ev.Rotate,{enable:!1}],[ev.Pinch,{enable:!1}],[ev.Swipe,{enable:!1}],[ev.Pan,{threshold:0,enable:!1}],[ev.Press,{enable:!1}],[ev.Tap,{event:"doubletap",taps:2,enable:!1}],[ev.Tap,{event:"anytap",enable:!1}],[ev.Tap,{enable:!1}]]:null,em={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},eb={doubletap:["tap"]},ey={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},ew={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},eO={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"},eE={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},e_="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",eP="undefined"!=typeof window?window:n.g;void 0!==n.g?n.g:window;let eM=!1;try{const ej={get passive(){return eM=!0,!0}};eP.addEventListener("test",ej,ej),eP.removeEventListener("test",ej,ej)}catch(eS){}const eT=-1!==e_.indexOf("firefox"),{WHEEL_EVENTS:ek}=ew,ex="wheel";class eD{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.events=ek.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(e=>t.addEventListener(e,this.handleEvent,!!eM&&{passive:!1}))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===ex&&(this.options.enable=e)}handleEvent(t){if(!this.options.enable)return;let e=t.deltaY;eP.WheelEvent&&(eT&&t.deltaMode===eP.WheelEvent.DOM_DELTA_PIXEL&&(e/=eP.devicePixelRatio),t.deltaMode===eP.WheelEvent.DOM_DELTA_LINE&&(e*=40));const n={x:t.clientX,y:t.clientY};0!==e&&e%4.000244140625==0&&(e=Math.floor(e/4.000244140625)),t.shiftKey&&e&&(e*=.25),this._onWheel(t,-e,n)}_onWheel(t,e,n){this.callback({type:ex,center:n,delta:e,srcEvent:t,pointerType:"mouse",target:t.target})}}const{MOUSE_EVENTS:eC}=ew,eR="pointermove",eA="pointerover",eI="pointerout",eL="pointerleave";class eN{constructor(t,e,n={}){this.element=t,this.callback=e,this.pressed=!1,this.options=Object.assign({enable:!0},n),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=eC.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===eR&&(this.enableMoveEvent=e),t===eA&&(this.enableOverEvent=e),t===eI&&(this.enableOutEvent=e),t===eL&&(this.enableLeaveEvent=e)}handleEvent(t){this.handleOverEvent(t),this.handleOutEvent(t),this.handleLeaveEvent(t),this.handleMoveEvent(t)}handleOverEvent(t){this.enableOverEvent&&"mouseover"===t.type&&this.callback({type:eA,srcEvent:t,pointerType:"mouse",target:t.target})}handleOutEvent(t){this.enableOutEvent&&"mouseout"===t.type&&this.callback({type:eI,srcEvent:t,pointerType:"mouse",target:t.target})}handleLeaveEvent(t){this.enableLeaveEvent&&"mouseleave"===t.type&&this.callback({type:eL,srcEvent:t,pointerType:"mouse",target:t.target})}handleMoveEvent(t){if(this.enableMoveEvent)switch(t.type){case"mousedown":t.button>=0&&(this.pressed=!0);break;case"mousemove":0===t.which&&(this.pressed=!1),this.pressed||this.callback({type:eR,srcEvent:t,pointerType:"mouse",target:t.target});break;case"mouseup":this.pressed=!1}}}const{KEY_EVENTS:ez}=ew,eF="keydown",eV="keyup";class eB{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=ez.concat(n.events||[]),this.handleEvent=this.handleEvent.bind(this),t.tabIndex=n.tabIndex||0,t.style.outline="none",this.events.forEach(e=>t.addEventListener(e,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,e){t===eF&&(this.enableDownEvent=e),t===eV&&(this.enableUpEvent=e)}handleEvent(t){const e=t.target||t.srcElement;("INPUT"!==e.tagName||"text"!==e.type)&&"TEXTAREA"!==e.tagName&&(this.enableDownEvent&&"keydown"===t.type&&this.callback({type:eF,srcEvent:t,key:t.key,target:t.target}),this.enableUpEvent&&"keyup"===t.type&&this.callback({type:eV,srcEvent:t,key:t.key,target:t.target}))}}const eZ="contextmenu";class eU{constructor(t,e,n={}){this.element=t,this.callback=e,this.options=Object.assign({enable:!0},n),this.handleEvent=this.handleEvent.bind(this),t.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(t,e){t===eZ&&(this.options.enable=e)}handleEvent(t){this.options.enable&&this.callback({type:eZ,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}}const eq={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},eH={srcElement:"root",priority:0};class eW{constructor(t){this.eventManager=t,this.handlers=[],this.handlersByElement=new Map,this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(t,e,n,r=!1,i=!1){const{handlers:o,handlersByElement:a}=this;n&&("object"!=typeof n||n.addEventListener)&&(n={srcElement:n}),n=n?Object.assign({},eH,n):eH;let s=a.get(n.srcElement);s||(s=[],a.set(n.srcElement,s));const c={type:t,handler:e,srcElement:n.srcElement,priority:n.priority};r&&(c.once=!0),i&&(c.passive=!0),o.push(c),this._active=this._active||!c.passive;let u=s.length-1;for(;u>=0&&!(s[u].priority>=c.priority);)u--;s.splice(u+1,0,c)}remove(t,e){const{handlers:n,handlersByElement:r}=this;for(let i=n.length-1;i>=0;i--){const o=n[i];if(o.type===t&&o.handler===e){n.splice(i,1);const a=r.get(o.srcElement);a.splice(a.indexOf(o),1),0===a.length&&r.delete(o.srcElement)}}this._active=n.some(t=>!t.passive)}handleEvent(t){if(this.isEmpty())return;const e=this._normalizeEvent(t);let n=t.srcEvent.target;for(;n&&n!==e.rootElement;){if(this._emit(e,n),e.handled)return;n=n.parentNode}this._emit(e,"root")}_emit(t,e){const n=this.handlersByElement.get(e);if(n){let r=!1;const i=()=>{t.handled=!0},o=()=>{t.handled=!0,r=!0},a=[];for(let s=0;s{const e=this.manager.get(t);e&&em[t].forEach(t=>{e.recognizeWith(t)})}),e.recognizerOptions){const i=this.manager.get(r);if(i){const o=e.recognizerOptions[r];delete o.enable,i.set(o)}}for(const[a,s]of(this.wheelInput=new eD(t,this._onOtherEvent,{enable:!1}),this.moveInput=new eN(t,this._onOtherEvent,{enable:!1}),this.keyInput=new eB(t,this._onOtherEvent,{enable:!1,tabIndex:e.tabIndex}),this.contextmenuInput=new eU(t,this._onOtherEvent,{enable:!1}),this.events))s.isEmpty()||(this._toggleRecognizer(s.recognizerName,!0),this.manager.on(a,s.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(t,e,n){this._addEventHandler(t,e,n,!1)}once(t,e,n){this._addEventHandler(t,e,n,!0)}watch(t,e,n){this._addEventHandler(t,e,n,!1,!0)}off(t,e){this._removeEventHandler(t,e)}_toggleRecognizer(t,e){const{manager:n}=this;if(!n)return;const r=n.get(t);if(r&&r.options.enable!==e){r.set({enable:e});const i=eb[t];i&&!this.options.recognizers&&i.forEach(i=>{const o=n.get(i);e?(o.requireFailure(t),r.dropRequireFailure(i)):o.dropRequireFailure(t)})}this.wheelInput.enableEventType(t,e),this.moveInput.enableEventType(t,e),this.keyInput.enableEventType(t,e),this.contextmenuInput.enableEventType(t,e)}_addEventHandler(t,e,n,r,i){if("string"!=typeof t){for(const o in n=e,t)this._addEventHandler(o,t[o],n,r,i);return}const{manager:a,events:s}=this,c=eE[t]||t;let u=s.get(c);!u&&(u=new eW(this),s.set(c,u),u.recognizerName=eO[c]||c,a&&a.on(c,u.handleEvent)),u.add(t,e,n,r,i),u.isEmpty()||this._toggleRecognizer(u.recognizerName,!0)}_removeEventHandler(t,e){if("string"!=typeof t){for(const n in t)this._removeEventHandler(n,t[n]);return}const{events:r}=this,i=eE[t]||t,o=r.get(i);if(o&&(o.remove(t,e),o.isEmpty())){const{recognizerName:a}=o;let s=!1;for(const c of r.values())if(c.recognizerName===a&&!c.isEmpty()){s=!0;break}s||this._toggleRecognizer(a,!1)}}_onBasicInput(t){const{srcEvent:e}=t,n=ey[e.type];n&&this.manager.emit(n,t)}_onOtherEvent(t){this.manager.emit(t.type,t)}}function eK(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function eG(t){for(var e=1;e0),a=o&&!this.state.isHovering,s=!o&&this.state.isHovering;(r||a)&&(t.features=e,r&&r(t)),a&&e9.call(this,"onMouseEnter",t),s&&e9.call(this,"onMouseLeave",t),(a||s)&&this.setState({isHovering:o})}}function nr(t){var e=this.props,n=e.onClick,r=e.onNativeClick,i=e.onDblClick,o=e.doubleClickZoom,a=[],s=i||o;switch(t.type){case"anyclick":a.push(r),s||a.push(n);break;case"click":s&&a.push(n)}(a=a.filter(Boolean)).length&&((t=e6.call(this,t)).features=e7.call(this,t.point),a.forEach(function(e){return e(t)}))}var ni=(0,h.forwardRef)(function(t,e){var n,a,s=(0,h.useContext)(tN),c=(0,h.useMemo)(function(){return t.controller||new e1},[]),u=(0,h.useMemo)(function(){return new eX(null,{touchAction:t.touchAction,recognizerOptions:t.eventRecognizerOptions})},[]),l=(0,h.useRef)(null),p=(0,h.useRef)(null),f=(0,h.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;f.props=t,f.map=p.current&&p.current.getMap(),f.setState=function(e){f.state=e4(e4({},f.state),e),l.current.style.cursor=t.getCursor(f.state)};var d=!0,v=function(t,e,r){if(d){n=[t,e,r];return}var i=f.props,o=i.onViewStateChange,a=i.onViewportChange;Object.defineProperty(t,"position",{get:function(){return[0,0,tV(f.map,t)]}}),o&&o({viewState:t,interactionState:e,oldViewState:r}),a&&a(t,e,r)};(0,h.useImperativeHandle)(e,function(){return{getMap:p.current&&p.current.getMap,queryRenderedFeatures:p.current&&p.current.queryRenderedFeatures}},[]);var g=(0,h.useMemo)(function(){return e4(e4({},s),{},{eventManager:u,container:s.container||l.current})},[s,l.current]);g.onViewportChange=v,g.viewport=s.viewport||tq(f),f.viewport=g.viewport;var m=function(t){var e=t.isDragging,n=void 0!==e&&e;if(n!==f.state.isDragging&&f.setState({isDragging:n}),d){a=t;return}var r=f.props.onInteractionStateChange;r&&r(t)},b=function(){f.width&&f.height&&c.setOptions(e4(e4(e4({},f.props),f.props.viewState),{},{isInteractive:Boolean(f.props.onViewStateChange||f.props.onViewportChange),onViewportChange:v,onStateChange:m,eventManager:u,width:f.width,height:f.height}))},y=function(t){var e=t.width,n=t.height;f.width=e,f.height=n,b(),f.props.onResize({width:e,height:n})};(0,h.useEffect)(function(){return u.setElement(l.current),u.on({pointerdown:nt.bind(f),pointermove:nn.bind(f),pointerup:ne.bind(f),pointerleave:e9.bind(f,"onMouseOut"),click:nr.bind(f),anyclick:nr.bind(f),dblclick:e9.bind(f,"onDblClick"),wheel:e9.bind(f,"onWheel"),contextmenu:e9.bind(f,"onContextMenu")}),function(){u.destroy()}},[]),tF(function(){if(n){var t;v.apply(void 0,function(t){if(Array.isArray(t))return i(t)}(t=n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}a&&m(a)}),b();var w=t.width,O=t.height,E=t.style,_=t.getCursor,P=(0,h.useMemo)(function(){return e4(e4({position:"relative"},E),{},{width:w,height:O,cursor:_(f.state)})},[E,w,O,_,f.state]);return n&&f._child||(f._child=h.createElement(tz,{value:g},h.createElement("div",{key:"event-canvas",ref:l,style:P},h.createElement(tK,r({},t,{width:"100%",height:"100%",style:null,onResize:y,ref:p}))))),d=!1,f._child});ni.supported=tK.supported,ni.propTypes=e3,ni.defaultProps=e8;var no=ni;p.string.isRequired,p.string,p.oneOf(["fill","line","symbol","circle","fill-extrusion","raster","background","heatmap","hillshade","sky"]).isRequired,p.string,p.string,p.string;var na={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},ns={captureScroll:p.bool,captureDrag:p.bool,captureClick:p.bool,captureDoubleClick:p.bool,capturePointerMove:p.bool};function nc(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=(0,h.useContext)(tN),n=(0,h.useRef)(null),r=(0,h.useRef)({props:t,state:{},context:e,containerRef:n}).current;return r.props=t,r.context=e,(0,h.useEffect)(function(){return function(t){var e=t.containerRef.current,n=t.context.eventManager;if(e&&n){var r={wheel:function(e){var n=t.props;n.captureScroll&&e.stopPropagation(),n.onScroll&&n.onScroll(e,t)},panstart:function(e){var n=t.props;n.captureDrag&&e.stopPropagation(),n.onDragStart&&n.onDragStart(e,t)},anyclick:function(e){var n=t.props;n.captureClick&&e.stopPropagation(),n.onNativeClick&&n.onNativeClick(e,t)},click:function(e){var n=t.props;n.captureClick&&e.stopPropagation(),n.onClick&&n.onClick(e,t)},dblclick:function(e){var n=t.props;n.captureDoubleClick&&e.stopPropagation(),n.onDoubleClick&&n.onDoubleClick(e,t)},pointermove:function(e){var n=t.props;n.capturePointerMove&&e.stopPropagation(),n.onPointerMove&&n.onPointerMove(e,t)}};return n.watch(r,e),function(){n.off(r)}}}(r)},[e.eventManager]),r}function nu(t){var e=t.instance,n=nc(t),r=n.context,i=n.containerRef;return e._context=r,e._containerRef=i,e._render()}var nl=function(t){t0(i,t);var e,n=(e=function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,n=t4(i);if(e){var r=t4(this).constructor;t=Reflect.construct(n,arguments,r)}else t=n.apply(this,arguments);return t2(this,t)});function i(){var t;tu(this,i);for(var e=arguments.length,r=Array(e),o=0;o2&&void 0!==arguments[2]?arguments[2]:"x";if(null===t)return e;var r="x"===n?t.offsetWidth:t.offsetHeight;return ny(e/100*r)/r*100};function nO(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}var nE=Object.assign({},nf,{className:p.string,longitude:p.number.isRequired,latitude:p.number.isRequired,style:p.object}),n_=Object.assign({},nd,{className:""});function nP(t){var e,n,r,i,o,s,c,u=(n=(e=f((0,h.useState)(null),2))[0],r=e[1],o=(i=f((0,h.useState)(null),2))[0],s=i[1],(c=nc(np(np({},t),{},{onDragStart:nm}))).callbacks=t,c.state.dragPos=n,c.state.setDragPos=r,c.state.dragOffset=o,c.state.setDragOffset=s,(0,h.useEffect)(function(){return function(t){var e=t.context.eventManager;if(e&&t.state.dragPos){var n={panmove:function(e){return function(t,e){var n=e.props,r=e.callbacks,i=e.state,o=e.context;t.stopPropagation();var a=nv(t);i.setDragPos(a);var s=i.dragOffset;if(r.onDrag&&s){var c=Object.assign({},t);c.lngLat=ng(a,s,n,o),r.onDrag(c)}}(e,t)},panend:function(e){return function(t,e){var n=e.props,r=e.callbacks,i=e.state,o=e.context;t.stopPropagation();var a=i.dragPos,s=i.dragOffset;if(i.setDragPos(null),i.setDragOffset(null),r.onDragEnd&&a&&s){var c=Object.assign({},t);c.lngLat=ng(a,s,n,o),r.onDragEnd(c)}}(e,t)},pancancel:function(e){var n;return n=t.state,void(e.stopPropagation(),n.setDragPos(null),n.setDragOffset(null))}};return e.watch(n),function(){e.off(n)}}}(c)},[c.context.eventManager,Boolean(n)]),c),l=u.state,p=u.containerRef,d=t.children,v=t.className,g=t.draggable,m=t.style,b=l.dragPos,y=function(t){var e=t.props,n=t.state,r=t.context,i=e.longitude,o=e.latitude,a=e.offsetLeft,s=e.offsetTop,c=n.dragPos,u=n.dragOffset,l=r.viewport,h=r.map;if(c&&u)return[c[0]+u[0],c[1]+u[1]];var p=tV(h,{longitude:i,latitude:o}),d=l.project([i,o,p]),v=f(d,2),g=v[0],m=v[1];return[g+=a,m+=s]}(u),w=f(y,2),O=w[0],E=w[1],_="translate(".concat(ny(O),"px, ").concat(ny(E),"px)"),P=g?b?"grabbing":"grab":"auto",M=(0,h.useMemo)(function(){var t=function(t){for(var e=1;e0){var g=p,m=v;for(p=0;p<=1;p+=.5)d=(f=n-p*a)+a,(v=Math.max(0,u-f)+Math.max(0,d-i+u))0){var E=h,_=O;for(h=0;h<=1;h+=b)w=(y=e-h*o)+o,(O=Math.max(0,u-y)+Math.max(0,w-r+u))<_&&(_=O,E=h);h=E}return nj.find(function(t){var e=nM[t];return e.x===h&&e.y===p})||s}({x:r,y:i,anchor:o,padding:s,width:S.width,height:S.height,selfWidth:e.clientWidth,selfHeight:e.clientHeight}):o),z=(c=M.current,l=(u=f(L,3))[0],p=u[1],d=u[2],v=t.offsetLeft,g=t.offsetTop,m=t.sortByDepth,y=nw(c,-(100*(b=nM[N]).x)),w=nw(c,-(100*b.y),"y"),O={position:"absolute",transform:"\n translate(".concat(y,"%, ").concat(w,"%)\n translate(").concat(ny(l+v),"px, ").concat(ny(p+g),"px)\n "),display:void 0,zIndex:void 0},m&&(d>1||d<-1||l<0||l>S.width||p<0||p>S.height?O.display="none":O.zIndex=Math.floor((1-d)/2*1e5)),O),F=(0,h.useCallback)(function(t){_.props.onClose();var e=_.context.eventManager;e&&e.once("click",function(t){return t.stopPropagation()},t.target)},[]);return h.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(N," ").concat(k),style:z,ref:M},h.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:C}}),h.createElement("div",{key:"content",ref:E,className:"mapboxgl-popup-content"},R&&h.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:F},"\xd7"),A))}function nx(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}nk.propTypes=nS,nk.defaultProps=nT,h.memo(nk);var nD=Object.assign({},ns,{toggleLabel:p.string,className:p.string,style:p.object,compact:p.bool,customAttribution:p.oneOfType([p.string,p.arrayOf(p.string)])}),nC=Object.assign({},na,{className:"",toggleLabel:"Toggle Attribution"});function nR(t){var e=nc(t),n=e.context,r=e.containerRef,i=(0,h.useRef)(null),o=f((0,h.useState)(!1),2),s=o[0],c=o[1];(0,h.useEffect)(function(){var e,o,a,s,c,u;return n.map&&(o={customAttribution:t.customAttribution},a=n.map,s=r.current,c=i.current,(u=new(tM()).AttributionControl(o))._map=a,u._container=s,u._innerContainer=c,u._updateAttributions(),u._updateEditLink(),a.on("styledata",u._updateData),a.on("sourcedata",u._updateData),e=u),function(){return e&&void(e._map.off("styledata",e._updateData),e._map.off("sourcedata",e._updateData))}},[n.map]);var u=void 0===t.compact?n.viewport.width<=640:t.compact;(0,h.useEffect)(function(){!u&&s&&c(!1)},[u]);var l=(0,h.useCallback)(function(){return c(function(t){return!t})},[]),p=(0,h.useMemo)(function(){return function(t){for(var e=1;ea)return 1}return 0}(o.map.version,"1.6.0")>=0?2:1:2},[o.map]),n=o.viewport.bearing,r={transform:"rotate(".concat(-n,"deg)")},2===e?h.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:r}):h.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:r})))))}function nG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}nK.propTypes=nH,nK.defaultProps=nW,h.memo(nK);var n$=Object.assign({},ns,{className:p.string,style:p.object,maxWidth:p.number,unit:p.oneOf(["imperial","metric","nautical"])}),nJ=Object.assign({},na,{className:"",maxWidth:100,unit:"metric"});function nQ(t){var e=nc(t),n=e.context,r=e.containerRef,i=f((0,h.useState)(null),2),o=i[0],s=i[1];(0,h.useEffect)(function(){if(n.map){var t=new(tM()).ScaleControl;t._map=n.map,t._container=r.current,s(t)}},[n.map]),o&&(o.options=t,o._onMove());var c=(0,h.useMemo)(function(){return function(t){for(var e=1;e. Did you mean "together", "forwards" or "backwards"?', revealOrder); } - }(revealOrder), tailMode1 = tailMode, revealOrder1 = revealOrder, void 0 === tailMode1 || didWarnAboutTailOptions[tailMode1] || ("collapsed" !== tailMode1 && "hidden" !== tailMode1 ? (didWarnAboutTailOptions[tailMode1] = !0, error('"%s" is not a supported value for tail on . Did you mean "collapsed" or "hidden"?', tailMode1)) : "forwards" !== revealOrder1 && "backwards" !== revealOrder1 && (didWarnAboutTailOptions[tailMode1] = !0, error(' is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?', tailMode1))), function(children, revealOrder) { + }(revealOrder), void 0 === tailMode || didWarnAboutTailOptions[tailMode] || ("collapsed" !== tailMode && "hidden" !== tailMode ? (didWarnAboutTailOptions[tailMode] = !0, error('"%s" is not a supported value for tail on . Did you mean "collapsed" or "hidden"?', tailMode)) : "forwards" !== revealOrder && "backwards" !== revealOrder && (didWarnAboutTailOptions[tailMode] = !0, error(' is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?', tailMode))), function(children, revealOrder) { if (("forwards" === revealOrder || "backwards" === revealOrder) && null != children && !1 !== children) { if (Array.isArray(children)) { for(var i = 0; i < children.length; i++)if (!validateSuspenseListNestedChild(children[i], i)) return; @@ -6730,22 +6730,22 @@ return workInProgress.child; }(current, workInProgress, renderLanes); case 5: - return current2 = current, workInProgress2 = workInProgress, renderLanes2 = renderLanes, pushHostContext(workInProgress2), null === current2 && tryToClaimNextHydratableInstance(workInProgress2), type1 = workInProgress2.type, nextProps = workInProgress2.pendingProps, prevProps = null !== current2 ? current2.memoizedProps : null, nextChildren = nextProps.children, shouldSetTextContent(type1, nextProps) ? nextChildren = null : null !== prevProps && shouldSetTextContent(type1, prevProps) && (workInProgress2.flags |= 16), markRef(current2, workInProgress2), reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2), workInProgress2.child; + return workInProgress2 = workInProgress, pushHostContext(workInProgress2), null === current && tryToClaimNextHydratableInstance(workInProgress2), type1 = workInProgress2.type, nextProps = workInProgress2.pendingProps, prevProps = null !== current ? current.memoizedProps : null, nextChildren = nextProps.children, shouldSetTextContent(type1, nextProps) ? nextChildren = null : null !== prevProps && shouldSetTextContent(type1, prevProps) && (workInProgress2.flags |= 16), markRef(current, workInProgress2), reconcileChildren(current, workInProgress2, nextChildren, renderLanes), workInProgress2.child; case 6: - return current3 = current, workInProgress3 = workInProgress, null === current3 && tryToClaimNextHydratableInstance(workInProgress3), null; + return null === current && tryToClaimNextHydratableInstance(workInProgress), null; case 13: return updateSuspenseComponent(current, workInProgress, renderLanes); case 4: - return current4 = current, workInProgress4 = workInProgress, renderLanes3 = renderLanes, pushHostContainer(workInProgress4, workInProgress4.stateNode.containerInfo), nextChildren1 = workInProgress4.pendingProps, null === current4 ? workInProgress4.child = reconcileChildFibers(workInProgress4, null, nextChildren1, renderLanes3) : reconcileChildren(current4, workInProgress4, nextChildren1, renderLanes3), workInProgress4.child; + return workInProgress4 = workInProgress, pushHostContainer(workInProgress4, workInProgress4.stateNode.containerInfo), nextChildren1 = workInProgress4.pendingProps, null === current ? workInProgress4.child = reconcileChildFibers(workInProgress4, null, nextChildren1, renderLanes) : reconcileChildren(current, workInProgress4, nextChildren1, renderLanes), workInProgress4.child; case 11: var type = workInProgress.type, _unresolvedProps2 = workInProgress.pendingProps, _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2); return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderLanes); case 7: - return current5 = current, workInProgress5 = workInProgress, renderLanes4 = renderLanes, nextChildren2 = workInProgress5.pendingProps, reconcileChildren(current5, workInProgress5, nextChildren2, renderLanes4), workInProgress5.child; + return nextChildren2 = workInProgress.pendingProps, reconcileChildren(current, workInProgress, nextChildren2, renderLanes), workInProgress.child; case 8: - return current6 = current, workInProgress6 = workInProgress, renderLanes5 = renderLanes, nextChildren3 = workInProgress6.pendingProps.children, reconcileChildren(current6, workInProgress6, nextChildren3, renderLanes5), workInProgress6.child; + return nextChildren3 = workInProgress.pendingProps.children, reconcileChildren(current, workInProgress, nextChildren3, renderLanes), workInProgress.child; case 12: - return current7 = current, workInProgress7 = workInProgress, renderLanes6 = renderLanes, workInProgress7.flags |= 4, (stateNode1 = workInProgress7.stateNode).effectDuration = 0, stateNode1.passiveEffectDuration = 0, nextChildren4 = workInProgress7.pendingProps.children, reconcileChildren(current7, workInProgress7, nextChildren4, renderLanes6), workInProgress7.child; + return workInProgress7 = workInProgress, workInProgress7.flags |= 4, (stateNode1 = workInProgress7.stateNode).effectDuration = 0, stateNode1.passiveEffectDuration = 0, nextChildren4 = workInProgress7.pendingProps.children, reconcileChildren(current, workInProgress7, nextChildren4, renderLanes), workInProgress7.child; case 10: return function(current, workInProgress, renderLanes) { var context = workInProgress.type._context, newProps = workInProgress.pendingProps, oldProps = workInProgress.memoizedProps, newValue = newProps.value; @@ -7115,12 +7115,12 @@ if ("string" != typeof newProps && !(null !== workInProgress.stateNode)) throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."); var hostInst1, node2, text, rootContainerInstance4, hostContext2, internalInstanceHandle, text1, rootContainerElement, textNode, _rootContainerInstance = getRootHostContainer(), _currentHostContext = getHostContext(); if (popHydrationState(workInProgress)) (function(fiber) { - var textInstance = fiber.stateNode, textContent = fiber.memoizedProps, shouldUpdate = (textInstance1 = textInstance, text = textContent, hostInst = fiber, (node = textInstance1)[internalInstanceKey] = hostInst, textNode = textInstance1, text1 = text, textNode.nodeValue !== text1); + var textInstance = fiber.stateNode, textContent = fiber.memoizedProps, shouldUpdate = (hostInst = fiber, (node = textInstance)[internalInstanceKey] = hostInst, textInstance.nodeValue !== textContent); if (shouldUpdate) { var returnFiber = hydrationParentFiber; if (null !== returnFiber) switch(returnFiber.tag){ case 3: - returnFiber.stateNode.containerInfo, warnForUnmatchedText(textInstance2 = textInstance, textContent); + returnFiber.stateNode.containerInfo, warnForUnmatchedText(textInstance, textContent); break; case 5: var hostInst, node, textInstance1, text, textNode, text1, parentContainer, textInstance2, parentType, parentProps, parentInstance, textInstance3, text2, parentType1 = returnFiber.type, parentProps1 = returnFiber.memoizedProps, parentInstance1 = returnFiber.stateNode; @@ -7783,7 +7783,7 @@ ]) : rootsWithPendingDiscreteUpdates.add(root)), ensureRootIsScheduled(root, eventTime), schedulePendingInteractions(root, lane)), mostRecentlyUpdatedRoot = root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { - sourceFiber.lanes = (a = sourceFiber.lanes, b = lane, a | b); + sourceFiber.lanes = (a = sourceFiber.lanes) | lane; var a, b, a1, b1, a2, b2, a3, b3, alternate = sourceFiber.alternate; null !== alternate && (alternate.lanes = (a1 = alternate.lanes, b1 = lane, a1 | b1)), null === alternate && (1026 & sourceFiber.flags) != 0 && warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); for(var node = sourceFiber, parent = sourceFiber.return; null !== parent;)(parent.childLanes = (a2 = parent.childLanes, b2 = lane, a2 | b2), null !== (alternate = parent.alternate)) ? alternate.childLanes = (a3 = alternate.childLanes, b3 = lane, a3 | b3) : (1026 & parent.flags) != 0 && warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber), node = parent, parent = parent.return; @@ -9050,7 +9050,7 @@ var lane = requestUpdateLane(current$1), context = function(parentComponent) { if (!parentComponent) return emptyContextObject; var fiber = get(parentComponent), parentContext = function(fiber) { - if (!(getNearestMountedFiber(fiber1 = fiber) === fiber1 && 1 === fiber.tag)) throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."); + if (!(getNearestMountedFiber(fiber) === fiber && 1 === fiber.tag)) throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."); var fiber1, node = fiber; do { switch(node.tag){