From e9fabd61e883edc9089cd7ddca44fda5e387b3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Sun, 20 Feb 2022 21:08:26 +0900 Subject: [PATCH] feat(es/minifier): Improve name mangler (#3638) --- .../tests/fixture/issue-2000/output/index.js | 2 +- .../tests/fixture/issue-2086/output/index.ts | 2 +- .../fixture/sourcemap/004/output/index.js | 6 +- .../full-compact/d3-color/1/output/index.js | 2 +- .../react-autosuggest/1/output/index.js | 2 +- .../vercel/full/d3-color/1/output/index.js | 34 +- .../full/d3-time-format/1/output/index.js | 282 +- .../full/firebase/dist/1/output/index.js | 116 +- .../tests/vercel/full/ms/1/output/index.ts | 34 +- .../vercel/full/next-31419/1/output/index.js | 14 +- .../vercel/full/next-31419/2/output/index.js | 30 +- .../vercel/full/next-33088/output/index.js | 14 +- .../full/react-autowhatever/1/output/index.js | 170 +- .../full/react-autowhatever/2/output/index.js | 152 +- .../react-instantsearch/2/output/index.js | 188 +- .../vercel/full/var-scpoing/1/output/index.js | 4 +- .../src/pass/compute_char_freq.rs | 75 +- .../src/pass/mangle_names/analyzer/mod.rs | 24 +- .../src/pass/mangle_names/analyzer/scope.rs | 28 +- .../src/pass/mangle_names/private_name.rs | 4 +- .../src/pass/mangle_names/real_impl.rs | 9 +- .../src/pass/mangle_props.rs | 4 +- crates/swc_ecma_minifier/src/util/base54.rs | 14 +- .../2c796e83-0724e2af5f19128a/output.js | 2 +- .../785-e1932cc99ac3bb67/output.js | 2 +- .../pages/index-d4b892cd7cdbfcba/output.js | 2 +- .../tests/full/next-30498/1/output.js | 2 +- .../tests/full/next-33088/output.js | 6 +- .../tests/full/vercel/ms/1/output.js | 2 +- .../tests/mangle/1/output.js | 22 +- .../tests/mangle/2/output.js | 6 +- .../tests/mangle/reuse/1/output.js | 8 +- .../tests/mangle/reuse/2/output.js | 214 +- .../tests/mangle/reuse/3/output.js | 2516 ++++++++--------- .../compress/export/dynamic_import/output.js | 8 +- .../rename/function_catch_catch/output.js | 8 +- .../broken_safari_catch_scope/output.js | 6 +- .../output.js | 6 +- 38 files changed, 2062 insertions(+), 1958 deletions(-) diff --git a/crates/swc/tests/fixture/issue-2000/output/index.js b/crates/swc/tests/fixture/issue-2000/output/index.js index 301cfb34a57..509281e97b9 100644 --- a/crates/swc/tests/fixture/issue-2000/output/index.js +++ b/crates/swc/tests/fixture/issue-2000/output/index.js @@ -1 +1 @@ -export function testme(){for(var a=arguments.length,b=new Array(a),c=0;c{this.#a.textContent="TESTED"},1e3)}run(){this.#b()}}export{a as default} +class a{#a;constructor(a){this.#a=a} #b(){setTimeout(()=>{this.#a.textContent="TESTED"},1e3)}run(){this.#b()}}export{a as default} diff --git a/crates/swc/tests/fixture/sourcemap/004/output/index.js b/crates/swc/tests/fixture/sourcemap/004/output/index.js index 3810abe9b8e..8da353be4b4 100644 --- a/crates/swc/tests/fixture/sourcemap/004/output/index.js +++ b/crates/swc/tests/fixture/sourcemap/004/output/index.js @@ -3,7 +3,7 @@ 158 ], { - 2943: function(a, b, c) { + 2943: function(c, b, a) { "use strict"; var d = function(a) { var b = a.data; @@ -11,7 +11,7 @@ children: b.foo }); }; - c.r(b), c.d(b, { + a.r(b), a.d(b, { "__N_SSG": function() { return f; }, @@ -19,7 +19,7 @@ return d; } }); - var e = c(4512), f = !0; + var e = a(4512), f = !0; }, 7139: function(a, b, c) { (window.__NEXT_P = window.__NEXT_P || []).push([ diff --git a/crates/swc/tests/vercel/full-compact/d3-color/1/output/index.js b/crates/swc/tests/vercel/full-compact/d3-color/1/output/index.js index 2ad83d1f74b..0cdb3a3f596 100644 --- a/crates/swc/tests/vercel/full-compact/d3-color/1/output/index.js +++ b/crates/swc/tests/vercel/full-compact/d3-color/1/output/index.js @@ -1 +1 @@ -import*as a from"@swc/helpers";import{Color as b,rgbConvert as c,Rgb as d}from"./color.js";var e=Math.PI/180,f=180/Math.PI,g=-0.5210501878999999-.1347134789;export default function h(b,e,h,i){return 1===arguments.length?(function(b){if(a._instanceof(b,Cubehelix))return new Cubehelix(b.h,b.s,b.l,b.opacity);a._instanceof(b,d)||(b=c(b));var e=b.r/255,h=b.g/255,i=b.b/255,j=(g*i+ -1.7884503806*e-3.5172982438*h)/(g+ -1.7884503806-3.5172982438),k=i-j,l=-((1.97294*(h-j)- -0.29227*k)/.90649),m=Math.sqrt(l*l+k*k)/(1.97294*j*(1-j)),n=m?Math.atan2(l,k)*f-120:NaN;return new Cubehelix(n<0?n+360:n,m,j,b.opacity)})(b):new Cubehelix(b,e,h,null==i?1:i)};export function Cubehelix(a,b,c,d){this.h=+a,this.s=+b,this.l=+c,this.opacity=+d}!function(a,b,c){a.prototype=b.prototype=c,c.constructor=a}(Cubehelix,h,function(a,b){var c=Object.create(a.prototype);for(var d in b)c[d]=b[d];return c}(b,{brighter:function(a){return a=null==a?1.4285714285714286:Math.pow(1.4285714285714286,a),new Cubehelix(this.h,this.s,this.l*a,this.opacity)},darker:function(a){return a=null==a?.7:Math.pow(.7,a),new Cubehelix(this.h,this.s,this.l*a,this.opacity)},rgb:function(){var a=isNaN(this.h)?0:(this.h+120)*e,b=+this.l,c=isNaN(this.s)?0:this.s*b*(1-b),f=Math.cos(a),g=Math.sin(a);return new d(255*(b+c*(-0.14861*f+1.78277*g)),255*(b+c*(-0.29227*f+ -0.90649*g)),255*(b+c*(1.97294*f)),this.opacity)}})) +import*as c from"@swc/helpers";import{Color as a,rgbConvert as d,Rgb as e}from"./color.js";var f=Math.PI/180,g=180/Math.PI,h=-0.5210501878999999-.1347134789;export default function b(a,f,i,b){return 1===arguments.length?(function(a){if(c._instanceof(a,Cubehelix))return new Cubehelix(a.h,a.s,a.l,a.opacity);c._instanceof(a,e)||(a=d(a));var n=a.r/255,k=a.g/255,l=a.b/255,b=(h*l+ -1.7884503806*n-3.5172982438*k)/(h+ -1.7884503806-3.5172982438),f=l-b,i=-((1.97294*(k-b)- -0.29227*f)/.90649),m=Math.sqrt(i*i+f*f)/(1.97294*b*(1-b)),j=m?Math.atan2(i,f)*g-120:NaN;return new Cubehelix(j<0?j+360:j,m,b,a.opacity)})(a):new Cubehelix(a,f,i,null==b?1:b)};export function Cubehelix(a,b,c,d){this.h=+a,this.s=+b,this.l=+c,this.opacity=+d}!function(a,c,b){a.prototype=c.prototype=b,b.constructor=a}(Cubehelix,b,function(d,a){var b=Object.create(d.prototype);for(var c in a)b[c]=a[c];return b}(a,{brighter:function(a){return a=null==a?1.4285714285714286:Math.pow(1.4285714285714286,a),new Cubehelix(this.h,this.s,this.l*a,this.opacity)},darker:function(a){return a=null==a?.7:Math.pow(.7,a),new Cubehelix(this.h,this.s,this.l*a,this.opacity)},rgb:function(){var d=isNaN(this.h)?0:(this.h+120)*f,a=+this.l,b=isNaN(this.s)?0:this.s*a*(1-a),c=Math.cos(d),g=Math.sin(d);return new e(255*(a+b*(-0.14861*c+1.78277*g)),255*(a+b*(-0.29227*c+ -0.90649*g)),255*(a+b*(1.97294*c)),this.opacity)}})) diff --git a/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js b/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js index 2655171b7af..f60c34a6307 100644 --- a/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js +++ b/crates/swc/tests/vercel/full-compact/react-autosuggest/1/output/index.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var a=function(a){if(a&&a.__esModule)return a;if(null===a||"object"!==d(a)&&"function"!=typeof a)return{"default":a};var b=c();if(b&&b.has(a))return b.get(a);var e={},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in a)if(Object.prototype.hasOwnProperty.call(a,g)){var h=f?Object.getOwnPropertyDescriptor(a,g):null;h&&(h.get||h.set)?Object.defineProperty(e,g,h):e[g]=a[g]}return e.default=a,b&&b.set(a,e),e}(require("react")),b=function(a){return a&&a.__esModule?a:{"default":a}}(require("prop-types"));function c(){if("function"!=typeof WeakMap)return null;var a=new WeakMap();return c=function(){return a},a}function d(a){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function e(){return(e=Object.assign||function(a){for(var b=1;b 53) return null; - "w" in k || (k.w = 1), "Z" in k ? (f = (j = (f = m(n(k.y, 0, 1))).getUTCDay()) > 4 || 0 === j ? i.ceil(f) : i(f), f = g.offset(f, (k.V - 1) * 7), k.y = f.getUTCFullYear(), k.m = f.getUTCMonth(), k.d = f.getUTCDate() + (k.w + 6) % 7) : (f = (j = (f = l(n(k.y, 0, 1))).getDay()) > 4 || 0 === j ? d.ceil(f) : d(f), f = b.offset(f, (k.V - 1) * 7), k.y = f.getFullYear(), k.m = f.getMonth(), k.d = f.getDate() + (k.w + 6) % 7); - } else ("W" in k || "U" in k) && ("w" in k || (k.w = "u" in k ? k.u % 7 : "W" in k ? 1 : 0), j = "Z" in k ? m(n(k.y, 0, 1)).getUTCDay() : l(n(k.y, 0, 1)).getDay(), k.m = 0, k.d = "W" in k ? (k.w + 6) % 7 + 7 * k.W - (j + 5) % 7 : k.w + 7 * k.U - (j + 6) % 7); - return "Z" in k ? (k.H += k.Z / 100 | 0, k.M += k.Z % 100, m(k)) : l(k); + }, aa = function(a, c) { + return function(j) { + var f, h, e = n(1900, void 0, 1); + if (ua(e, a, j += "", 0) != j.length) return null; + if ("Q" in e) return new Date(e.Q); + if ("s" in e) return new Date(1000 * e.s + ("L" in e ? e.L : 0)); + if (!c || "Z" in e || (e.Z = 0), "p" in e && (e.H = e.H % 12 + 12 * e.p), void 0 === e.m && (e.m = "q" in e ? e.q : 0), "V" in e) { + if (e.V < 1 || e.V > 53) return null; + "w" in e || (e.w = 1), "Z" in e ? (f = (h = (f = m(n(e.y, 0, 1))).getUTCDay()) > 4 || 0 === h ? i.ceil(f) : i(f), f = g.offset(f, (e.V - 1) * 7), e.y = f.getUTCFullYear(), e.m = f.getUTCMonth(), e.d = f.getUTCDate() + (e.w + 6) % 7) : (f = (h = (f = l(n(e.y, 0, 1))).getDay()) > 4 || 0 === h ? d.ceil(f) : d(f), f = b.offset(f, (e.V - 1) * 7), e.y = f.getFullYear(), e.m = f.getMonth(), e.d = f.getDate() + (e.w + 6) % 7); + } else ("W" in e || "U" in e) && ("w" in e || (e.w = "u" in e ? e.u % 7 : "W" in e ? 1 : 0), h = "Z" in e ? m(n(e.y, 0, 1)).getUTCDay() : l(n(e.y, 0, 1)).getDay(), e.m = 0, e.d = "W" in e ? (e.w + 6) % 7 + 7 * e.W - (h + 5) % 7 : e.w + 7 * e.U - (h + 6) % 7); + return "Z" in e ? (e.H += e.Z / 100 | 0, e.M += e.Z % 100, m(e)) : l(e); }; - }, h = function(a, b, c, d) { - for(var e, f, g = 0, h = b.length, i = c.length; g < h;){ - if (d >= i) return -1; - if (37 === (e = b.charCodeAt(g++))) { - if (!(f = Qa[(e = b.charAt(g++)) in p ? b.charAt(g++) : e]) || (d = f(a, c, d)) < 0) return -1; - } else if (e != c.charCodeAt(d++)) return -1; + }, ua = function(g, b, e, a) { + for(var c, f, d = 0, h = b.length, i = e.length; d < h;){ + if (a >= i) return -1; + if (37 === (c = b.charCodeAt(d++))) { + if (!(f = Qa[(c = b.charAt(d++)) in p ? b.charAt(d++) : c]) || (a = f(g, e, a)) < 0) return -1; + } else if (c != e.charCodeAt(a++)) return -1; } - return d; - }, j = c.dateTime, k = c.date, o = c.time, q = c.periods, r = c.days, s = c.shortDays, t = c.months, u = c.shortMonths, aa = v(q), ua = w(q), Ga = v(r), Ha = w(r), Ia = v(s), Ja = w(s), Ka = v(t), La = w(t), Ma = v(u), Na = w(u), Oa = { + return a; + }, j = c.dateTime, k = c.date, o = c.time, q = c.periods, r = c.days, s = c.shortDays, t = c.months, u = c.shortMonths, Ga = v(q), Ha = w(q), Ia = v(r), Ja = w(r), Ka = v(s), La = w(s), Ma = v(t), Na = w(t), Oa = v(u), Pa = w(u), f = { a: function(a) { return s[a.getDay()]; }, @@ -97,7 +97,7 @@ export default function o(c) { Y: ga, Z: ia, "%": Da - }, Pa = { + }, h = { a: function(a) { return s[a.getUTCDay()]; }, @@ -143,24 +143,24 @@ export default function o(c) { Z: Ca, "%": Da }, Qa = { - a: function(a, b, c) { - var d = Ia.exec(b.slice(c)); - return d ? (a.w = Ja.get(d[0].toLowerCase()), c + d[0].length) : -1; + a: function(c, d, b) { + var a = Ka.exec(d.slice(b)); + return a ? (c.w = La.get(a[0].toLowerCase()), b + a[0].length) : -1; }, - A: function(a, b, c) { - var d = Ga.exec(b.slice(c)); - return d ? (a.w = Ha.get(d[0].toLowerCase()), c + d[0].length) : -1; + A: function(c, d, b) { + var a = Ia.exec(d.slice(b)); + return a ? (c.w = Ja.get(a[0].toLowerCase()), b + a[0].length) : -1; }, - b: function(a, b, c) { - var d = Ma.exec(b.slice(c)); - return d ? (a.m = Na.get(d[0].toLowerCase()), c + d[0].length) : -1; + b: function(c, d, b) { + var a = Oa.exec(d.slice(b)); + return a ? (c.m = Pa.get(a[0].toLowerCase()), b + a[0].length) : -1; }, - B: function(a, b, c) { - var d = Ka.exec(b.slice(c)); - return d ? (a.m = La.get(d[0].toLowerCase()), c + d[0].length) : -1; + B: function(c, d, b) { + var a = Ma.exec(d.slice(b)); + return a ? (c.m = Na.get(a[0].toLowerCase()), b + a[0].length) : -1; }, c: function(a, b, c) { - return h(a, j, b, c); + return ua(a, j, b, c); }, d: H, e: H, @@ -173,9 +173,9 @@ export default function o(c) { L: M, m: G, M: K, - p: function(a, b, c) { - var d = aa.exec(b.slice(c)); - return d ? (a.p = ua.get(d[0].toLowerCase()), c + d[0].length) : -1; + p: function(c, d, b) { + var a = Ga.exec(d.slice(b)); + return a ? (c.p = Ha.get(a[0].toLowerCase()), b + a[0].length) : -1; }, q: F, Q: P, @@ -187,40 +187,40 @@ export default function o(c) { w: x, W: B, x: function(a, b, c) { - return h(a, k, b, c); + return ua(a, k, b, c); }, X: function(a, b, c) { - return h(a, o, b, c); + return ua(a, o, b, c); }, y: D, Y: C, Z: E, "%": O }; - return Oa.x = e(k, Oa), Oa.X = e(o, Oa), Oa.c = e(j, Oa), Pa.x = e(k, Pa), Pa.X = e(o, Pa), Pa.c = e(j, Pa), { - format: function(a) { - var b = e(a += "", Oa); - return b.toString = function() { - return a; - }, b; + return f.x = e(k, f), f.X = e(o, f), f.c = e(j, f), h.x = e(k, h), h.X = e(o, h), h.c = e(j, h), { + format: function(b) { + var a = e(b += "", f); + return a.toString = function() { + return b; + }, a; }, - parse: function(a) { - var b = f(a += "", !1); - return b.toString = function() { - return a; - }, b; + parse: function(b) { + var a = aa(b += "", !1); + return a.toString = function() { + return b; + }, a; }, - utcFormat: function(a) { - var b = e(a += "", Pa); - return b.toString = function() { - return a; - }, b; + utcFormat: function(b) { + var a = e(b += "", h); + return a.toString = function() { + return b; + }, a; }, - utcParse: function(a) { - var b = f(a += "", !0); - return b.toString = function() { - return a; - }, b; + utcParse: function(b) { + var a = aa(b += "", !0); + return a.toString = function() { + return b; + }, a; } }; }; @@ -229,9 +229,9 @@ var p = { "_": " ", "0": "0" }, q = /^\s*\d+/, r = /^%/, s = /[\\^$*+?|[\]().{}]/g; -function t(a, b, c) { - var d = a < 0 ? "-" : "", e = (d ? -a : a) + "", f = e.length; - return d + (f < c ? new Array(c - f + 1).join(b) + e : e); +function t(a, f, c) { + var d = a < 0 ? "-" : "", b = (d ? -a : a) + "", e = b.length; + return d + (e < c ? new Array(c - e + 1).join(f) + b : b); } function u(a) { return a.replace(s, "\\$&"); @@ -247,85 +247,85 @@ function w(a) { ]; })); } -function x(a, b, c) { - var d = q.exec(b.slice(c, c + 1)); - return d ? (a.w = +d[0], c + d[0].length) : -1; +function x(c, d, a) { + var b = q.exec(d.slice(a, a + 1)); + return b ? (c.w = +b[0], a + b[0].length) : -1; } -function y(a, b, c) { - var d = q.exec(b.slice(c, c + 1)); - return d ? (a.u = +d[0], c + d[0].length) : -1; +function y(c, d, a) { + var b = q.exec(d.slice(a, a + 1)); + return b ? (c.u = +b[0], a + b[0].length) : -1; } -function z(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.U = +d[0], c + d[0].length) : -1; +function z(c, d, a) { + var b = q.exec(d.slice(a, a + 2)); + return b ? (c.U = +b[0], a + b[0].length) : -1; } -function A(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.V = +d[0], c + d[0].length) : -1; +function A(c, d, a) { + var b = q.exec(d.slice(a, a + 2)); + return b ? (c.V = +b[0], a + b[0].length) : -1; } -function B(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.W = +d[0], c + d[0].length) : -1; +function B(c, d, a) { + var b = q.exec(d.slice(a, a + 2)); + return b ? (c.W = +b[0], a + b[0].length) : -1; } -function C(a, b, c) { - var d = q.exec(b.slice(c, c + 4)); - return d ? (a.y = +d[0], c + d[0].length) : -1; +function C(c, d, a) { + var b = q.exec(d.slice(a, a + 4)); + return b ? (c.y = +b[0], a + b[0].length) : -1; } -function D(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.y = +d[0] + (+d[0] > 68 ? 1900 : 2000), c + d[0].length) : -1; +function D(c, d, b) { + var a = q.exec(d.slice(b, b + 2)); + return a ? (c.y = +a[0] + (+a[0] > 68 ? 1900 : 2000), b + a[0].length) : -1; } -function E(a, b, c) { - var d = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(b.slice(c, c + 6)); - return d ? (a.Z = d[1] ? 0 : -(d[2] + (d[3] || "00")), c + d[0].length) : -1; +function E(c, d, b) { + var a = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(d.slice(b, b + 6)); + return a ? (c.Z = a[1] ? 0 : -(a[2] + (a[3] || "00")), b + a[0].length) : -1; } -function F(a, b, c) { - var d = q.exec(b.slice(c, c + 1)); - return d ? (a.q = 3 * d[0] - 3, c + d[0].length) : -1; +function F(c, d, a) { + var b = q.exec(d.slice(a, a + 1)); + return b ? (c.q = 3 * b[0] - 3, a + b[0].length) : -1; } -function G(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.m = d[0] - 1, c + d[0].length) : -1; +function G(c, d, a) { + var b = q.exec(d.slice(a, a + 2)); + return b ? (c.m = b[0] - 1, a + b[0].length) : -1; } -function H(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.d = +d[0], c + d[0].length) : -1; +function H(c, d, a) { + var b = q.exec(d.slice(a, a + 2)); + return b ? (c.d = +b[0], a + b[0].length) : -1; } -function I(a, b, c) { - var d = q.exec(b.slice(c, c + 3)); - return d ? (a.m = 0, a.d = +d[0], c + d[0].length) : -1; +function I(c, d, a) { + var b = q.exec(d.slice(a, a + 3)); + return b ? (c.m = 0, c.d = +b[0], a + b[0].length) : -1; } -function J(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.H = +d[0], c + d[0].length) : -1; +function J(c, d, a) { + var b = q.exec(d.slice(a, a + 2)); + return b ? (c.H = +b[0], a + b[0].length) : -1; } -function K(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.M = +d[0], c + d[0].length) : -1; +function K(c, d, a) { + var b = q.exec(d.slice(a, a + 2)); + return b ? (c.M = +b[0], a + b[0].length) : -1; } -function L(a, b, c) { - var d = q.exec(b.slice(c, c + 2)); - return d ? (a.S = +d[0], c + d[0].length) : -1; +function L(c, d, a) { + var b = q.exec(d.slice(a, a + 2)); + return b ? (c.S = +b[0], a + b[0].length) : -1; } -function M(a, b, c) { - var d = q.exec(b.slice(c, c + 3)); - return d ? (a.L = +d[0], c + d[0].length) : -1; +function M(c, d, a) { + var b = q.exec(d.slice(a, a + 3)); + return b ? (c.L = +b[0], a + b[0].length) : -1; } -function N(a, b, c) { - var d = q.exec(b.slice(c, c + 6)); - return d ? (a.L = Math.floor(d[0] / 1000), c + d[0].length) : -1; +function N(c, d, a) { + var b = q.exec(d.slice(a, a + 6)); + return b ? (c.L = Math.floor(b[0] / 1000), a + b[0].length) : -1; } -function O(a, b, c) { - var d = r.exec(b.slice(c, c + 1)); - return d ? c + d[0].length : -1; +function O(d, c, a) { + var b = r.exec(c.slice(a, a + 1)); + return b ? a + b[0].length : -1; } -function P(a, b, c) { - var d = q.exec(b.slice(c)); - return d ? (a.Q = +d[0], c + d[0].length) : -1; +function P(c, d, b) { + var a = q.exec(d.slice(b)); + return a ? (c.Q = +a[0], b + a[0].length) : -1; } -function Q(a, b, c) { - var d = q.exec(b.slice(c)); - return d ? (a.s = +d[0], c + d[0].length) : -1; +function Q(c, d, b) { + var a = q.exec(d.slice(b)); + return a ? (c.s = +a[0], b + a[0].length) : -1; } function R(a, b) { return t(a.getDate(), b, 2); @@ -354,9 +354,9 @@ function Y(a, b) { function Z(a, b) { return t(a.getSeconds(), b, 2); } -function $(a) { - var b = a.getDay(); - return 0 === b ? 7 : b; +function $(b) { + var a = b.getDay(); + return 0 === a ? 7 : a; } function _(a, b) { return t(c.count(f(a) - 1, a), b, 2); @@ -383,13 +383,13 @@ function fa(a, b) { function ga(a, b) { return t(a.getFullYear() % 10000, b, 4); } -function ha(a, b) { - var c = a.getDay(); - return t((a = c >= 4 || 0 === c ? e(a) : e.ceil(a)).getFullYear() % 10000, b, 4); +function ha(a, c) { + var b = a.getDay(); + return t((a = b >= 4 || 0 === b ? e(a) : e.ceil(a)).getFullYear() % 10000, c, 4); } -function ia(a) { - var b = a.getTimezoneOffset(); - return (b > 0 ? "-" : (b *= -1, "+")) + t(b / 60 | 0, "0", 2) + t(b % 60, "0", 2); +function ia(b) { + var a = b.getTimezoneOffset(); + return (a > 0 ? "-" : (a *= -1, "+")) + t(a / 60 | 0, "0", 2) + t(a % 60, "0", 2); } function ja(a, b) { return t(a.getUTCDate(), b, 2); @@ -418,9 +418,9 @@ function qa(a, b) { function ra(a, b) { return t(a.getUTCSeconds(), b, 2); } -function sa(a) { - var b = a.getUTCDay(); - return 0 === b ? 7 : b; +function sa(b) { + var a = b.getUTCDay(); + return 0 === a ? 7 : a; } function ta(a, b) { return t(h.count(k(a) - 1, a), b, 2); @@ -447,9 +447,9 @@ function za(a, b) { function Aa(a, b) { return t(a.getUTCFullYear() % 10000, b, 4); } -function Ba(a, b) { - var c = a.getUTCDay(); - return t((a = c >= 4 || 0 === c ? j(a) : j.ceil(a)).getUTCFullYear() % 10000, b, 4); +function Ba(a, c) { + var b = a.getUTCDay(); + return t((a = b >= 4 || 0 === b ? j(a) : j.ceil(a)).getUTCFullYear() % 10000, c, 4); } function Ca() { return "+0000"; diff --git a/crates/swc/tests/vercel/full/firebase/dist/1/output/index.js b/crates/swc/tests/vercel/full/firebase/dist/1/output/index.js index 50b4d9a6a60..30e059bab49 100644 --- a/crates/swc/tests/vercel/full/firebase/dist/1/output/index.js +++ b/crates/swc/tests/vercel/full/firebase/dist/1/output/index.js @@ -1,5 +1,5 @@ "use strict"; -var a, b = require("@firebase/util"), c = require("tslib"), d = require("@firebase/component"), e = require("@firebase/app"), f = require("@firebase/logger"), g = function(a) { +var a, b = require("@firebase/util"), j = require("tslib"), k = require("@firebase/component"), c = require("@firebase/app"), f = require("@firebase/logger"), l = function(a) { if (a && a.__esModule) return a; var b = Object.create(null); return a && Object.keys(a).forEach(function(c) { @@ -13,11 +13,11 @@ var a, b = require("@firebase/util"), c = require("tslib"), d = require("@fireba }); } }), b.default = a, Object.freeze(b); -}(e), h = function() { +}(c), m = function() { var a = function(a, b) { - var c = this; - this._delegate = a, this.firebase = b, e._addComponent(a, new d.Component("app-compat", function() { - return c; + var d = this; + this._delegate = a, this.firebase = b, c._addComponent(a, new k.Component("app-compat", function() { + return d; }, "PUBLIC")), this.container = a.container; }; return Object.defineProperty(a.prototype, "automaticDataCollectionEnabled", { @@ -46,20 +46,20 @@ var a, b = require("@firebase/util"), c = require("tslib"), d = require("@fireba return new Promise(function(b) { a._delegate.checkDestroyed(), b(); }).then(function() { - return a.firebase.INTERNAL.removeApp(a.name), e.deleteApp(a._delegate); + return a.firebase.INTERNAL.removeApp(a.name), c.deleteApp(a._delegate); }); - }, a.prototype._getService = function(a, b) { - void 0 === b && (b = e._DEFAULT_ENTRY_NAME), this._delegate.checkDestroyed(); - var c, d = this._delegate.container.getProvider(a); - return d.isInitialized() || (null === (c = d.getComponent()) || void 0 === c ? void 0 : c.instantiationMode) !== "EXPLICIT" || d.initialize(), d.getImmediate({ + }, a.prototype._getService = function(e, b) { + void 0 === b && (b = c._DEFAULT_ENTRY_NAME), this._delegate.checkDestroyed(); + var d, a = this._delegate.container.getProvider(e); + return a.isInitialized() || (null === (d = a.getComponent()) || void 0 === d ? void 0 : d.instantiationMode) !== "EXPLICIT" || a.initialize(), a.getImmediate({ identifier: b }); - }, a.prototype._removeServiceInstance = function(a, b) { - void 0 === b && (b = e._DEFAULT_ENTRY_NAME), this._delegate.container.getProvider(a).clearInstance(b); + }, a.prototype._removeServiceInstance = function(b, a) { + void 0 === a && (a = c._DEFAULT_ENTRY_NAME), this._delegate.container.getProvider(b).clearInstance(a); }, a.prototype._addComponent = function(a) { - e._addComponent(this._delegate, a); + c._addComponent(this._delegate, a); }, a.prototype._addOrOverwriteComponent = function(a) { - e._addOrOverwriteComponent(this._delegate, a); + c._addOrOverwriteComponent(this._delegate, a); }, a.prototype.toJSON = function() { return { name: this.name, @@ -67,74 +67,74 @@ var a, b = require("@firebase/util"), c = require("tslib"), d = require("@fireba options: this.options }; }, a; -}(), i = ((a = {})["no-app"] = "No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()", a["invalid-app-argument"] = "firebase.{$appName}() takes either no argument or a Firebase App instance.", a), j = new b.ErrorFactory("app-compat", "Firebase", i); -function k() { - var a, d, e, f, i = (a = h, d = function(a) { - if (a = a || g._DEFAULT_ENTRY_NAME, !b.contains(e, a)) throw j.create("no-app", { +}(), g = ((a = {})["no-app"] = "No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()", a["invalid-app-argument"] = "firebase.{$appName}() takes either no argument or a Firebase App instance.", a), n = new b.ErrorFactory("app-compat", "Firebase", g); +function h() { + var e, c, f, a, d = (e = m, c = function(a) { + if (a = a || l._DEFAULT_ENTRY_NAME, !b.contains(f, a)) throw n.create("no-app", { appName: a }); - return e[a]; - }, e = {}, (f = { + return f[a]; + }, f = {}, (a = { __esModule: !0, - initializeApp: function(c, d) { + initializeApp: function(h, d) { void 0 === d && (d = {}); - var h = g.initializeApp(c, d); - if (b.contains(e, h.name)) return e[h.name]; - var i = new a(h, f); - return e[h.name] = i, i; + var c = l.initializeApp(h, d); + if (b.contains(f, c.name)) return f[c.name]; + var g = new e(c, a); + return f[c.name] = g, g; }, - app: d, - registerVersion: g.registerVersion, - setLogLevel: g.setLogLevel, - onLog: g.onLog, + app: c, + registerVersion: l.registerVersion, + setLogLevel: l.setLogLevel, + onLog: l.onLog, apps: null, - SDK_VERSION: g.SDK_VERSION, + SDK_VERSION: l.SDK_VERSION, INTERNAL: { - registerComponent: function(c) { - var e = c.name, h = e.replace("-compat", ""); - if (g._registerComponent(c) && "PUBLIC" === c.type) { - var i = function(a) { - if (void 0 === a && (a = d()), "function" != typeof a[h]) throw j.create("invalid-app-argument", { - appName: e + registerComponent: function(d) { + var h = d.name, f = h.replace("-compat", ""); + if (l._registerComponent(d) && "PUBLIC" === d.type) { + var g = function(a) { + if (void 0 === a && (a = c()), "function" != typeof a[f]) throw n.create("invalid-app-argument", { + appName: h }); - return a[h](); + return a[f](); }; - void 0 !== c.serviceProps && b.deepExtend(i, c.serviceProps), f[h] = i, a.prototype[h] = function() { - for(var a = [], b = 0; b < arguments.length; b++)a[b] = arguments[b]; - return this._getService.bind(this, e).apply(this, c.multipleInstances ? a : []); + void 0 !== d.serviceProps && b.deepExtend(g, d.serviceProps), a[f] = g, e.prototype[f] = function() { + for(var b = [], a = 0; a < arguments.length; a++)b[a] = arguments[a]; + return this._getService.bind(this, h).apply(this, d.multipleInstances ? b : []); }; } - return "PUBLIC" === c.type ? f[h] : null; + return "PUBLIC" === d.type ? a[f] : null; }, removeApp: function(a) { - delete e[a]; + delete f[a]; }, - useAsService: function(a, b) { - return "serverAuth" === b ? null : b; + useAsService: function(b, a) { + return "serverAuth" === a ? null : a; }, - modularAPIs: g + modularAPIs: l } - }).default = f, Object.defineProperty(f, "apps", { + }).default = a, Object.defineProperty(a, "apps", { get: function() { - return Object.keys(e).map(function(a) { - return e[a]; + return Object.keys(f).map(function(a) { + return f[a]; }); } - }), d.App = a, f); - return i.INTERNAL = c.__assign(c.__assign({}, i.INTERNAL), { - createFirebaseNamespace: k, + }), c.App = e, a); + return d.INTERNAL = j.__assign(j.__assign({}, d.INTERNAL), { + createFirebaseNamespace: h, extendNamespace: function(a) { - b.deepExtend(i, a); + b.deepExtend(d, a); }, createSubscribe: b.createSubscribe, ErrorFactory: b.ErrorFactory, deepExtend: b.deepExtend - }), i; + }), d; } -var l = k(), m = new f.Logger("@firebase/app-compat"); +var i = h(), d = new f.Logger("@firebase/app-compat"); if (b.isBrowser() && void 0 !== self.firebase) { - m.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n "); - var n = self.firebase.SDK_VERSION; - n && n.indexOf("LITE") >= 0 && m.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n "); + d.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n "); + var e = self.firebase.SDK_VERSION; + e && e.indexOf("LITE") >= 0 && d.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n "); } -e.registerVersion("@firebase/app-compat", "0.1.5", void 0), module.exports = l; +c.registerVersion("@firebase/app-compat", "0.1.5", void 0), module.exports = i; diff --git a/crates/swc/tests/vercel/full/ms/1/output/index.ts b/crates/swc/tests/vercel/full/ms/1/output/index.ts index afa6875a2c5..2bc99bfab2b 100644 --- a/crates/swc/tests/vercel/full/ms/1/output/index.ts +++ b/crates/swc/tests/vercel/full/ms/1/output/index.ts @@ -1,49 +1,49 @@ export default function(c, e) { try { - if ("string" == typeof c && c.length > 0) return (function(a) { - if ((a = String(a)).length > 100) throw new Error("Value exceeds the maximum length of 100 characters."); - var b = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a); - if (!b) return NaN; - var c = parseFloat(b[1]), d = (b[2] || "ms").toLowerCase(); + if ("string" == typeof c && c.length > 0) return (function(b) { + if ((b = String(b)).length > 100) throw new Error("Value exceeds the maximum length of 100 characters."); + var c = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(b); + if (!c) return NaN; + var a = parseFloat(c[1]), d = (c[2] || "ms").toLowerCase(); switch(d){ case "years": case "year": case "yrs": case "yr": case "y": - return 31557600000 * c; + return 31557600000 * a; case "weeks": case "week": case "w": - return 604800000 * c; + return 604800000 * a; case "days": case "day": case "d": - return 86400000 * c; + return 86400000 * a; case "hours": case "hour": case "hrs": case "hr": case "h": - return 3600000 * c; + return 3600000 * a; case "minutes": case "minute": case "mins": case "min": case "m": - return 60000 * c; + return 60000 * a; case "seconds": case "second": case "secs": case "sec": case "s": - return 1000 * c; + return 1000 * a; case "milliseconds": case "millisecond": case "msecs": case "msec": case "ms": - return c; + return a; default: throw new Error("The unit ".concat(d, " was matched, but no matching case exists.")); } @@ -59,12 +59,12 @@ function a(a) { var b = Math.abs(a); return b >= 86400000 ? "".concat(Math.round(a / 86400000), "d") : b >= 3600000 ? "".concat(Math.round(a / 3600000), "h") : b >= 60000 ? "".concat(Math.round(a / 60000), "m") : b >= 1000 ? "".concat(Math.round(a / 1000), "s") : "".concat(a, "ms"); } -function b(a) { - var b = Math.abs(a); - return b >= 86400000 ? c(a, b, 86400000, "day") : b >= 3600000 ? c(a, b, 3600000, "hour") : b >= 60000 ? c(a, b, 60000, "minute") : b >= 1000 ? c(a, b, 1000, "second") : "".concat(a, " ms"); +function b(b) { + var a = Math.abs(b); + return a >= 86400000 ? c(b, a, 86400000, "day") : a >= 3600000 ? c(b, a, 3600000, "hour") : a >= 60000 ? c(b, a, 60000, "minute") : a >= 1000 ? c(b, a, 1000, "second") : "".concat(b, " ms"); } -function c(a, b, c, d) { - return "".concat(Math.round(a / c), " ").concat(d).concat(b >= 1.5 * c ? "s" : ""); +function c(b, c, a, d) { + return "".concat(Math.round(b / a), " ").concat(d).concat(c >= 1.5 * a ? "s" : ""); } function d(a) { return "object" == typeof a && null !== a && "message" in a; diff --git a/crates/swc/tests/vercel/full/next-31419/1/output/index.js b/crates/swc/tests/vercel/full/next-31419/1/output/index.js index 4a33392380d..28474ef9fb0 100644 --- a/crates/swc/tests/vercel/full/next-31419/1/output/index.js +++ b/crates/swc/tests/vercel/full/next-31419/1/output/index.js @@ -28,22 +28,22 @@ Promise.all(assignAll).then(function() { return c.apply(this, arguments); }; }()); -export var listOfUser = function(c) { - var d; - return new Promise((d = a.asyncToGenerator(b.mark(function a(d, e) { +export var listOfUser = function(d) { + var c; + return new Promise((c = a.asyncToGenerator(b.mark(function a(c, e) { var f; return b.wrap(function(a) { for(;;)switch(a.prev = a.next){ case 0: - f = "Select Distinct id from \"TABLE\" Where id = '".concat(c, "' And user_id IS not null"), postgreSQL.query(f, null, function(a, b) { - a ? e(a) : d(b.rows); + f = "Select Distinct id from \"TABLE\" Where id = '".concat(d, "' And user_id IS not null"), postgreSQL.query(f, null, function(a, b) { + a ? e(a) : c(b.rows); }); case 2: case "end": return a.stop(); } }, a); - })), function(d, e) { - return d.apply(this, arguments); + })), function(c, e) { + return c.apply(this, arguments); })); }; diff --git a/crates/swc/tests/vercel/full/next-31419/2/output/index.js b/crates/swc/tests/vercel/full/next-31419/2/output/index.js index 05c3f4b92c5..b7e59bd8c2d 100644 --- a/crates/swc/tests/vercel/full/next-31419/2/output/index.js +++ b/crates/swc/tests/vercel/full/next-31419/2/output/index.js @@ -1,28 +1,28 @@ import * as a from "@swc/helpers"; Promise.all(assignAll).then(function() { - var b = a.asyncToGenerator(function*(a) { + var b = a.asyncToGenerator(function*(e) { let b = "DELETE FROM \"TABLE\" WHERE \"UUID\" IN ( "; for(let c in obj){ - let d = obj[c]; - b += `'${d.id}', `; - let e = yield listOfUser(d.id); - e.forEach((a)=>{ - insertQuery += `INSERT INTO "TABLE"("UUID", id, other_ids_here) VALUES ('${uuidv4()}', '${d.id}', now());`; + let a = obj[c]; + b += `'${a.id}', `; + let d = yield listOfUser(a.id); + d.forEach((b)=>{ + insertQuery += `INSERT INTO "TABLE"("UUID", id, other_ids_here) VALUES ('${uuidv4()}', '${a.id}', now());`; }); } }); - return function(a) { + return function(e) { return b.apply(this, arguments); }; }()); -export const listOfUser = function(b) { - var c; - return new Promise((c = a.asyncToGenerator(function*(a, c) { - const d = `Select Distinct id from "TABLE" Where id = '${b}' And user_id IS not null`; - postgreSQL.query(d, null, function(b, d) { - b ? c(b) : a(d.rows); +export const listOfUser = function(c) { + var b; + return new Promise((b = a.asyncToGenerator(function*(b, d) { + const a = `Select Distinct id from "TABLE" Where id = '${c}' And user_id IS not null`; + postgreSQL.query(a, null, function(a, c) { + a ? d(a) : b(c.rows); }); - }), function(a, c) { - return c.apply(this, arguments); + }), function(b, d) { + return b.apply(this, arguments); })); }; diff --git a/crates/swc/tests/vercel/full/next-33088/output/index.js b/crates/swc/tests/vercel/full/next-33088/output/index.js index a964b23e548..935dd445708 100644 --- a/crates/swc/tests/vercel/full/next-33088/output/index.js +++ b/crates/swc/tests/vercel/full/next-33088/output/index.js @@ -5,9 +5,9 @@ import * as f from "react"; export default function g() { var g = a.slicedToArray(f.useState({ hits: [] - }), 2), h = g[0], i = g[1], j = a.slicedToArray(f.useState("react"), 2), k = j[0], l = j[1]; + }), 2), j = g[0], k = g[1], h = a.slicedToArray(f.useState("react"), 2), i = h[0], l = h[1]; return f.useEffect(function() { - "" !== k && (function() { + "" !== i && (function() { return c.apply(this, arguments); })(); function c() { @@ -16,11 +16,11 @@ export default function g() { return b.wrap(function(a) { for(;;)switch(a.prev = a.next){ case 0: - return a.next = 2, fetch("https://hn.algolia.com/api/v1/search?query=" + k); + return a.next = 2, fetch("https://hn.algolia.com/api/v1/search?query=" + i); case 2: return c = a.sent, a.next = 5, c.json(); case 5: - i(d = a.sent); + k(d = a.sent); case 7: case "end": return a.stop(); @@ -29,17 +29,17 @@ export default function g() { }))).apply(this, arguments); } }, [ - k + i ]), d(e, { children: [ c("input", { - value: k, + value: i, onChange: function(a) { return l(a.target.value); } }), c("ul", { - children: h.hits.map(function(a) { + children: j.hits.map(function(a) { return c("li", { children: c("a", { href: a.url, diff --git a/crates/swc/tests/vercel/full/react-autowhatever/1/output/index.js b/crates/swc/tests/vercel/full/react-autowhatever/1/output/index.js index d23baa83343..90e4b49db57 100644 --- a/crates/swc/tests/vercel/full/react-autowhatever/1/output/index.js +++ b/crates/swc/tests/vercel/full/react-autowhatever/1/output/index.js @@ -2,69 +2,69 @@ Object.defineProperty(exports, "__esModule", { value: !0 }), exports.default = void 0; -var a = require("react/jsx-runtime"), b = function(a) { +var d = require("react/jsx-runtime"), c = function(a) { if (a && a.__esModule) return a; - var b = {}; + var c = {}; if (null != a) { - for(var c in a)if (Object.prototype.hasOwnProperty.call(a, c)) { - var d = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(a, c) : {}; - d.get || d.set ? Object.defineProperty(b, c, d) : b[c] = a[c]; + for(var b in a)if (Object.prototype.hasOwnProperty.call(a, b)) { + var d = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(a, b) : {}; + d.get || d.set ? Object.defineProperty(c, b, d) : c[b] = a[b]; } } - return b.default = a, b; -}(require("react")), c = function(a) { + return c.default = a, c; +}(require("react")), a = function(a) { return a && a.__esModule ? a : { default: a }; }(require("prop-types")); -function d(a, b) { - for(var c = 0; c < b.length; c++){ - var d = b[c]; - d.enumerable = d.enumerable || !1, d.configurable = !0, "value" in d && (d.writable = !0), Object.defineProperty(a, d.key, d); +function e(d, c) { + for(var b = 0; b < c.length; b++){ + var a = c[b]; + a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(d, a.key, a); } } -function e(a, c, d) { - return c in a ? Object.defineProperty(a, c, { - value: d, +function f(a, b, c) { + return b in a ? Object.defineProperty(a, b, { + value: c, enumerable: !0, configurable: !0, writable: !0 - }) : a[c] = d, a; -} -function f(a) { - return f = Object.setPrototypeOf ? Object.getPrototypeOf : function f(a) { - return a.__proto__ || Object.getPrototypeOf(a); - }, f(a); + }) : a[b] = c, a; } function g(a) { - for(var c = 1; c < arguments.length; c++){ - var d = null != arguments[c] ? arguments[c] : {}, f = Object.keys(d); - "function" == typeof Object.getOwnPropertySymbols && (f = f.concat(Object.getOwnPropertySymbols(d).filter(function(a) { - return Object.getOwnPropertyDescriptor(d, a).enumerable; - }))), f.forEach(function(c) { - e(a, c, d[c]); + return g = Object.setPrototypeOf ? Object.getPrototypeOf : function g(a) { + return a.__proto__ || Object.getPrototypeOf(a); + }, g(a); +} +function h(d) { + for(var b = 1; b < arguments.length; b++){ + var e = null != arguments[b] ? arguments[b] : {}, c = Object.keys(e); + "function" == typeof Object.getOwnPropertySymbols && (c = c.concat(Object.getOwnPropertySymbols(e).filter(function(a) { + return Object.getOwnPropertyDescriptor(e, a).enumerable; + }))), c.forEach(function(b) { + f(d, b, e[b]); }); } - return a; + return d; } -function h(a, b) { - return h = Object.setPrototypeOf || function h(a, b) { +function i(a, b) { + return i = Object.setPrototypeOf || function i(a, b) { return a.__proto__ = b, a; - }, h(a, b); + }, i(a, b); } -var i = function(b) { +var b = function(l) { "use strict"; - !function(a, b) { - if ("function" != typeof b && null !== b) throw new TypeError("Super expression must either be null or a function"); - a.prototype = Object.create(b && b.prototype, { + !function(b, a) { + if ("function" != typeof a && null !== a) throw new TypeError("Super expression must either be null or a function"); + b.prototype = Object.create(a && a.prototype, { constructor: { - value: a, + value: b, writable: !0, configurable: !0 } - }), b && h(a, b); - }(i, b); - var c, e, j, k, l, m = (k = i, l = function() { + }), a && i(b, a); + }(b, l); + var c, f, j, m, n, o = (m = b, n = function() { if ("undefined" == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; @@ -74,25 +74,25 @@ var i = function(b) { return !1; } }(), function() { - var a, b, c, d, e = f(k); - if (l) { - var g = f(this).constructor; - d = Reflect.construct(e, arguments, g); - } else d = e.apply(this, arguments); - return b = this, (c = d) && ("object" == ((a = c) && "undefined" != typeof Symbol && a.constructor === Symbol ? "symbol" : typeof a) || "function" == typeof c) ? c : (function(b) { - if (void 0 === b) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - return b; - })(b); + var a, e, b, d, f = g(m); + if (n) { + var h = g(this).constructor; + d = Reflect.construct(f, arguments, h); + } else d = f.apply(this, arguments); + return e = this, (b = d) && ("object" == ((a = b) && "undefined" != typeof Symbol && a.constructor === Symbol ? "symbol" : typeof a) || "function" == typeof b) ? b : (function(e) { + if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return e; + })(e); }); - function i() { + function b() { var a; return !function(a, c) { if (!(a instanceof c)) throw new TypeError("Cannot call a class as a function"); - }(this, i), a = m.apply(this, arguments), a.storeHighlightedItemReference = function(b) { + }(this, b), a = o.apply(this, arguments), a.storeHighlightedItemReference = function(b) { a.props.onHighlightedItemChange(null === b ? null : b.item); }, a; } - return c = i, e = [ + return c = b, f = [ { key: "shouldComponentUpdate", value: function(a) { @@ -102,46 +102,46 @@ var i = function(b) { { key: "render", value: function() { - var b = this, c = this.props, d = c.items, e = c.itemProps, f = c.renderItem, h = c.renderItemData, i = c.sectionIndex, j = c.highlightedItemIndex, k = c.getItemId, l = c.theme, m = c.keyPrefix, n = null === i ? m : "".concat(m, "section-").concat(i, "-"), o = "function" == typeof e; - return a.jsx("ul", g({ + var j = this, a = this.props, e = a.items, f = a.itemProps, k = a.renderItem, l = a.renderItemData, b = a.sectionIndex, m = a.highlightedItemIndex, n = a.getItemId, g = a.theme, c = a.keyPrefix, i = null === b ? c : "".concat(c, "section-").concat(b, "-"), o = "function" == typeof f; + return d.jsx("ul", h({ role: "listbox" - }, l("".concat(n, "items-list"), "itemsList"), { - children: d.map(function(c, d) { - var m = d === j, p = "".concat(n, "item-").concat(d), q = o ? e({ - sectionIndex: i, - itemIndex: d - }) : e, r = g({ - id: k(i, d), - "aria-selected": m - }, l(p, "item", 0 === d && "itemFirst", m && "itemHighlighted"), q); - return m && (r.ref = b.storeHighlightedItemReference), a.jsx(Item, g({}, r, { - sectionIndex: i, - isHighlighted: m, - itemIndex: d, - item: c, - renderItem: f, - renderItemData: h + }, g("".concat(i, "items-list"), "itemsList"), { + children: e.map(function(p, a) { + var c = a === m, q = "".concat(i, "item-").concat(a), r = o ? f({ + sectionIndex: b, + itemIndex: a + }) : f, e = h({ + id: n(b, a), + "aria-selected": c + }, g(q, "item", 0 === a && "itemFirst", c && "itemHighlighted"), r); + return c && (e.ref = j.storeHighlightedItemReference), d.jsx(Item, h({}, e, { + sectionIndex: b, + isHighlighted: c, + itemIndex: a, + item: p, + renderItem: k, + renderItemData: l })); }) })); } } - ], d(c.prototype, e), j && d(c, j), i; -}(b.Component); -exports.default = i, i.propTypes = { - items: c.default.array.isRequired, - itemProps: c.default.oneOfType([ - c.default.object, - c.default.func + ], e(c.prototype, f), j && e(c, j), b; +}(c.Component); +exports.default = b, b.propTypes = { + items: a.default.array.isRequired, + itemProps: a.default.oneOfType([ + a.default.object, + a.default.func ]), - renderItem: c.default.func.isRequired, - renderItemData: c.default.object.isRequired, - sectionIndex: c.default.number, - highlightedItemIndex: c.default.number, - onHighlightedItemChange: c.default.func.isRequired, - getItemId: c.default.func.isRequired, - theme: c.default.func.isRequired, - keyPrefix: c.default.string.isRequired -}, i.defaultProps = { + renderItem: a.default.func.isRequired, + renderItemData: a.default.object.isRequired, + sectionIndex: a.default.number, + highlightedItemIndex: a.default.number, + onHighlightedItemChange: a.default.func.isRequired, + getItemId: a.default.func.isRequired, + theme: a.default.func.isRequired, + keyPrefix: a.default.string.isRequired +}, b.defaultProps = { sectionIndex: null -}, new i(); +}, new b(); diff --git a/crates/swc/tests/vercel/full/react-autowhatever/2/output/index.js b/crates/swc/tests/vercel/full/react-autowhatever/2/output/index.js index 053eaa53666..b7db75cf510 100644 --- a/crates/swc/tests/vercel/full/react-autowhatever/2/output/index.js +++ b/crates/swc/tests/vercel/full/react-autowhatever/2/output/index.js @@ -2,65 +2,65 @@ Object.defineProperty(exports, "__esModule", { value: !0 }), exports.default = void 0; -var a = require("react/jsx-runtime"), b = function(a) { +var c = require("react/jsx-runtime"), b = function(a) { if (a && a.__esModule) return a; - var b = {}; + var c = {}; if (null != a) { - for(var c in a)if (Object.prototype.hasOwnProperty.call(a, c)) { - var d = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(a, c) : {}; - d.get || d.set ? Object.defineProperty(b, c, d) : b[c] = a[c]; + for(var b in a)if (Object.prototype.hasOwnProperty.call(a, b)) { + var d = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(a, b) : {}; + d.get || d.set ? Object.defineProperty(c, b, d) : c[b] = a[b]; } } - return b.default = a, b; + return c.default = a, c; }(require("react")); -function c(a, b) { - for(var c = 0; c < b.length; c++){ - var d = b[c]; - d.enumerable = d.enumerable || !1, d.configurable = !0, "value" in d && (d.writable = !0), Object.defineProperty(a, d.key, d); +function d(d, c) { + for(var b = 0; b < c.length; b++){ + var a = c[b]; + a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(d, a.key, a); } } -function d(a, c, d) { - return c in a ? Object.defineProperty(a, c, { - value: d, +function e(a, b, c) { + return b in a ? Object.defineProperty(a, b, { + value: c, enumerable: !0, configurable: !0, writable: !0 - }) : a[c] = d, a; -} -function e(a) { - return e = Object.setPrototypeOf ? Object.getPrototypeOf : function e(a) { - return a.__proto__ || Object.getPrototypeOf(a); - }, e(a); + }) : a[b] = c, a; } function f(a) { - for(var c = 1; c < arguments.length; c++){ - var e = null != arguments[c] ? arguments[c] : {}, f = Object.keys(e); - "function" == typeof Object.getOwnPropertySymbols && (f = f.concat(Object.getOwnPropertySymbols(e).filter(function(a) { - return Object.getOwnPropertyDescriptor(e, a).enumerable; - }))), f.forEach(function(c) { - d(a, c, e[c]); + return f = Object.setPrototypeOf ? Object.getPrototypeOf : function f(a) { + return a.__proto__ || Object.getPrototypeOf(a); + }, f(a); +} +function g(d) { + for(var b = 1; b < arguments.length; b++){ + var f = null != arguments[b] ? arguments[b] : {}, c = Object.keys(f); + "function" == typeof Object.getOwnPropertySymbols && (c = c.concat(Object.getOwnPropertySymbols(f).filter(function(a) { + return Object.getOwnPropertyDescriptor(f, a).enumerable; + }))), c.forEach(function(b) { + e(d, b, f[b]); }); } - return a; + return d; } -function g(a, b) { - return g = Object.setPrototypeOf || function g(a, b) { +function h(a, b) { + return h = Object.setPrototypeOf || function h(a, b) { return a.__proto__ = b, a; - }, g(a, b); + }, h(a, b); } -var h = function(b) { +var a = function(k) { "use strict"; - !function(a, b) { - if ("function" != typeof b && null !== b) throw new TypeError("Super expression must either be null or a function"); - a.prototype = Object.create(b && b.prototype, { + !function(b, a) { + if ("function" != typeof a && null !== a) throw new TypeError("Super expression must either be null or a function"); + b.prototype = Object.create(a && a.prototype, { constructor: { - value: a, + value: b, writable: !0, configurable: !0 } - }), b && g(a, b); - }(h, b); - var d, i, j, k, l, m = (k = h, l = function() { + }), a && h(b, a); + }(a, k); + var b, e, i, l, m, n = (l = a, m = function() { if ("undefined" == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; @@ -70,25 +70,25 @@ var h = function(b) { return !1; } }(), function() { - var a, b, c, d, f = e(k); - if (l) { - var g = e(this).constructor; - d = Reflect.construct(f, arguments, g); - } else d = f.apply(this, arguments); - return b = this, (c = d) && ("object" == ((a = c) && "undefined" != typeof Symbol && a.constructor === Symbol ? "symbol" : typeof a) || "function" == typeof c) ? c : (function(b) { - if (void 0 === b) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - return b; - })(b); + var a, e, b, d, g = f(l); + if (m) { + var h = f(this).constructor; + d = Reflect.construct(g, arguments, h); + } else d = g.apply(this, arguments); + return e = this, (b = d) && ("object" == ((a = b) && "undefined" != typeof Symbol && a.constructor === Symbol ? "symbol" : typeof a) || "function" == typeof b) ? b : (function(e) { + if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + return e; + })(e); }); - function h() { - var a; - return !function(a, d) { - if (!(a instanceof d)) throw new TypeError("Cannot call a class as a function"); - }(this, h), a = m.apply(this, arguments), a.storeHighlightedItemReference = function(b) { - a.props.onHighlightedItemChange(null === b ? null : b.item); - }, a; + function a() { + var c; + return !function(a, b) { + if (!(a instanceof b)) throw new TypeError("Cannot call a class as a function"); + }(this, a), c = n.apply(this, arguments), c.storeHighlightedItemReference = function(a) { + c.props.onHighlightedItemChange(null === a ? null : a.item); + }, c; } - return d = h, i = [ + return b = a, e = [ { key: "shouldComponentUpdate", value: function(a) { @@ -100,34 +100,34 @@ var h = function(b) { { key: "render", value: function() { - var b = this, c = this.props, d = c.items, e = c.itemProps, g = c.renderItem, h = c.renderItemData, i = c.sectionIndex, j = c.highlightedItemIndex, k = c.getItemId, l = c.theme, m = c.keyPrefix, n = null === i ? m : "".concat(m, "section-").concat(i, "-"), o = "function" == typeof e; - return a.jsx("ul", f({ + var j = this, a = this.props, e = a.items, f = a.itemProps, k = a.renderItem, l = a.renderItemData, b = a.sectionIndex, m = a.highlightedItemIndex, n = a.getItemId, h = a.theme, d = a.keyPrefix, i = null === b ? d : "".concat(d, "section-").concat(b, "-"), o = "function" == typeof f; + return c.jsx("ul", g({ role: "listbox" - }, l("".concat(n, "items-list"), "itemsList"), { - children: d.map(function(c, d) { - var m = d === j, p = "".concat(n, "item-").concat(d), q = o ? e({ - sectionIndex: i, - itemIndex: d - }) : e, r = f({ - id: k(i, d), - "aria-selected": m - }, l(p, "item", 0 === d && "itemFirst", m && "itemHighlighted"), q); - return m && (r.ref = b.storeHighlightedItemReference), a.jsx(Item, f({}, r, { - sectionIndex: i, - isHighlighted: m, - itemIndex: d, - item: c, - renderItem: g, - renderItemData: h + }, h("".concat(i, "items-list"), "itemsList"), { + children: e.map(function(p, a) { + var d = a === m, q = "".concat(i, "item-").concat(a), r = o ? f({ + sectionIndex: b, + itemIndex: a + }) : f, e = g({ + id: n(b, a), + "aria-selected": d + }, h(q, "item", 0 === a && "itemFirst", d && "itemHighlighted"), r); + return d && (e.ref = j.storeHighlightedItemReference), c.jsx(Item, g({}, e, { + sectionIndex: b, + isHighlighted: d, + itemIndex: a, + item: p, + renderItem: k, + renderItemData: l })); }) })); } } - ], c(d.prototype, i), j && c(d, j), h; + ], d(b.prototype, e), i && d(b, i), a; }(b.Component); -exports.default = h, h.propTypes = { +exports.default = a, a.propTypes = { items: 500 -}, h.defaultProps = { +}, a.defaultProps = { sectionIndex: null -}, new h(); +}, new a(); diff --git a/crates/swc/tests/vercel/full/react-instantsearch/2/output/index.js b/crates/swc/tests/vercel/full/react-instantsearch/2/output/index.js index 7e066fbfb6f..836f5f8685f 100644 --- a/crates/swc/tests/vercel/full/react-instantsearch/2/output/index.js +++ b/crates/swc/tests/vercel/full/react-instantsearch/2/output/index.js @@ -19,39 +19,39 @@ var i = function(a) { return Boolean(a.props.indexId); }, l = function(a, b) { return a.props.indexId === b; -}, m = function(a, b) { - var c = k(a), d = k(b); - return c && !d ? -1 : !c && d ? 1 : 0; +}, m = function(c, d) { + var a = k(c), b = k(d); + return a && !b ? -1 : !a && b ? 1 : 0; }; export default function n(e) { - var f = e.indexName, g = e.initialState, n = e.searchClient, p = e.resultsState, q = e.stalledSearchDelay, r = function(a) { - return C.getWidgets().filter(function(a) { + var p = e.indexName, q = e.initialState, g = e.searchClient, n = e.resultsState, z = e.stalledSearchDelay, A = function(a) { + return v.getWidgets().filter(function(a) { return Boolean(a.getMetadata); }).map(function(b) { return b.getMetadata(a); }); }, s = function() { - var b = C.getWidgets().filter(function(a) { + var b = v.getWidgets().filter(function(a) { return Boolean(a.getSearchParameters); }).filter(function(a) { return !i(a) && !k(a); }).reduce(function(a, b) { return b.getSearchParameters(a); - }, B), c = C.getWidgets().filter(function(a) { + }, G), c = v.getWidgets().filter(function(a) { return Boolean(a.getSearchParameters); }).filter(function(a) { - var b = i(a) && j(a, f), c = k(a) && l(a, f); + var b = i(a) && j(a, p), c = k(a) && l(a, p); return b || c; }).sort(m).reduce(function(a, b) { return b.getSearchParameters(a); - }, b), d = C.getWidgets().filter(function(a) { + }, b), d = v.getWidgets().filter(function(a) { return Boolean(a.getSearchParameters); }).filter(function(a) { - var b = i(a) && !j(a, f), c = k(a) && !l(a, f); + var b = i(a) && !j(a, p), c = k(a) && !l(a, p); return b || c; - }).sort(m).reduce(function(b, c) { - var d = i(c) ? c.props.indexContextValue.targetedIndex : c.props.indexId, e = b[d] || []; - return a.objectSpread({}, b, a.defineProperty({}, d, e.concat(c))); + }).sort(m).reduce(function(c, b) { + var d = i(b) ? b.props.indexContextValue.targetedIndex : b.props.indexId, e = c[d] || []; + return a.objectSpread({}, c, a.defineProperty({}, d, e.concat(b))); }, {}), e = Object.keys(d).map(function(a) { return { parameters: d[a].reduce(function(a, b) { @@ -64,49 +64,49 @@ export default function n(e) { mainParameters: c, derivedParameters: e }; - }, t = function() { - if (!z) { - var a = s(y.state), b = a.mainParameters, c = a.derivedParameters; - y.derivedHelpers.slice().forEach(function(a) { + }, B = function() { + if (!E) { + var a = s(r.state), b = a.mainParameters, c = a.derivedParameters; + r.derivedHelpers.slice().forEach(function(a) { a.detach(); }), c.forEach(function(a) { - var b = a.indexId, c = a.parameters, d = y.derive(function() { - return c; + var b = a.indexId, d = a.parameters, c = r.derive(function() { + return d; }); - d.on("result", u({ + c.on("result", t({ indexId: b - })).on("error", v); - }), y.setState(b), y.search(); + })).on("error", u); + }), r.setState(b), r.search(); } - }, u = function(b) { + }, t = function(b) { var c = b.indexId; - return function(b) { - var d = G.getState(), e = !y.derivedHelpers.length, f = d.results ? d.results : {}; - f = !e && f.getFacetByName ? {} : f, f = e ? b.results : a.objectSpread({}, f, a.defineProperty({}, c, b.results)); - var g = G.getState(), h = g.isSearchStalled; - y.hasPendingRequests() || (clearTimeout(A), A = null, h = !1), g.resultsFacetValues; - var i = a.objectWithoutProperties(g, [ + return function(e) { + var f = y.getState(), g = !r.derivedHelpers.length, b = f.results ? f.results : {}; + b = !g && b.getFacetByName ? {} : b, b = g ? e.results : a.objectSpread({}, b, a.defineProperty({}, c, e.results)); + var d = y.getState(), h = d.isSearchStalled; + r.hasPendingRequests() || (clearTimeout(F), F = null, h = !1), d.resultsFacetValues; + var i = a.objectWithoutProperties(d, [ "resultsFacetValues" ]); - G.setState(a.objectSpread({}, i, { - results: f, + y.setState(a.objectSpread({}, i, { + results: b, isSearchStalled: h, searching: !1, error: null })); }; - }, v = function(b) { - var c = b.error, d = G.getState(), e = d.isSearchStalled; - y.hasPendingRequests() || (clearTimeout(A), e = !1), d.resultsFacetValues; - var f = a.objectWithoutProperties(d, [ + }, u = function(d) { + var e = d.error, b = y.getState(), c = b.isSearchStalled; + r.hasPendingRequests() || (clearTimeout(F), c = !1), b.resultsFacetValues; + var f = a.objectWithoutProperties(b, [ "resultsFacetValues" ]); - G.setState(a.objectSpread({}, f, { - isSearchStalled: e, - error: c, + y.setState(a.objectSpread({}, f, { + isSearchStalled: c, + error: e, searching: !1 })); - }, w = function(b, c) { + }, C = function(b, c) { if (b.transporter) { b.transporter.responsesCache.set({ method: "search", @@ -142,7 +142,7 @@ export default function n(e) { return a.concat(b.rawResults); }, []) }))); - }, x = function(b, c) { + }, D = function(b, c) { if (b.transporter) { b.transporter.responsesCache.set({ method: "search", @@ -170,41 +170,41 @@ export default function n(e) { b.cache = a.objectSpread({}, b.cache, a.defineProperty({}, d, JSON.stringify({ results: c.rawResults }))); - }, y = b(n, f, a.objectSpread({}, d)); - h(n), y.on("search", function() { - A || (A = setTimeout(function() { - var b = G.getState(), c = b.resultsFacetValues, d = a.objectWithoutProperties(b, [ + }, r = b(g, p, a.objectSpread({}, d)); + h(g), r.on("search", function() { + F || (F = setTimeout(function() { + var b = y.getState(), d = b.resultsFacetValues, c = a.objectWithoutProperties(b, [ "resultsFacetValues" ]); - G.setState(a.objectSpread({}, d, { + y.setState(a.objectSpread({}, c, { isSearchStalled: !0 })); - }, q)); - }).on("result", u({ - indexId: f - })).on("error", v); - var z = !1, A = null, B = y.state, C = c(function() { - var b = r(G.getState().widgets); - G.setState(a.objectSpread({}, G.getState(), { + }, z)); + }).on("result", t({ + indexId: p + })).on("error", u); + var E = !1, F = null, G = r.state, v = c(function() { + var b = A(y.getState().widgets); + y.setState(a.objectSpread({}, y.getState(), { metadata: b, searching: !0 - })), t(); + })), B(); }); !function(b, c) { if (c && (b.transporter && !b._cacheHydrated || b._useCache && "function" == typeof b.addAlgoliaAgent)) { if (b.transporter && !b._cacheHydrated) { b._cacheHydrated = !0; var d = b.search; - b.search = function(c) { - for(var e = arguments.length, f = new Array(e > 1 ? e - 1 : 0), g = 1; g < e; g++)f[g - 1] = arguments[g]; - var h = c.map(function(b) { + b.search = function(g) { + for(var e = arguments.length, f = new Array(e > 1 ? e - 1 : 0), c = 1; c < e; c++)f[c - 1] = arguments[c]; + var h = g.map(function(b) { var c, d; return a.objectSpread({}, b, { - params: (c = b.params, d = function(a) { - for(var b = arguments.length, c = new Array(b > 1 ? b - 1 : 0), d = 1; d < b; d++)c[d - 1] = arguments[d]; + params: (c = b.params, d = function(c) { + for(var b = arguments.length, d = new Array(b > 1 ? b - 1 : 0), a = 1; a < b; a++)d[a - 1] = arguments[a]; var e = 0; - return a.replace(/%s/g, function() { - return encodeURIComponent(c[e++]); + return c.replace(/%s/g, function() { + return encodeURIComponent(d[e++]); }); }, Object.keys(c).map(function(a) { var b; @@ -219,65 +219,65 @@ export default function n(e) { ].concat(a.toConsumableArray(f)) }, function() { return d.apply(void 0, [ - c + g ].concat(a.toConsumableArray(f))); }); }; } if (Array.isArray(c.results)) { - w(b, c.results); + C(b, c.results); return; } - x(b, c); + D(b, c); } - }(n, p); - var D, E, F, G = (E = { - widgets: void 0 === g ? {} : g, - metadata: o(p), - results: (D = p) ? Array.isArray(D.results) ? D.results.reduce(function(c, d) { - return a.objectSpread({}, c, a.defineProperty({}, d._internalIndexId, new b.SearchResults(new b.SearchParameters(d.state), d.rawResults))); - }, {}) : new b.SearchResults(new b.SearchParameters(D.state), D.rawResults) : null, + }(g, n); + var f, w, x, y = (w = { + widgets: void 0 === q ? {} : q, + metadata: o(n), + results: (f = n) ? Array.isArray(f.results) ? f.results.reduce(function(d, c) { + return a.objectSpread({}, d, a.defineProperty({}, c._internalIndexId, new b.SearchResults(new b.SearchParameters(c.state), c.rawResults))); + }, {}) : new b.SearchResults(new b.SearchParameters(f.state), f.rawResults) : null, error: null, searching: !1, isSearchStalled: !0, searchingForFacetValues: !1 - }, F = [], { + }, x = [], { getState: function() { - return E; + return w; }, setState: function(a) { - E = a, F.forEach(function(a) { + w = a, x.forEach(function(a) { return a(); }); }, subscribe: function(a) { - return F.push(a), function() { - F.splice(F.indexOf(a), 1); + return x.push(a), function() { + x.splice(x.indexOf(a), 1); }; } }); return { - store: G, - widgetsManager: C, + store: y, + widgetsManager: v, getWidgetsIds: function() { - return G.getState().metadata.reduce(function(a, b) { + return y.getState().metadata.reduce(function(a, b) { return void 0 !== b.id ? a.concat(b.id) : a; }, []); }, getSearchParameters: s, onSearchForFacetValues: function(b) { - var c = b.facetName, d = b.query, e = b.maxFacetHits; - G.setState(a.objectSpread({}, G.getState(), { + var d = b.facetName, e = b.query, c = b.maxFacetHits; + y.setState(a.objectSpread({}, y.getState(), { searchingForFacetValues: !0 - })), y.searchForFacetValues(c, d, Math.max(1, Math.min(void 0 === e ? 10 : e, 100))).then(function(b) { - var e; - G.setState(a.objectSpread({}, G.getState(), { + })), r.searchForFacetValues(d, e, Math.max(1, Math.min(void 0 === c ? 10 : c, 100))).then(function(c) { + var b; + y.setState(a.objectSpread({}, y.getState(), { error: null, searchingForFacetValues: !1, - resultsFacetValues: a.objectSpread({}, G.getState().resultsFacetValues, (e = {}, a.defineProperty(e, c, b.facetHits), a.defineProperty(e, "query", d), e)) + resultsFacetValues: a.objectSpread({}, y.getState().resultsFacetValues, (b = {}, a.defineProperty(b, d, c.facetHits), a.defineProperty(b, "query", e), b)) })); }, function(b) { - G.setState(a.objectSpread({}, G.getState(), { + y.setState(a.objectSpread({}, y.getState(), { searchingForFacetValues: !1, error: b })); @@ -288,32 +288,32 @@ export default function n(e) { }); }, onExternalStateUpdate: function(b) { - var c = r(b); - G.setState(a.objectSpread({}, G.getState(), { + var c = A(b); + y.setState(a.objectSpread({}, y.getState(), { widgets: b, metadata: c, searching: !0 - })), t(); + })), B(); }, transitionState: function(a) { - var b = G.getState().widgets; - return C.getWidgets().filter(function(a) { + var b = y.getState().widgets; + return v.getWidgets().filter(function(a) { return Boolean(a.transitionState); }).reduce(function(a, c) { return c.transitionState(b, a); }, a); }, updateClient: function(a) { - h(a), y.setClient(a), t(); + h(a), r.setClient(a), B(); }, updateIndex: function(a) { - B = B.setIndex(a); + G = G.setIndex(a); }, clearCache: function() { - y.clearCache(), t(); + r.clearCache(), B(); }, skipSearch: function() { - z = !0; + E = !0; } }; }; diff --git a/crates/swc/tests/vercel/full/var-scpoing/1/output/index.js b/crates/swc/tests/vercel/full/var-scpoing/1/output/index.js index 1b05c53021b..e923652108b 100644 --- a/crates/swc/tests/vercel/full/var-scpoing/1/output/index.js +++ b/crates/swc/tests/vercel/full/var-scpoing/1/output/index.js @@ -1,4 +1,4 @@ -for(var a = 0; a < points.length; a++)for(var b in points[a], keys){ - for(var c = 0; c < keys[key].length; c++)console.log(c); +for(var a = 0; a < points.length; a++)for(var c in points[a], keys){ + for(var b = 0; b < keys[key].length; b++)console.log(b); console.log(a); } diff --git a/crates/swc_ecma_minifier/src/pass/compute_char_freq.rs b/crates/swc_ecma_minifier/src/pass/compute_char_freq.rs index 3d1e6c33b2c..b3828fc1aeb 100644 --- a/crates/swc_ecma_minifier/src/pass/compute_char_freq.rs +++ b/crates/swc_ecma_minifier/src/pass/compute_char_freq.rs @@ -1,8 +1,75 @@ -use swc_ecma_ast::Module; +use std::cmp::Ordering; + +use swc_common::collections::AHashMap; +use swc_ecma_ast::*; +use swc_ecma_visit::{noop_visit_type, Visit}; + +use crate::util::base54::{incr_base54, BASE54_DEFAULT_CHARS}; + +/// TODO: Use [u8; 64] instead +type CharFreq = AHashMap; #[derive(Debug)] -pub struct CharFreqInfo {} +pub(crate) struct CharFreqInfo { + frequency: CharFreq, -pub fn compute_char_freq(_: &Module) -> CharFreqInfo { - CharFreqInfo {} + chars: [u8; 64], +} + +pub(crate) fn compute_char_freq(_m: &Module) -> CharFreqInfo { + let mut base54 = CharFreqInfo { + frequency: AHashMap::with_capacity_and_hasher(64, Default::default()), + chars: *BASE54_DEFAULT_CHARS, + }; + + // TODO: Implement more visitor methods (or use codegen) and enable this + // m.visit_with(&mut base54); + base54.sort(); + + base54 +} + +impl CharFreqInfo { + fn consider(&mut self, s: &str, delta: f32) { + for c in s.chars().rev().filter_map(|c| { + if c.len_utf8() == 1 { + let b = c as u8; + if BASE54_DEFAULT_CHARS.contains(&b) { + return Some(b); + } + + None + } else { + None + } + }) { + let freq = self.frequency.entry(c).or_insert(0.0); + *freq += delta; + } + } + + fn sort(&mut self) { + fn cmp(f: &CharFreq, a: u8, b: u8) -> Ordering { + let af = f.get(&a).copied().unwrap_or(0.0); + let bf = f.get(&b).copied().unwrap_or(0.0); + + af.partial_cmp(&bf).unwrap_or_else(|| a.cmp(&b)) + } + + self.chars[..53].sort_by(|&a, &b| cmp(&self.frequency, a, b)); + self.chars[53..].sort_by(|&a, &b| cmp(&self.frequency, a, b)); + } + + /// returns `(used_value, identifier_symbol)` + pub fn incr_base54(&self, init: &mut usize) -> (usize, String) { + incr_base54(init, &self.chars) + } +} + +impl Visit for CharFreqInfo { + noop_visit_type!(); + + fn visit_ident(&mut self, i: &Ident) { + self.consider(&i.sym, 1.0); + } } diff --git a/crates/swc_ecma_minifier/src/pass/mangle_names/analyzer/mod.rs b/crates/swc_ecma_minifier/src/pass/mangle_names/analyzer/mod.rs index bb9fcb9e7fb..462f1f84af4 100644 --- a/crates/swc_ecma_minifier/src/pass/mangle_names/analyzer/mod.rs +++ b/crates/swc_ecma_minifier/src/pass/mangle_names/analyzer/mod.rs @@ -7,6 +7,7 @@ use tracing::trace; use self::scope::Scope; use super::rename_map::RenameMap; +use crate::pass::compute_char_freq::CharFreqInfo; mod scope; @@ -17,11 +18,16 @@ pub(super) struct Analyzer { } impl Analyzer { - pub(super) fn into_rename_map(mut self, preserved: &AHashSet) -> AHashMap { + pub(super) fn into_rename_map( + mut self, + freq: &CharFreqInfo, + preserved: &AHashSet, + ) -> AHashMap { let mut map = RenameMap::default(); let preserved_symbols = preserved.iter().cloned().map(|v| v.0).collect(); - self.scope.rename(&mut map, preserved, &preserved_symbols); + self.scope + .rename(freq, &mut map, preserved, &preserved_symbols); map.into_map() } @@ -112,6 +118,20 @@ impl Visit for Analyzer { }) } + fn visit_class_method(&mut self, f: &ClassMethod) { + f.key.visit_with(self); + + self.with_scope(|v| { + f.function.visit_with(v); + }) + } + + fn visit_constructor(&mut self, f: &Constructor) { + self.with_scope(|v| { + f.visit_children_with(v); + }) + } + fn visit_default_decl(&mut self, d: &DefaultDecl) { match d { DefaultDecl::Class(c) => { diff --git a/crates/swc_ecma_minifier/src/pass/mangle_names/analyzer/scope.rs b/crates/swc_ecma_minifier/src/pass/mangle_names/analyzer/scope.rs index b54d701da53..e99ba4be679 100644 --- a/crates/swc_ecma_minifier/src/pass/mangle_names/analyzer/scope.rs +++ b/crates/swc_ecma_minifier/src/pass/mangle_names/analyzer/scope.rs @@ -2,7 +2,7 @@ use swc_atoms::{js_word, JsWord}; use swc_common::{collections::AHashSet, util::take::Take}; use swc_ecma_utils::Id; -use crate::{pass::mangle_names::rename_map::RenameMap, util::base54::incr_base54}; +use crate::pass::{compute_char_freq::CharFreqInfo, mangle_names::rename_map::RenameMap}; #[derive(Debug, Default)] pub(crate) struct Scope { @@ -18,7 +18,7 @@ pub struct ScopeData { /// Usages in current scope. usages: AHashSet, - queue: Vec, + queue: Vec<(Id, u32)>, } impl Scope { @@ -29,8 +29,10 @@ impl Scope { self.data.decls.insert(id.clone()); { - if !self.data.queue.contains(id) { - self.data.queue.push(id.clone()); + if let Some((_, cnt)) = self.data.queue.iter_mut().find(|(i, _)| *i == *id) { + *cnt += 1; + } else { + self.data.queue.push((id.clone(), 1)); } } } @@ -40,23 +42,31 @@ impl Scope { return; } + if let Some((_, cnt)) = self.data.queue.iter_mut().find(|(i, _)| *i == *id) { + *cnt += 1; + } + self.data.usages.insert(id.clone()); } pub(super) fn rename( &mut self, + f: &CharFreqInfo, to: &mut RenameMap, preserved: &AHashSet, preserved_symbols: &AHashSet, ) { let mut n = 0; - for id in self.data.queue.take() { - if preserved.contains(&id) { + let mut queue = self.data.queue.take(); + queue.sort_by(|a, b| b.1.cmp(&a.1)); + + for (id, cnt) in queue { + if cnt == 0 || preserved.contains(&id) { continue; } loop { - let (_, sym) = incr_base54(&mut n); + let (_, sym) = f.incr_base54(&mut n); let sym: JsWord = sym.into(); @@ -66,13 +76,15 @@ impl Scope { if self.can_rename(&id, &sym, to) { to.insert(id.clone(), sym); + self.data.decls.remove(&id); + self.data.usages.remove(&id); break; } } } for child in self.children.iter_mut() { - child.rename(to, preserved, preserved_symbols); + child.rename(f, to, preserved, preserved_symbols); } } diff --git a/crates/swc_ecma_minifier/src/pass/mangle_names/private_name.rs b/crates/swc_ecma_minifier/src/pass/mangle_names/private_name.rs index 1666da770b9..d6ea8ea8e67 100644 --- a/crates/swc_ecma_minifier/src/pass/mangle_names/private_name.rs +++ b/crates/swc_ecma_minifier/src/pass/mangle_names/private_name.rs @@ -4,7 +4,7 @@ use swc_ecma_ast::*; use swc_ecma_utils::{ident::IdentLike, Id}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith}; -use crate::util::base54::incr_base54; +use crate::util::base54::{incr_base54, BASE54_DEFAULT_CHARS}; pub fn private_name_mangler(keep_private_props: bool) -> impl Fold + VisitMut { as_folder(PrivateNameMangler { @@ -28,7 +28,7 @@ impl PrivateNameMangler { let new_sym = if let Some(cached) = self.renamed_private.get(&id) { cached.clone() } else { - let sym = incr_base54(&mut self.private_n).1; + let sym = incr_base54(&mut self.private_n, BASE54_DEFAULT_CHARS).1; let sym: JsWord = sym.into(); diff --git a/crates/swc_ecma_minifier/src/pass/mangle_names/real_impl.rs b/crates/swc_ecma_minifier/src/pass/mangle_names/real_impl.rs index 6a018ad9e5d..c43fe130cd5 100644 --- a/crates/swc_ecma_minifier/src/pass/mangle_names/real_impl.rs +++ b/crates/swc_ecma_minifier/src/pass/mangle_names/real_impl.rs @@ -9,18 +9,21 @@ use crate::{marks::Marks, option::MangleOptions, pass::compute_char_freq::CharFr pub(crate) fn name_mangler( options: MangleOptions, - _char_freq_info: CharFreqInfo, + char_freq_info: CharFreqInfo, _marks: Marks, top_level_ctxt: SyntaxContext, ) -> impl VisitMut { Mangler { options, top_level_ctxt, + char_freq_info, } } struct Mangler { options: MangleOptions, + char_freq_info: CharFreqInfo, + /// Used to check `eval`. top_level_ctxt: SyntaxContext, } @@ -54,7 +57,7 @@ impl VisitMut for Mangler { }; m.visit_with(&mut analyzer); - analyzer.into_rename_map(&preserved) + analyzer.into_rename_map(&self.char_freq_info, &preserved) }; m.visit_mut_with(&mut rename(&map)); @@ -74,7 +77,7 @@ impl VisitMut for Mangler { }; s.visit_with(&mut analyzer); - analyzer.into_rename_map(&preserved) + analyzer.into_rename_map(&self.char_freq_info, &preserved) }; s.visit_mut_with(&mut rename(&map)); diff --git a/crates/swc_ecma_minifier/src/pass/mangle_props.rs b/crates/swc_ecma_minifier/src/pass/mangle_props.rs index c38aa40b8ed..99d634dbbab 100644 --- a/crates/swc_ecma_minifier/src/pass/mangle_props.rs +++ b/crates/swc_ecma_minifier/src/pass/mangle_props.rs @@ -13,7 +13,7 @@ use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith}; use crate::{ analyzer::{analyze, ProgramData}, option::ManglePropertiesOptions, - util::base54::incr_base54, + util::base54::{incr_base54, BASE54_DEFAULT_CHARS}, }; pub static JS_ENVIRONMENT_PROPS: Lazy> = Lazy::new(|| { @@ -86,7 +86,7 @@ impl ManglePropertiesState { if let Some(cached) = self.cache.get(name) { Some(cached.clone()) } else { - let sym = incr_base54(&mut self.n).1; + let sym = incr_base54(&mut self.n, BASE54_DEFAULT_CHARS).1; let mangled_name: JsWord = sym.into(); self.cache.insert(name.clone(), mangled_name.clone()); diff --git a/crates/swc_ecma_minifier/src/util/base54.rs b/crates/swc_ecma_minifier/src/util/base54.rs index 7e0cbe7501c..27c70ba9ddc 100644 --- a/crates/swc_ecma_minifier/src/util/base54.rs +++ b/crates/swc_ecma_minifier/src/util/base54.rs @@ -1,9 +1,10 @@ use swc_ecma_ast::IdentExt; -const CHARS: &[u8] = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789"; +pub(crate) static BASE54_DEFAULT_CHARS: &[u8; 64] = + b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789"; /// Note: This returns `a` for 0. -pub(crate) fn incr_base54(init: &mut usize) -> (usize, String) { +pub(crate) fn incr_base54(init: &mut usize, chars: &[u8; 64]) -> (usize, String) { let mut n = *init; *init += 1; @@ -16,10 +17,10 @@ pub(crate) fn incr_base54(init: &mut usize) -> (usize, String) { while n > 0 { n -= 1; - let c = CHARS[n % base] as char; + let c = chars[n % base] as char; if ret.is_empty() && c.is_digit(10) { - return incr_base54(init); + return incr_base54(init, chars); } ret.push(c); @@ -30,7 +31,7 @@ pub(crate) fn incr_base54(init: &mut usize) -> (usize, String) { if ret.is_reserved() || ret.is_reserved_in_strict_bind() || ret.is_reserved_in_strict_mode(true) { - return incr_base54(init); + return incr_base54(init, chars); } (*init - 1, ret) @@ -39,6 +40,7 @@ pub(crate) fn incr_base54(init: &mut usize) -> (usize, String) { #[cfg(test)] mod tests { use super::incr_base54; + use crate::util::base54::BASE54_DEFAULT_CHARS; struct Tester { n: usize, } @@ -49,7 +51,7 @@ mod tests { } fn gen(&mut self, expected: &str) { - let generated = incr_base54(&mut self.n).1; + let generated = incr_base54(&mut self.n, BASE54_DEFAULT_CHARS).1; assert_eq!(generated, expected); } } diff --git a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js index 640df83e91e..8c645f44099 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/2c796e83-0724e2af5f19128a/output.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(a,b,c){var d=c(3454);!function(b,c){a.exports=c()}(this,function(){"use strict";var a,b,c;function e(d,e){if(a)if(b){var f="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+a+")(sharedChunk); ("+b+")(sharedChunk); self.onerror = null;",g={};a(g),c=e(g),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(c.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else b=e;else a=e}return e(["exports"],function(a){"use strict";var b,c="2.7.0",e=f;function f(a,b,c,d){this.cx=3*a,this.bx=3*(c-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*b,this.by=3*(d-b)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=d,this.p2x=c,this.p2y=d}f.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},f.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},f.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},f.prototype.solveCurveX=function(a,b){var c,d,e,f,g;for(void 0===b&&(b=1e-6),e=a,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(e)-a)Math.abs(h))break;e-=f/h}if((e=a)<(c=0))return c;if(e>(d=1))return d;for(;cf?c=e:d=e,e=.5*(d-c)+c}return e},f.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var g=h;function h(a,b){this.x=a,this.y=b}h.prototype={clone:function(){return new h(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(a,b){var c=Math.cos(a),d=Math.sin(a),e=b.y+d*(this.x-b.x)+c*(this.y-b.y);return this.x=b.x+c*(this.x-b.x)-d*(this.y-b.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},h.convert=function(a){return a instanceof h?a:Array.isArray(a)?new h(a[0],a[1]):a};var i="undefined"!=typeof self?self:{},j="undefined"!=typeof Float32Array?Float32Array:Array;function k(){var a=new j(9);return j!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function l(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function m(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],p=b[12],q=b[13],r=b[14],s=b[15],t=c[0],u=c[1],v=c[2],w=c[3];return a[0]=t*d+u*h+v*l+w*p,a[1]=t*e+u*i+v*m+w*q,a[2]=t*f+u*j+v*n+w*r,a[3]=t*g+u*k+v*o+w*s,a[4]=(t=c[4])*d+(u=c[5])*h+(v=c[6])*l+(w=c[7])*p,a[5]=t*e+u*i+v*m+w*q,a[6]=t*f+u*j+v*n+w*r,a[7]=t*g+u*k+v*o+w*s,a[8]=(t=c[8])*d+(u=c[9])*h+(v=c[10])*l+(w=c[11])*p,a[9]=t*e+u*i+v*m+w*q,a[10]=t*f+u*j+v*n+w*r,a[11]=t*g+u*k+v*o+w*s,a[12]=(t=c[12])*d+(u=c[13])*h+(v=c[14])*l+(w=c[15])*p,a[13]=t*e+u*i+v*m+w*q,a[14]=t*f+u*j+v*n+w*r,a[15]=t*g+u*k+v*o+w*s,a}function n(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=c[0],q=c[1],r=c[2];return b===a?(a[12]=b[0]*p+b[4]*q+b[8]*r+b[12],a[13]=b[1]*p+b[5]*q+b[9]*r+b[13],a[14]=b[2]*p+b[6]*q+b[10]*r+b[14],a[15]=b[3]*p+b[7]*q+b[11]*r+b[15]):(e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],a[0]=d=b[0],a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=j,a[7]=k,a[8]=l,a[9]=m,a[10]=n,a[11]=o,a[12]=d*p+h*q+l*r+b[12],a[13]=e*p+i*q+m*r+b[13],a[14]=f*p+j*q+n*r+b[14],a[15]=g*p+k*q+o*r+b[15]),a}function o(a,b,c){var d=c[0],e=c[1],f=c[2];return a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d,a[3]=b[3]*d,a[4]=b[4]*e,a[5]=b[5]*e,a[6]=b[6]*e,a[7]=b[7]*e,a[8]=b[8]*f,a[9]=b[9]*f,a[10]=b[10]*f,a[11]=b[11]*f,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function p(a,b,c){var d=Math.sin(c),e=Math.cos(c),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*e+j*d,a[5]=g*e+k*d,a[6]=h*e+l*d,a[7]=i*e+m*d,a[8]=j*e-f*d,a[9]=k*e-g*d,a[10]=l*e-h*d,a[11]=m*e-i*d,a}function q(a,b,c){var d=Math.sin(c),e=Math.cos(c),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*e-j*d,a[1]=g*e-k*d,a[2]=h*e-l*d,a[3]=i*e-m*d,a[8]=f*d+j*e,a[9]=g*d+k*e,a[10]=h*d+l*e,a[11]=i*d+m*e,a}Math.hypot||(Math.hypot=function(){for(var a=0,b=arguments.length;b--;)a+=arguments[b]*arguments[b];return Math.sqrt(a)});var r=m;function s(){var a=new j(3);return j!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function t(a){var b=new j(3);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b}function u(a){return Math.hypot(a[0],a[1],a[2])}function v(a,b,c){var d=new j(3);return d[0]=a,d[1]=b,d[2]=c,d}function w(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function x(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function y(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function z(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function A(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function B(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function C(a,b){var c=b[0],d=b[1],e=b[2],f=c*c+d*d+e*e;return f>0&&(f=1/Math.sqrt(f)),a[0]=b[0]*f,a[1]=b[1]*f,a[2]=b[2]*f,a}function D(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function E(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function F(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[3]*d+c[7]*e+c[11]*f+c[15];return a[0]=(c[0]*d+c[4]*e+c[8]*f+c[12])/(g=g||1),a[1]=(c[1]*d+c[5]*e+c[9]*f+c[13])/g,a[2]=(c[2]*d+c[6]*e+c[10]*f+c[14])/g,a}function G(a,b,c){var d=c[0],e=c[1],f=c[2],g=b[0],h=b[1],i=b[2],j=e*i-f*h,k=f*g-d*i,l=d*h-e*g,m=e*l-f*k,n=f*j-d*l,o=d*k-e*j,p=2*c[3];return k*=p,l*=p,n*=2,o*=2,a[0]=g+(j*=p)+(m*=2),a[1]=h+k+n,a[2]=i+l+o,a}var H,I=x;function J(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];return a[0]=c[0]*d+c[4]*e+c[8]*f+c[12]*g,a[1]=c[1]*d+c[5]*e+c[9]*f+c[13]*g,a[2]=c[2]*d+c[6]*e+c[10]*f+c[14]*g,a[3]=c[3]*d+c[7]*e+c[11]*f+c[15]*g,a}function K(){var a=new j(4);return j!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function L(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function M(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+g*h,a[1]=e*i+f*h,a[2]=f*i-e*h,a[3]=g*i-d*h,a}function N(a,b){return a[0]===b[0]&&a[1]===b[1]}s(),H=new j(4),j!=Float32Array&&(H[0]=0,H[1]=0,H[2]=0,H[3]=0),s(),v(1,0,0),v(0,1,0),K(),K(),k(),b=new j(2),j!=Float32Array&&(b[0]=0,b[1]=0);const O=Math.PI/180,P=180/Math.PI;function Q(a){return a*O}function R(a){return a*P}const S=[[0,0],[1,0],[1,1],[0,1]];function T(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function U(a,b,c,d){const f=new e(a,b,c,d);return function(a){return f.solve(a)}}const V=U(.25,.1,.25,1);function W(a,b,c){return Math.min(c,Math.max(b,a))}function X(a,b,c){return(c=W((c-a)/(b-a),0,1))*c*(3-2*c)}function Y(a,b,c){const d=c-b,e=((a-b)%d+d)%d+b;return e===b?c:e}function Z(a,b,c){if(!a.length)return c(null,[]);let d=a.length;const e=new Array(a.length);let f=null;a.forEach((a,g)=>{b(a,(a,b)=>{a&&(f=a),e[g]=b,0== --d&&c(f,e)})})}function $(a){const b=[];for(const c in a)b.push(a[c]);return b}function _(a,...b){for(const c of b)for(const d in c)a[d]=c[d];return a}let aa=1;function ba(){return aa++}function ca(){return(function a(b){return b?(b^16*Math.random()>>b/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,a)})()}function da(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function ea(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function fa(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function ga(a,b){return -1!==a.indexOf(b,a.length-b.length)}function ha(a,b,c){const d={};for(const e in a)d[e]=b.call(c||this,a[e],e,a);return d}function ia(a,b,c){const d={};for(const e in a)b.call(c||this,a[e],e,a)&&(d[e]=a[e]);return d}function ja(a){return Array.isArray(a)?a.map(ja):"object"==typeof a&&a?ha(a,ja):a}const ka={};function la(a){ka[a]||("undefined"!=typeof console&&console.warn(a),ka[a]=!0)}function ma(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function na(a){let b=0;for(let c,d,e=0,f=a.length,g=f-1;e@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(a,c,d,e)=>{const f=d||e;return b[c]=!f||f.toLowerCase(),""}),b["max-age"]){const c=parseInt(b["max-age"],10);isNaN(c)?delete b["max-age"]:b["max-age"]=c}return b}let qa,ra,sa,ta=null;function ua(a){if(null==ta){const b=a.navigator?a.navigator.userAgent:null;ta=!!a.safari||!(!b||!(/\b(iPad|iPhone|iPod)\b/.test(b)||b.match("Safari")&&!b.match("Chrome")))}return ta}function va(a){try{const b=i[a];return b.setItem("_mapbox_test_",1),b.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const wa={now:()=>void 0!==sa?sa:i.performance.now(),setNow(a){sa=a},restoreNow(){sa=void 0},frame(a){const b=i.requestAnimationFrame(a);return{cancel:()=>i.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=i.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(qa||(qa=i.document.createElement("a")),qa.href=a,qa.href),get devicePixelRatio(){return i.devicePixelRatio},get prefersReducedMotion(){return!!i.matchMedia&&(null==ra&&(ra=i.matchMedia("(prefers-reduced-motion: reduce)")),ra.matches)}};let xa;const ya={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==xa){const za=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{xa=null!=d.env.API_URL_REGEX?new RegExp(d.env.API_URL_REGEX):za}catch(Aa){xa=za}}return xa},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},Ba={supported:!1,testSupport:function(a){!Ea&&Da&&(Fa?Ga(a):Ca=a)}};let Ca,Da,Ea=!1,Fa=!1;function Ga(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,Da),a.isContextLost())return;Ba.supported=!0}catch(c){}a.deleteTexture(b),Ea=!0}i.document&&((Da=i.document.createElement("img")).onload=function(){Ca&&Ga(Ca),Ca=null,Fa=!0},Da.onerror=function(){Ea=!0,Ca=null},Da.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ha="NO_ACCESS_TOKEN";function Ia(a){return 0===a.indexOf("mapbox:")}function Ja(a){return ya.API_URL_REGEX.test(a)}const Ka=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function La(a){const b=a.match(Ka);if(!b)throw new Error("Unable to parse URL object");return{protocol:b[1],authority:b[2],path:b[3]||"/",params:b[4]?b[4].split("&"):[]}}function Ma(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function Na(a){if(!a)return null;const b=a.split(".");if(!b||3!==b.length)return null;try{return JSON.parse(decodeURIComponent(i.atob(b[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class Oa{constructor(Pa){this.type=Pa,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(Qa){const Ra=Na(ya.ACCESS_TOKEN);let Sa="";return Sa=Ra&&Ra.u?i.btoa(encodeURIComponent(Ra.u).replace(/%([0-9A-F]{2})/g,(a,b)=>String.fromCharCode(Number("0x"+b)))):ya.ACCESS_TOKEN||"",Qa?`mapbox.eventData.${Qa}:${Sa}`:`mapbox.eventData:${Sa}`}fetchEventData(){const Ta=va("localStorage"),Ua=this.getStorageKey(),Va=this.getStorageKey("uuid");if(Ta)try{const Wa=i.localStorage.getItem(Ua);Wa&&(this.eventData=JSON.parse(Wa));const Xa=i.localStorage.getItem(Va);Xa&&(this.anonId=Xa)}catch(Ya){la("Unable to read from LocalStorage")}}saveEventData(){const Za=va("localStorage"),$a=this.getStorageKey(),_a=this.getStorageKey("uuid");if(Za)try{i.localStorage.setItem(_a,this.anonId),Object.keys(this.eventData).length>=1&&i.localStorage.setItem($a,JSON.stringify(this.eventData))}catch(ab){la("Unable to write to LocalStorage")}}processRequests(bb){}postEvent(cb,db,eb,fb){if(!ya.EVENTS_URL)return;const gb=La(ya.EVENTS_URL);gb.params.push(`access_token=${fb||ya.ACCESS_TOKEN||""}`);const hb={event:this.type,created:new Date(cb).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:"01",userId:this.anonId},ib=db?_(hb,db):hb,jb={url:Ma(gb),headers:{"Content-Type":"text/plain"},body:JSON.stringify([ib])};this.pendingRequest=Jb(jb,a=>{this.pendingRequest=null,eb(a),this.saveEventData(),this.processRequests(fb)})}queueRequest(kb,lb){this.queue.push(kb),this.processRequests(lb)}}const mb=new class extends Oa{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(b,c){ya.EVENTS_URL&&ya.ACCESS_TOKEN&&Array.isArray(b)&&b.some(a=>Ia(a)||Ja(a))&&this.queueRequest(Date.now(),c)}processRequests(d){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=Na(ya.ACCESS_TOKEN),f=e?e.u:ya.ACCESS_TOKEN;let g=f!==this.eventData.tokenU;ea(this.anonId)||(this.anonId=ca(),g=!0);const h=this.queue.shift();if(this.eventData.lastSuccess){const i=new Date(this.eventData.lastSuccess),j=new Date(h),k=(h-this.eventData.lastSuccess)/864e5;g=g||k>=1||k< -1||i.getDate()!==j.getDate()}else g=!0;if(!g)return this.processRequests();this.postEvent(h,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=h,this.eventData.tokenU=f)},d)}},nb=mb.postTurnstileEvent.bind(mb),ob=new class extends Oa{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(a,b,c,d){this.skuToken=b,this.errorCb=d,ya.EVENTS_URL&&(c||ya.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},c):this.errorCb(new Error(Ha)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:f,timestamp:g}=this.queue.shift();f&&this.success[f]||(this.anonId||this.fetchEventData(),ea(this.anonId)||(this.anonId=ca()),this.postEvent(g,{skuToken:this.skuToken},a=>{a?this.errorCb(a):f&&(this.success[f]=!0)},e))}},pb=ob.postMapLoadEvent.bind(ob),qb=new class extends Oa{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(a,b,c,d){if(!ya.API_URL||!ya.SESSION_PATH)return;const e=La(ya.API_URL+ya.SESSION_PATH);e.params.push(`sku=${b||""}`),e.params.push(`access_token=${d||ya.ACCESS_TOKEN||""}`);const f={url:Ma(e),headers:{"Content-Type":"text/plain"}};this.pendingRequest=Kb(f,a=>{this.pendingRequest=null,c(a),this.saveEventData(),this.processRequests(d)})}getSessionAPI(g,h,i,j){this.skuToken=h,this.errorCb=j,ya.SESSION_PATH&&ya.API_URL&&(i||ya.ACCESS_TOKEN?this.queueRequest({id:g,timestamp:Date.now()},i):this.errorCb(new Error(Ha)))}processRequests(k){if(this.pendingRequest||0===this.queue.length)return;const{id:l,timestamp:m}=this.queue.shift();l&&this.success[l]||this.getSession(m,this.skuToken,a=>{a?this.errorCb(a):l&&(this.success[l]=!0)},k)}},rb=qb.getSessionAPI.bind(qb),sb=new Set,tb="mapbox-tiles";let ub,vb,wb=500,xb=50;function yb(){i.caches&&!ub&&(ub=i.caches.open(tb))}function zb(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let Ab=1/0;const Bb={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Bb);class Cb extends Error{constructor(Db,Eb,Fb){401===Eb&&Ja(Fb)&&(Db+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(Db),this.status=Eb,this.url=Fb}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Gb=oa()?()=>self.worker&&self.worker.referrer:()=>("blob:"===i.location.protocol?i.parent:i).location.href,Hb=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(Gb())&&!/^\w+:/.test(c))){if(i.fetch&&i.Request&&i.AbortController&&i.Request.prototype.hasOwnProperty("signal"))return(function(a,b){var c;const d=new i.AbortController,e=new i.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:Gb(),signal:d.signal});let f=!1,g=!1;const h=(c=e.url).indexOf("sku=")>0&&Ja(c);"json"===a.type&&e.headers.set("Accept","application/json");const j=(c,d,f)=>{if(g)return;if(c&&"SecurityError"!==c.message&&la(c),d&&f)return k(d);const j=Date.now();i.fetch(e).then(c=>{if(c.ok){const d=h?c.clone():null;return k(c,d,j)}return b(new Cb(c.statusText,c.status,a.url))}).catch(a=>{20!==a.code&&b(new Error(a.message))})},k=(c,d,h)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{g||(d&&h&&(function(a,b,c){if(yb(),!ub)return;const d={status:b.status,statusText:b.statusText,headers:new i.Headers};b.headers.forEach((a,b)=>d.headers.set(b,a));const e=pa(b.headers.get("Cache-Control")||"");e["no-store"]||(e["max-age"]&&d.headers.set("Expires",new Date(c+1e3*e["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||(function(a,b){if(void 0===vb)try{new Response(new ReadableStream),vb=!0}catch(c){vb=!1}vb?b(a.body):a.blob().then(b)})(b,b=>{const c=new i.Response(b,d);yb(),ub&&ub.then(b=>b.put(zb(a.url),c)).catch(a=>la(a.message))}))})(e,d,h),f=!0,b(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{g||b(new Error(a.message))})};return h?(function(a,b){if(yb(),!ub)return b(null);const c=zb(a.url);ub.then(a=>{a.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=pa(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);a.delete(c),e&&a.put(c,d.clone()),b(null,d,e)}).catch(b)}).catch(b)})(e,j):j(null,null),{cancel:()=>{g=!0,f||d.abort()}}})(a,b);if(oa()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return(function(a,b){const c=new i.XMLHttpRequest;for(const d in c.open(a.method||"GET",a.url,!0),"arrayBuffer"===a.type&&(c.responseType="arraybuffer"),a.headers)c.setRequestHeader(d,a.headers[d]);return"json"===a.type&&(c.responseType="text",c.setRequestHeader("Accept","application/json")),c.withCredentials="include"===a.credentials,c.onerror=()=>{b(new Error(c.statusText))},c.onload=()=>{if((c.status>=200&&c.status<300||0===c.status)&&null!==c.response){let d=c.response;if("json"===a.type)try{d=JSON.parse(c.response)}catch(e){return b(e)}b(null,d,c.getResponseHeader("Cache-Control"),c.getResponseHeader("Expires"))}else b(new Cb(c.statusText,c.status,a.url))},c.send(a.body),{cancel:()=>c.abort()}})(a,b)},Ib=function(a,b){return Hb(_(a,{type:"arrayBuffer"}),b)},Jb=function(a,b){return Hb(_(a,{method:"POST"}),b)},Kb=function(a,b){return Hb(_(a,{method:"GET"}),b)};function Lb(a){const b=i.document.createElement("a");return b.href=a,b.protocol===i.document.location.protocol&&b.host===i.document.location.host}const Mb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Nb,Ob;Nb=[],Ob=0;const Pb=function(a,b){if(Ba.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),Ob>=ya.MAX_PARALLEL_IMAGE_REQUESTS){const c={requestParameters:a,callback:b,cancelled:!1,cancel(){this.cancelled=!0}};return Nb.push(c),c}Ob++;let d=!1;const e=()=>{if(!d)for(d=!0,Ob--;Nb.length&&Ob{e(),a?b(a):c&&(i.createImageBitmap?(function(a,b){const c=new i.Blob([new Uint8Array(a)],{type:"image/png"});i.createImageBitmap(c).then(a=>{b(null,a)}).catch(a=>{b(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})})(c,(a,c)=>b(a,c,d,f)):(function(a,b){const c=new i.Image,d=i.URL;c.onload=()=>{b(null,c),d.revokeObjectURL(c.src),c.onload=null,i.requestAnimationFrame(()=>{c.src=Mb})},c.onerror=()=>b(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const e=new i.Blob([new Uint8Array(a)],{type:"image/png"});c.src=a.byteLength?d.createObjectURL(e):Mb})(c,(a,c)=>b(a,c,d,f)))});return{cancel:()=>{f.cancel(),e()}}};function Qb(a,b,c){c[a]&& -1!==c[a].indexOf(b)||(c[a]=c[a]||[],c[a].push(b))}function Rb(a,b,c){if(c&&c[a]){const d=c[a].indexOf(b);-1!==d&&c[a].splice(d,1)}}class Sb{constructor(Tb,Ub={}){_(this,Ub),this.type=Tb}}class Vb extends Sb{constructor(Wb,Xb={}){super("error",_({error:Wb},Xb))}}class Yb{on(Zb,$b){return this._listeners=this._listeners||{},Qb(Zb,$b,this._listeners),this}off(_b,ac){return Rb(_b,ac,this._listeners),Rb(_b,ac,this._oneTimeListeners),this}once(bc,cc){return cc?(this._oneTimeListeners=this._oneTimeListeners||{},Qb(bc,cc,this._oneTimeListeners),this):new Promise(a=>this.once(bc,a))}fire(dc,ec){"string"==typeof dc&&(dc=new Sb(dc,ec||{}));const fc=dc.type;if(this.listens(fc)){dc.target=this;const gc=this._listeners&&this._listeners[fc]?this._listeners[fc].slice():[];for(const hc of gc)hc.call(this,dc);const ic=this._oneTimeListeners&&this._oneTimeListeners[fc]?this._oneTimeListeners[fc].slice():[];for(const jc of ic)Rb(fc,jc,this._oneTimeListeners),jc.call(this,dc);const kc=this._eventedParent;kc&&(_(dc,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),kc.fire(dc))}else dc instanceof Vb&&console.error(dc.error);return this}listens(lc){return!!(this._listeners&&this._listeners[lc]&&this._listeners[lc].length>0||this._oneTimeListeners&&this._oneTimeListeners[lc]&&this._oneTimeListeners[lc].length>0||this._eventedParent&&this._eventedParent.listens(lc))}setEventedParent(mc,nc){return this._eventedParent=mc,this._eventedParentData=nc,this}}var oc=JSON.parse("{\"$version\":8,\"$root\":{\"version\":{\"required\":true,\"type\":\"enum\",\"values\":[8]},\"name\":{\"type\":\"string\"},\"metadata\":{\"type\":\"*\"},\"center\":{\"type\":\"array\",\"value\":\"number\"},\"zoom\":{\"type\":\"number\"},\"bearing\":{\"type\":\"number\",\"default\":0,\"period\":360,\"units\":\"degrees\"},\"pitch\":{\"type\":\"number\",\"default\":0,\"units\":\"degrees\"},\"light\":{\"type\":\"light\"},\"terrain\":{\"type\":\"terrain\"},\"fog\":{\"type\":\"fog\"},\"sources\":{\"required\":true,\"type\":\"sources\"},\"sprite\":{\"type\":\"string\"},\"glyphs\":{\"type\":\"string\"},\"transition\":{\"type\":\"transition\"},\"projection\":{\"type\":\"projection\"},\"layers\":{\"required\":true,\"type\":\"array\",\"value\":\"layer\"}},\"sources\":{\"*\":{\"type\":\"source\"}},\"source\":[\"source_vector\",\"source_raster\",\"source_raster_dem\",\"source_geojson\",\"source_video\",\"source_image\"],\"source_vector\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"vector\":{}}},\"url\":{\"type\":\"string\"},\"tiles\":{\"type\":\"array\",\"value\":\"string\"},\"bounds\":{\"type\":\"array\",\"value\":\"number\",\"length\":4,\"default\":[-180,-85.051129,180,85.051129]},\"scheme\":{\"type\":\"enum\",\"values\":{\"xyz\":{},\"tms\":{}},\"default\":\"xyz\"},\"minzoom\":{\"type\":\"number\",\"default\":0},\"maxzoom\":{\"type\":\"number\",\"default\":22},\"attribution\":{\"type\":\"string\"},\"promoteId\":{\"type\":\"promoteId\"},\"volatile\":{\"type\":\"boolean\",\"default\":false},\"*\":{\"type\":\"*\"}},\"source_raster\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"raster\":{}}},\"url\":{\"type\":\"string\"},\"tiles\":{\"type\":\"array\",\"value\":\"string\"},\"bounds\":{\"type\":\"array\",\"value\":\"number\",\"length\":4,\"default\":[-180,-85.051129,180,85.051129]},\"minzoom\":{\"type\":\"number\",\"default\":0},\"maxzoom\":{\"type\":\"number\",\"default\":22},\"tileSize\":{\"type\":\"number\",\"default\":512,\"units\":\"pixels\"},\"scheme\":{\"type\":\"enum\",\"values\":{\"xyz\":{},\"tms\":{}},\"default\":\"xyz\"},\"attribution\":{\"type\":\"string\"},\"volatile\":{\"type\":\"boolean\",\"default\":false},\"*\":{\"type\":\"*\"}},\"source_raster_dem\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"raster-dem\":{}}},\"url\":{\"type\":\"string\"},\"tiles\":{\"type\":\"array\",\"value\":\"string\"},\"bounds\":{\"type\":\"array\",\"value\":\"number\",\"length\":4,\"default\":[-180,-85.051129,180,85.051129]},\"minzoom\":{\"type\":\"number\",\"default\":0},\"maxzoom\":{\"type\":\"number\",\"default\":22},\"tileSize\":{\"type\":\"number\",\"default\":512,\"units\":\"pixels\"},\"attribution\":{\"type\":\"string\"},\"encoding\":{\"type\":\"enum\",\"values\":{\"terrarium\":{},\"mapbox\":{}},\"default\":\"mapbox\"},\"volatile\":{\"type\":\"boolean\",\"default\":false},\"*\":{\"type\":\"*\"}},\"source_geojson\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"geojson\":{}}},\"data\":{\"type\":\"*\"},\"maxzoom\":{\"type\":\"number\",\"default\":18},\"attribution\":{\"type\":\"string\"},\"buffer\":{\"type\":\"number\",\"default\":128,\"maximum\":512,\"minimum\":0},\"filter\":{\"type\":\"*\"},\"tolerance\":{\"type\":\"number\",\"default\":0.375},\"cluster\":{\"type\":\"boolean\",\"default\":false},\"clusterRadius\":{\"type\":\"number\",\"default\":50,\"minimum\":0},\"clusterMaxZoom\":{\"type\":\"number\"},\"clusterMinPoints\":{\"type\":\"number\"},\"clusterProperties\":{\"type\":\"*\"},\"lineMetrics\":{\"type\":\"boolean\",\"default\":false},\"generateId\":{\"type\":\"boolean\",\"default\":false},\"promoteId\":{\"type\":\"promoteId\"}},\"source_video\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"video\":{}}},\"urls\":{\"required\":true,\"type\":\"array\",\"value\":\"string\"},\"coordinates\":{\"required\":true,\"type\":\"array\",\"length\":4,\"value\":{\"type\":\"array\",\"length\":2,\"value\":\"number\"}}},\"source_image\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"image\":{}}},\"url\":{\"required\":true,\"type\":\"string\"},\"coordinates\":{\"required\":true,\"type\":\"array\",\"length\":4,\"value\":{\"type\":\"array\",\"length\":2,\"value\":\"number\"}}},\"layer\":{\"id\":{\"type\":\"string\",\"required\":true},\"type\":{\"type\":\"enum\",\"values\":{\"fill\":{},\"line\":{},\"symbol\":{},\"circle\":{},\"heatmap\":{},\"fill-extrusion\":{},\"raster\":{},\"hillshade\":{},\"background\":{},\"sky\":{}},\"required\":true},\"metadata\":{\"type\":\"*\"},\"source\":{\"type\":\"string\"},\"source-layer\":{\"type\":\"string\"},\"minzoom\":{\"type\":\"number\",\"minimum\":0,\"maximum\":24},\"maxzoom\":{\"type\":\"number\",\"minimum\":0,\"maximum\":24},\"filter\":{\"type\":\"filter\"},\"layout\":{\"type\":\"layout\"},\"paint\":{\"type\":\"paint\"}},\"layout\":[\"layout_fill\",\"layout_line\",\"layout_circle\",\"layout_heatmap\",\"layout_fill-extrusion\",\"layout_symbol\",\"layout_raster\",\"layout_hillshade\",\"layout_background\",\"layout_sky\"],\"layout_background\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_sky\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_fill\":{\"fill-sort-key\":{\"type\":\"number\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_circle\":{\"circle-sort-key\":{\"type\":\"number\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_heatmap\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_fill-extrusion\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_line\":{\"line-cap\":{\"type\":\"enum\",\"values\":{\"butt\":{},\"round\":{},\"square\":{}},\"default\":\"butt\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"line-join\":{\"type\":\"enum\",\"values\":{\"bevel\":{},\"round\":{},\"miter\":{}},\"default\":\"miter\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"line-miter-limit\":{\"type\":\"number\",\"default\":2,\"requires\":[{\"line-join\":\"miter\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-round-limit\":{\"type\":\"number\",\"default\":1.05,\"requires\":[{\"line-join\":\"round\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-sort-key\":{\"type\":\"number\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_symbol\":{\"symbol-placement\":{\"type\":\"enum\",\"values\":{\"point\":{},\"line\":{},\"line-center\":{}},\"default\":\"point\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"symbol-spacing\":{\"type\":\"number\",\"default\":250,\"minimum\":1,\"units\":\"pixels\",\"requires\":[{\"symbol-placement\":\"line\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"symbol-avoid-edges\":{\"type\":\"boolean\",\"default\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"symbol-sort-key\":{\"type\":\"number\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"symbol-z-order\":{\"type\":\"enum\",\"values\":{\"auto\":{},\"viewport-y\":{},\"source\":{}},\"default\":\"auto\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-allow-overlap\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-ignore-placement\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-optional\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"icon-image\",\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-rotation-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{},\"auto\":{}},\"default\":\"auto\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-size\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"units\":\"factor of the original icon size\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-text-fit\":{\"type\":\"enum\",\"values\":{\"none\":{},\"width\":{},\"height\":{},\"both\":{}},\"default\":\"none\",\"requires\":[\"icon-image\",\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-text-fit-padding\":{\"type\":\"array\",\"value\":\"number\",\"length\":4,\"default\":[0,0,0,0],\"units\":\"pixels\",\"requires\":[\"icon-image\",\"text-field\",{\"icon-text-fit\":[\"both\",\"width\",\"height\"]}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-image\":{\"type\":\"resolvedImage\",\"tokens\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-rotate\":{\"type\":\"number\",\"default\":0,\"period\":360,\"units\":\"degrees\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-padding\":{\"type\":\"number\",\"default\":2,\"minimum\":0,\"units\":\"pixels\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-keep-upright\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"icon-image\",{\"icon-rotation-alignment\":\"map\"},{\"symbol-placement\":[\"line\",\"line-center\"]}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-offset\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-anchor\":{\"type\":\"enum\",\"values\":{\"center\":{},\"left\":{},\"right\":{},\"top\":{},\"bottom\":{},\"top-left\":{},\"top-right\":{},\"bottom-left\":{},\"bottom-right\":{}},\"default\":\"center\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-pitch-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{},\"auto\":{}},\"default\":\"auto\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-pitch-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{},\"auto\":{}},\"default\":\"auto\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-rotation-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{},\"auto\":{}},\"default\":\"auto\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-field\":{\"type\":\"formatted\",\"default\":\"\",\"tokens\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-font\":{\"type\":\"array\",\"value\":\"string\",\"default\":[\"Open Sans Regular\",\"Arial Unicode MS Regular\"],\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-size\":{\"type\":\"number\",\"default\":16,\"minimum\":0,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-max-width\":{\"type\":\"number\",\"default\":10,\"minimum\":0,\"units\":\"ems\",\"requires\":[\"text-field\",{\"symbol-placement\":[\"point\"]}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-line-height\":{\"type\":\"number\",\"default\":1.2,\"units\":\"ems\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-letter-spacing\":{\"type\":\"number\",\"default\":0,\"units\":\"ems\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-justify\":{\"type\":\"enum\",\"values\":{\"auto\":{},\"left\":{},\"center\":{},\"right\":{}},\"default\":\"center\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-radial-offset\":{\"type\":\"number\",\"units\":\"ems\",\"default\":0,\"requires\":[\"text-field\"],\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]}},\"text-variable-anchor\":{\"type\":\"array\",\"value\":\"enum\",\"values\":{\"center\":{},\"left\":{},\"right\":{},\"top\":{},\"bottom\":{},\"top-left\":{},\"top-right\":{},\"bottom-left\":{},\"bottom-right\":{}},\"requires\":[\"text-field\",{\"symbol-placement\":[\"point\"]}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-anchor\":{\"type\":\"enum\",\"values\":{\"center\":{},\"left\":{},\"right\":{},\"top\":{},\"bottom\":{},\"top-left\":{},\"top-right\":{},\"bottom-left\":{},\"bottom-right\":{}},\"default\":\"center\",\"requires\":[\"text-field\",{\"!\":\"text-variable-anchor\"}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-max-angle\":{\"type\":\"number\",\"default\":45,\"units\":\"degrees\",\"requires\":[\"text-field\",{\"symbol-placement\":[\"line\",\"line-center\"]}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-writing-mode\":{\"type\":\"array\",\"value\":\"enum\",\"values\":{\"horizontal\":{},\"vertical\":{}},\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-rotate\":{\"type\":\"number\",\"default\":0,\"period\":360,\"units\":\"degrees\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-padding\":{\"type\":\"number\",\"default\":2,\"minimum\":0,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-keep-upright\":{\"type\":\"boolean\",\"default\":true,\"requires\":[\"text-field\",{\"text-rotation-alignment\":\"map\"},{\"symbol-placement\":[\"line\",\"line-center\"]}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-transform\":{\"type\":\"enum\",\"values\":{\"none\":{},\"uppercase\":{},\"lowercase\":{}},\"default\":\"none\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-offset\":{\"type\":\"array\",\"value\":\"number\",\"units\":\"ems\",\"length\":2,\"default\":[0,0],\"requires\":[\"text-field\",{\"!\":\"text-radial-offset\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-allow-overlap\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-ignore-placement\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-optional\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"text-field\",\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_raster\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_hillshade\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"filter\":{\"type\":\"array\",\"value\":\"*\"},\"filter_symbol\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\",\"pitch\",\"distance-from-center\"]}},\"filter_fill\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_line\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_circle\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_fill-extrusion\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_heatmap\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_operator\":{\"type\":\"enum\",\"values\":{\"==\":{},\"!=\":{},\">\":{},\">=\":{},\"<\":{},\"<=\":{},\"in\":{},\"!in\":{},\"all\":{},\"any\":{},\"none\":{},\"has\":{},\"!has\":{},\"within\":{}}},\"geometry_type\":{\"type\":\"enum\",\"values\":{\"Point\":{},\"LineString\":{},\"Polygon\":{}}},\"function\":{\"expression\":{\"type\":\"expression\"},\"stops\":{\"type\":\"array\",\"value\":\"function_stop\"},\"base\":{\"type\":\"number\",\"default\":1,\"minimum\":0},\"property\":{\"type\":\"string\",\"default\":\"$zoom\"},\"type\":{\"type\":\"enum\",\"values\":{\"identity\":{},\"exponential\":{},\"interval\":{},\"categorical\":{}},\"default\":\"exponential\"},\"colorSpace\":{\"type\":\"enum\",\"values\":{\"rgb\":{},\"lab\":{},\"hcl\":{}},\"default\":\"rgb\"},\"default\":{\"type\":\"*\",\"required\":false}},\"function_stop\":{\"type\":\"array\",\"minimum\":0,\"maximum\":24,\"value\":[\"number\",\"color\"],\"length\":2},\"expression\":{\"type\":\"array\",\"value\":\"*\",\"minimum\":1},\"fog\":{\"range\":{\"type\":\"array\",\"default\":[0.5,10],\"minimum\":-20,\"maximum\":20,\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"color\":{\"type\":\"color\",\"property-type\":\"data-constant\",\"default\":\"#ffffff\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"horizon-blend\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":0.1,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true}},\"light\":{\"anchor\":{\"type\":\"enum\",\"default\":\"viewport\",\"values\":{\"map\":{},\"viewport\":{}},\"property-type\":\"data-constant\",\"transition\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]}},\"position\":{\"type\":\"array\",\"default\":[1.15,210,30],\"length\":3,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"color\":{\"type\":\"color\",\"property-type\":\"data-constant\",\"default\":\"#ffffff\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"intensity\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":0.5,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true}},\"projection\":{\"name\":{\"type\":\"enum\",\"values\":{\"albers\":{},\"equalEarth\":{},\"equirectangular\":{},\"lambertConformalConic\":{},\"mercator\":{},\"naturalEarth\":{},\"winkelTripel\":{}},\"default\":\"mercator\",\"required\":true},\"center\":{\"type\":\"array\",\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":false,\"requires\":[{\"name\":[\"albers\",\"lambertConformalConic\"]}]},\"parallels\":{\"type\":\"array\",\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":false,\"requires\":[{\"name\":[\"albers\",\"lambertConformalConic\"]}]}},\"terrain\":{\"source\":{\"type\":\"string\",\"required\":true},\"exaggeration\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":1,\"minimum\":0,\"maximum\":1000,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true}},\"paint\":[\"paint_fill\",\"paint_line\",\"paint_circle\",\"paint_heatmap\",\"paint_fill-extrusion\",\"paint_symbol\",\"paint_raster\",\"paint_hillshade\",\"paint_background\",\"paint_sky\"],\"paint_fill\":{\"fill-antialias\":{\"type\":\"boolean\",\"default\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[{\"!\":\"fill-pattern\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-outline-color\":{\"type\":\"color\",\"transition\":true,\"requires\":[{\"!\":\"fill-pattern\"},{\"fill-antialias\":true}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"fill-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-pattern\":{\"type\":\"resolvedImage\",\"transition\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"cross-faded-data-driven\"}},\"paint_fill-extrusion\":{\"fill-extrusion-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[{\"!\":\"fill-extrusion-pattern\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"fill-extrusion-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-pattern\":{\"type\":\"resolvedImage\",\"transition\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"cross-faded-data-driven\"},\"fill-extrusion-height\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"units\":\"meters\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-base\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"units\":\"meters\",\"transition\":true,\"requires\":[\"fill-extrusion-height\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-vertical-gradient\":{\"type\":\"boolean\",\"default\":true,\"transition\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_line\":{\"line-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[{\"!\":\"line-pattern\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"line-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-width\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-gap-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-offset\":{\"type\":\"number\",\"default\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-dasharray\":{\"type\":\"array\",\"value\":\"number\",\"minimum\":0,\"transition\":true,\"units\":\"line widths\",\"requires\":[{\"!\":\"line-pattern\"}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"cross-faded-data-driven\"},\"line-pattern\":{\"type\":\"resolvedImage\",\"transition\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"cross-faded-data-driven\"},\"line-gradient\":{\"type\":\"color\",\"transition\":false,\"requires\":[{\"!\":\"line-pattern\"},{\"source\":\"geojson\",\"has\":{\"lineMetrics\":true}}],\"expression\":{\"interpolated\":true,\"parameters\":[\"line-progress\"]},\"property-type\":\"color-ramp\"}},\"paint_circle\":{\"circle-radius\":{\"type\":\"number\",\"default\":5,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-blur\":{\"type\":\"number\",\"default\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"circle-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-pitch-scale\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-pitch-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"viewport\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-stroke-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-stroke-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-stroke-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"}},\"paint_heatmap\":{\"heatmap-radius\":{\"type\":\"number\",\"default\":30,\"minimum\":1,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"heatmap-weight\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":false,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"heatmap-intensity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"heatmap-color\":{\"type\":\"color\",\"default\":[\"interpolate\",[\"linear\"],[\"heatmap-density\"],0,\"rgba(0, 0, 255, 0)\",0.1,\"royalblue\",0.3,\"cyan\",0.5,\"lime\",0.7,\"yellow\",1,\"red\"],\"transition\":false,\"expression\":{\"interpolated\":true,\"parameters\":[\"heatmap-density\"]},\"property-type\":\"color-ramp\"},\"heatmap-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_symbol\":{\"icon-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-halo-color\":{\"type\":\"color\",\"default\":\"rgba(0, 0, 0, 0)\",\"transition\":true,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-halo-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-halo-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"icon-image\",\"icon-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"overridable\":true,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-halo-color\":{\"type\":\"color\",\"default\":\"rgba(0, 0, 0, 0)\",\"transition\":true,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-halo-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-halo-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"text-field\",\"text-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_raster\":{\"raster-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-hue-rotate\":{\"type\":\"number\",\"default\":0,\"period\":360,\"transition\":true,\"units\":\"degrees\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-brightness-min\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-brightness-max\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-saturation\":{\"type\":\"number\",\"default\":0,\"minimum\":-1,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-contrast\":{\"type\":\"number\",\"default\":0,\"minimum\":-1,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-resampling\":{\"type\":\"enum\",\"values\":{\"linear\":{},\"nearest\":{}},\"default\":\"linear\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-fade-duration\":{\"type\":\"number\",\"default\":300,\"minimum\":0,\"transition\":false,\"units\":\"milliseconds\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_hillshade\":{\"hillshade-illumination-direction\":{\"type\":\"number\",\"default\":335,\"minimum\":0,\"maximum\":359,\"transition\":false,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-illumination-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"viewport\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-exaggeration\":{\"type\":\"number\",\"default\":0.5,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-shadow-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-highlight-color\":{\"type\":\"color\",\"default\":\"#FFFFFF\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-accent-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_background\":{\"background-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[{\"!\":\"background-pattern\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"background-pattern\":{\"type\":\"resolvedImage\",\"transition\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"cross-faded\"},\"background-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_sky\":{\"sky-type\":{\"type\":\"enum\",\"values\":{\"gradient\":{},\"atmosphere\":{}},\"default\":\"atmosphere\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-atmosphere-sun\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"units\":\"degrees\",\"minimum\":[0,0],\"maximum\":[360,180],\"transition\":false,\"requires\":[{\"sky-type\":\"atmosphere\"}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-atmosphere-sun-intensity\":{\"type\":\"number\",\"requires\":[{\"sky-type\":\"atmosphere\"}],\"default\":10,\"minimum\":0,\"maximum\":100,\"transition\":false,\"property-type\":\"data-constant\"},\"sky-gradient-center\":{\"type\":\"array\",\"requires\":[{\"sky-type\":\"gradient\"}],\"value\":\"number\",\"default\":[0,0],\"length\":2,\"units\":\"degrees\",\"minimum\":[0,0],\"maximum\":[360,180],\"transition\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-gradient-radius\":{\"type\":\"number\",\"requires\":[{\"sky-type\":\"gradient\"}],\"default\":90,\"minimum\":0,\"maximum\":180,\"transition\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-gradient\":{\"type\":\"color\",\"default\":[\"interpolate\",[\"linear\"],[\"sky-radial-progress\"],0.8,\"#87ceeb\",1,\"white\"],\"transition\":false,\"requires\":[{\"sky-type\":\"gradient\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"sky-radial-progress\"]},\"property-type\":\"color-ramp\"},\"sky-atmosphere-halo-color\":{\"type\":\"color\",\"default\":\"white\",\"transition\":false,\"requires\":[{\"sky-type\":\"atmosphere\"}],\"property-type\":\"data-constant\"},\"sky-atmosphere-color\":{\"type\":\"color\",\"default\":\"white\",\"transition\":false,\"requires\":[{\"sky-type\":\"atmosphere\"}],\"property-type\":\"data-constant\"},\"sky-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"transition\":{\"duration\":{\"type\":\"number\",\"default\":300,\"minimum\":0,\"units\":\"milliseconds\"},\"delay\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"units\":\"milliseconds\"}},\"property-type\":{\"data-driven\":{\"type\":\"property-type\"},\"cross-faded\":{\"type\":\"property-type\"},\"cross-faded-data-driven\":{\"type\":\"property-type\"},\"color-ramp\":{\"type\":\"property-type\"},\"data-constant\":{\"type\":\"property-type\"},\"constant\":{\"type\":\"property-type\"}},\"promoteId\":{\"*\":{\"type\":\"string\"}}}");class pc{constructor(qc,rc,sc,tc){this.message=(qc?`${qc}: `:"")+sc,tc&&(this.identifier=tc),null!=rc&&rc.__line__&&(this.line=rc.__line__)}}function uc(a){const b=a.value;return b?[new pc(a.key,b,"constants have been deprecated as of v8")]:[]}function vc(a,...b){for(const c of b)for(const d in c)a[d]=c[d];return a}function wc(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function xc(a){if(Array.isArray(a))return a.map(xc);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=xc(a[c]);return b}return wc(a)}class yc extends Error{constructor(zc,Ac){super(Ac),this.message=Ac,this.key=zc}}class Bc{constructor(Cc,Dc=[]){for(const[Ec,Fc]of(this.parent=Cc,this.bindings={},Dc))this.bindings[Ec]=Fc}concat(Gc){return new Bc(this,Gc)}get(Hc){if(this.bindings[Hc])return this.bindings[Hc];if(this.parent)return this.parent.get(Hc);throw new Error(`${Hc} not found in scope.`)}has(Ic){return!!this.bindings[Ic]|| !!this.parent&&this.parent.has(Ic)}}const Jc={kind:"null"},Kc={kind:"number"},Lc={kind:"string"},Mc={kind:"boolean"},Nc={kind:"color"},Oc={kind:"object"},Pc={kind:"value"},Qc={kind:"collator"},Rc={kind:"formatted"},Sc={kind:"resolvedImage"};function Tc(a,b){return{kind:"array",itemType:a,N:b}}function Uc(a){if("array"===a.kind){const b=Uc(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const Vc=[Jc,Kc,Lc,Mc,Nc,Rc,Oc,Tc(Pc),Sc];function Wc(a,b){if("error"===b.kind)return null;if("array"===a.kind){if("array"===b.kind&&(0===b.N&&"value"===b.itemType.kind||!Wc(a.itemType,b.itemType))&&("number"!=typeof a.N||a.N===b.N))return null}else{if(a.kind===b.kind)return null;if("value"===a.kind){for(const c of Vc)if(!Wc(c,b))return null}}return`Expected ${Uc(a)} but found ${Uc(b)} instead.`}function Xc(a,b){return b.some(b=>b.kind===a.kind)}function Yc(a,b){return b.some(b=>"null"===b?null===a:"array"===b?Array.isArray(a):"object"===b?a&&!Array.isArray(a)&&"object"==typeof a:b===typeof a)}function Zc(a){var b={exports:{}};return a(b,b.exports),b.exports}var $c=Zc(function(a,b){var c={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(a,b,c){return c<0?c+=1:c>1&&(c-=1),6*c<1?a+(b-a)*c*6:2*c<1?b:3*c<2?a+(b-a)*(2/3-c)*6:a}try{b.parseCSSColor=function(a){var b,h=a.replace(/ /g,"").toLowerCase();if(h in c)return c[h].slice();if("#"===h[0])return 4===h.length?(b=parseInt(h.substr(1),16))>=0&&b<=4095?[(3840&b)>>4|(3840&b)>>8,240&b|(240&b)>>4,15&b|(15&b)<<4,1]:null:7===h.length&&(b=parseInt(h.substr(1),16))>=0&&b<=16777215?[(16711680&b)>>16,(65280&b)>>8,255&b,1]:null;var i=h.indexOf("("),j=h.indexOf(")");if(-1!==i&&j+1===h.length){var k=h.substr(0,i),l=h.substr(i+1,j-(i+1)).split(","),m=1;switch(k){case"rgba":if(4!==l.length)return null;m=f(l.pop());case"rgb":return 3!==l.length?null:[e(l[0]),e(l[1]),e(l[2]),m];case"hsla":if(4!==l.length)return null;m=f(l.pop());case"hsl":if(3!==l.length)return null;var n=(parseFloat(l[0])%360+360)%360/360,o=f(l[1]),p=f(l[2]),q=p<=.5?p*(o+1):p+o-p*o,r=2*p-q;return[d(255*g(r,q,n+1/3)),d(255*g(r,q,n)),d(255*g(r,q,n-1/3)),m];default:return null}}return null}}catch(h){}});class _c{constructor(ad,bd,cd,dd=1){this.r=ad,this.g=bd,this.b=cd,this.a=dd}static parse(ed){if(!ed)return;if(ed instanceof _c)return ed;if("string"!=typeof ed)return;const fd=$c.parseCSSColor(ed);return fd?new _c(fd[0]/255*fd[3],fd[1]/255*fd[3],fd[2]/255*fd[3],fd[3]):void 0}toString(){const[gd,hd,id,jd]=this.toArray();return`rgba(${Math.round(gd)},${Math.round(hd)},${Math.round(id)},${jd})`}toArray(){const{r:kd,g:ld,b:md,a:nd}=this;return 0===nd?[0,0,0,0]:[255*kd/nd,255*ld/nd,255*md/nd,nd]}}_c.black=new _c(0,0,0,1),_c.white=new _c(1,1,1,1),_c.transparent=new _c(0,0,0,0),_c.red=new _c(1,0,0,1),_c.blue=new _c(0,0,1,1);class od{constructor(pd,qd,rd){this.sensitivity=pd?qd?"variant":"case":qd?"accent":"base",this.locale=rd,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(sd,td){return this.collator.compare(sd,td)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ud{constructor(vd,wd,xd,yd,zd){this.text=vd.normalize?vd.normalize():vd,this.image=wd,this.scale=xd,this.fontStack=yd,this.textColor=zd}}class Ad{constructor(Bd){this.sections=Bd}static fromString(Cd){return new Ad([new ud(Cd,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(Dd){return Dd instanceof Ad?Dd:Ad.fromString(Dd)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const Ed=["format"];for(const Fd of this.sections){if(Fd.image){Ed.push(["image",Fd.image.name]);continue}Ed.push(Fd.text);const Gd={};Fd.fontStack&&(Gd["text-font"]=["literal",Fd.fontStack.split(",")]),Fd.scale&&(Gd["font-scale"]=Fd.scale),Fd.textColor&&(Gd["text-color"]=["rgba"].concat(Fd.textColor.toArray())),Ed.push(Gd)}return Ed}}class Hd{constructor(Id){this.name=Id.name,this.available=Id.available}toString(){return this.name}static fromString(Jd){return Jd?new Hd({name:Jd,available:!1}):null}serialize(){return["image",this.name]}}function Kd(a,b,c,d){return"number"==typeof a&&a>=0&&a<=255&&"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255?void 0===d||"number"==typeof d&&d>=0&&d<=1?null:`Invalid rgba value [${[a,b,c,d].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof d?[a,b,c,d]:[a,b,c]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ld(a){if(null===a)return!0;if("string"==typeof a)return!0;if("boolean"==typeof a)return!0;if("number"==typeof a)return!0;if(a instanceof _c)return!0;if(a instanceof od)return!0;if(a instanceof Ad)return!0;if(a instanceof Hd)return!0;if(Array.isArray(a)){for(const b of a)if(!Ld(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!Ld(a[c]))return!1;return!0}return!1}function Md(a){if(null===a)return Jc;if("string"==typeof a)return Lc;if("boolean"==typeof a)return Mc;if("number"==typeof a)return Kc;if(a instanceof _c)return Nc;if(a instanceof od)return Qc;if(a instanceof Ad)return Rc;if(a instanceof Hd)return Sc;if(Array.isArray(a)){const b=a.length;let c;for(const d of a){const e=Md(d);if(c){if(c===e)continue;c=Pc;break}c=e}return Tc(c||Pc,b)}return Oc}function Nd(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof _c||a instanceof Ad||a instanceof Hd?a.toString():JSON.stringify(a)}class Od{constructor(Pd,Qd){this.type=Pd,this.value=Qd}static parse(Rd,Sd){if(2!==Rd.length)return Sd.error(`'literal' expression requires exactly one argument, but found ${Rd.length-1} instead.`);if(!Ld(Rd[1]))return Sd.error("invalid value");const Td=Rd[1];let Ud=Md(Td);const Vd=Sd.expectedType;return"array"===Ud.kind&&0===Ud.N&&Vd&&"array"===Vd.kind&&("number"!=typeof Vd.N||0===Vd.N)&&(Ud=Vd),new Od(Ud,Td)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof _c?["rgba"].concat(this.value.toArray()):this.value instanceof Ad?this.value.serialize():this.value}}class Wd{constructor(Xd){this.name="ExpressionEvaluationError",this.message=Xd}toJSON(){return this.message}}const Yd={string:Lc,number:Kc,boolean:Mc,object:Oc};class Zd{constructor($d,_d){this.type=$d,this.args=_d}static parse(ae,be){if(ae.length<2)return be.error("Expected at least one argument.");let ce,de=1;const ee=ae[0];if("array"===ee){let fe,ge;if(ae.length>2){const he=ae[1];if("string"!=typeof he||!(he in Yd)||"object"===he)return be.error("The item type argument of \"array\" must be one of string, number, boolean",1);fe=Yd[he],de++}else fe=Pc;if(ae.length>3){if(null!==ae[2]&&("number"!=typeof ae[2]||ae[2]<0||ae[2]!==Math.floor(ae[2])))return be.error("The length argument to \"array\" must be a positive integer literal",2);ge=ae[2],de++}ce=Tc(fe,ge)}else ce=Yd[ee];const ie=[];for(;dea.outputDefined())}serialize(){const oe=this.type,pe=[oe.kind];if("array"===oe.kind){const qe=oe.itemType;if("string"===qe.kind||"number"===qe.kind||"boolean"===qe.kind){pe.push(qe.kind);const re=oe.N;("number"==typeof re||this.args.length>1)&&pe.push(re)}}return pe.concat(this.args.map(a=>a.serialize()))}}class se{constructor(te){this.type=Rc,this.sections=te}static parse(ue,ve){if(ue.length<2)return ve.error("Expected at least one argument.");const we=ue[1];if(!Array.isArray(we)&&"object"==typeof we)return ve.error("First argument must be an image or text section.");const xe=[];let ye=!1;for(let ze=1;ze<=ue.length-1;++ze){const Ae=ue[ze];if(ye&&"object"==typeof Ae&&!Array.isArray(Ae)){ye=!1;let Be=null;if(Ae["font-scale"]&&!(Be=ve.parse(Ae["font-scale"],1,Kc)))return null;let Ce=null;if(Ae["text-font"]&&!(Ce=ve.parse(Ae["text-font"],1,Tc(Lc))))return null;let De=null;if(Ae["text-color"]&&!(De=ve.parse(Ae["text-color"],1,Nc)))return null;const Ee=xe[xe.length-1];Ee.scale=Be,Ee.font=Ce,Ee.textColor=De}else{const Fe=ve.parse(ue[ze],1,Pc);if(!Fe)return null;const Ge=Fe.type.kind;if("string"!==Ge&&"value"!==Ge&&"null"!==Ge&&"resolvedImage"!==Ge)return ve.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");ye=!0,xe.push({content:Fe,scale:null,font:null,textColor:null})}}return new se(xe)}evaluate(He){return new Ad(this.sections.map(a=>{const b=a.content.evaluate(He);return Md(b)===Sc?new ud("",b,null,null,null):new ud(Nd(b),null,a.scale?a.scale.evaluate(He):null,a.font?a.font.evaluate(He).join(","):null,a.textColor?a.textColor.evaluate(He):null)}))}eachChild(Ie){for(const Je of this.sections)Ie(Je.content),Je.scale&&Ie(Je.scale),Je.font&&Ie(Je.font),Je.textColor&&Ie(Je.textColor)}outputDefined(){return!1}serialize(){const Ke=["format"];for(const Le of this.sections){Ke.push(Le.content.serialize());const Me={};Le.scale&&(Me["font-scale"]=Le.scale.serialize()),Le.font&&(Me["text-font"]=Le.font.serialize()),Le.textColor&&(Me["text-color"]=Le.textColor.serialize()),Ke.push(Me)}return Ke}}class Ne{constructor(Oe){this.type=Sc,this.input=Oe}static parse(Pe,Qe){if(2!==Pe.length)return Qe.error("Expected two arguments.");const Re=Qe.parse(Pe[1],1,Lc);return Re?new Ne(Re):Qe.error("No image name provided.")}evaluate(Se){const Te=this.input.evaluate(Se),Ue=Hd.fromString(Te);return Ue&&Se.availableImages&&(Ue.available=Se.availableImages.indexOf(Te)> -1),Ue}eachChild(Ve){Ve(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const We={"to-boolean":Mc,"to-color":Nc,"to-number":Kc,"to-string":Lc};class Xe{constructor(Ye,Ze){this.type=Ye,this.args=Ze}static parse($e,_e){if($e.length<2)return _e.error("Expected at least one argument.");const af=$e[0];if(("to-boolean"===af||"to-string"===af)&&2!==$e.length)return _e.error("Expected one argument.");const bf=We[af],cf=[];for(let df=1;df<$e.length;df++){const ef=_e.parse($e[df],df,Pc);if(!ef)return null;cf.push(ef)}return new Xe(bf,cf)}evaluate(ff){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(ff));if("color"===this.type.kind){let gf,hf;for(const jf of this.args){if(hf=null,(gf=jf.evaluate(ff))instanceof _c)return gf;if("string"==typeof gf){const kf=ff.parseColor(gf);if(kf)return kf}else if(Array.isArray(gf)&&!(hf=gf.length<3||gf.length>4?`Invalid rbga value ${JSON.stringify(gf)}: expected an array containing either three or four numeric values.`:Kd(gf[0],gf[1],gf[2],gf[3])))return new _c(gf[0]/255,gf[1]/255,gf[2]/255,gf[3])}throw new Wd(hf||`Could not parse color from value '${"string"==typeof gf?gf:String(JSON.stringify(gf))}'`)}if("number"===this.type.kind){let lf=null;for(const mf of this.args){if(null===(lf=mf.evaluate(ff)))return 0;const nf=Number(lf);if(!isNaN(nf))return nf}throw new Wd(`Could not convert ${JSON.stringify(lf)} to number.`)}return"formatted"===this.type.kind?Ad.fromString(Nd(this.args[0].evaluate(ff))):"resolvedImage"===this.type.kind?Hd.fromString(Nd(this.args[0].evaluate(ff))):Nd(this.args[0].evaluate(ff))}eachChild(of){this.args.forEach(of)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new se([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Ne(this.args[0]).serialize();const pf=[`to-${this.type.kind}`];return this.eachChild(a=>{pf.push(a.serialize())}),pf}}const qf=["Unknown","Point","LineString","Polygon"];class rf{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?qf[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const sf=this.featureDistanceData.center,tf=this.featureDistanceData.scale,{x:uf,y:vf}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(uf*tf-sf[0])+this.featureDistanceData.bearing[1]*(vf*tf-sf[1])}return 0}parseColor(wf){let xf=this._parseColorCache[wf];return xf||(xf=this._parseColorCache[wf]=_c.parse(wf)),xf}}class yf{constructor(zf,Af,Bf,Cf){this.name=zf,this.type=Af,this._evaluate=Bf,this.args=Cf}evaluate(Df){return this._evaluate(Df,this.args)}eachChild(Ef){this.args.forEach(Ef)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(Ff,Gf){const Hf=Ff[0],If=yf.definitions[Hf];if(!If)return Gf.error(`Unknown expression "${Hf}". If you wanted a literal array, use ["literal", [...]].`,0);const Jf=Array.isArray(If)?If[0]:If.type,Kf=Array.isArray(If)?[[If[1],If[2]]]:If.overloads,Lf=Kf.filter(([a])=>!Array.isArray(a)||a.length===Ff.length-1);let Mf=null;for(const[Nf,Of]of Lf){Mf=new Zg(Gf.registry,Gf.path,null,Gf.scope);const Pf=[];let Qf=!1;for(let Rf=1;Rf{var b;return b=a,Array.isArray(b)?`(${b.map(Uc).join(", ")})`:`(${Uc(b.type)}...)`}).join(" | "),Zf=[];for(let $f=1;$f=b[2]||a[1]<=b[1]||a[3]>=b[3])}function sg(a,b){const c=(180+a[0])/360,d=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,e=Math.pow(2,b.z);return[Math.round(c*e*8192),Math.round(d*e*8192)]}function tg(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function ug(a,b){var c,d,e;let f=!1;for(let g=0,h=b.length;g(c=a)[1]!=(e=i[j+1])[1]>c[1]&&c[0]<(e[0]-d[0])*(c[1]-d[1])/(e[1]-d[1])+d[0]&&(f=!f)}}return f}function vg(a,b){for(let c=0;c0&&h<0||g<0&&h>0}function xg(a,b,c){var d,e,f,g,h,i;for(const j of c)for(let k=0;kc[2]){const e=.5*d;let f=a[0]-c[0]>e?-d:c[0]-a[0]>e?d:0;0===f&&(f=a[0]-c[2]>e?-d:c[2]-a[0]>e?d:0),a[0]+=f}qg(b,a)}function Dg(a,b,c,d){const e=8192*Math.pow(2,d.z),f=[8192*d.x,8192*d.y],g=[];for(const h of a)for(const i of h){const j=[i.x+f[0],i.y+f[1]];Cg(j,b,c,e),g.push(j)}return g}function Eg(a,b,c,d){var e;const f=8192*Math.pow(2,d.z),g=[8192*d.x,8192*d.y],h=[];for(const i of a){const j=[];for(const k of i){const l=[k.x+g[0],k.y+g[1]];qg(b,l),j.push(l)}h.push(j)}if(b[2]-b[0]<=f/2)for(const m of((e=b)[0]=e[1]=1/0,e[2]=e[3]=-1/0,h))for(const n of m)Cg(n,b,c,f);return h}class Fg{constructor(Gg,Hg){this.type=Mc,this.geojson=Gg,this.geometries=Hg}static parse(Ig,Jg){if(2!==Ig.length)return Jg.error(`'within' expression requires exactly one argument, but found ${Ig.length-1} instead.`);if(Ld(Ig[1])){const Kg=Ig[1];if("FeatureCollection"===Kg.type)for(let Lg=0;Lg{b&&!Pg(a)&&(b=!1)}),b}function Qg(a){if(a instanceof yf&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!Qg(a)&&(b=!1)}),b}function Rg(a,b){if(a instanceof yf&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!Rg(a,b)&&(c=!1)}),c}class Sg{constructor(Tg,Ug){this.type=Ug.type,this.name=Tg,this.boundExpression=Ug}static parse(Vg,Wg){if(2!==Vg.length||"string"!=typeof Vg[1])return Wg.error("'var' expression requires exactly one string literal argument.");const Xg=Vg[1];return Wg.scope.has(Xg)?new Sg(Xg,Wg.scope.get(Xg)):Wg.error(`Unknown variable "${Xg}". Make sure "${Xg}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(Yg){return this.boundExpression.evaluate(Yg)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Zg{constructor($g,_g=[],ah,bh=new Bc,ch=[]){this.registry=$g,this.path=_g,this.key=_g.map(a=>`[${a}]`).join(""),this.scope=bh,this.errors=ch,this.expectedType=ah}parse(dh,eh,fh,gh,hh={}){return eh?this.concat(eh,fh,gh)._parse(dh,hh):this._parse(dh,hh)}_parse(ih,jh){function kh(a,b,c){return"assert"===c?new Zd(b,[a]):"coerce"===c?new Xe(b,[a]):a}if(null!==ih&&"string"!=typeof ih&&"boolean"!=typeof ih&&"number"!=typeof ih||(ih=["literal",ih]),Array.isArray(ih)){if(0===ih.length)return this.error("Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].");const lh=ih[0];if("string"!=typeof lh)return this.error(`Expression name must be a string, but found ${typeof lh} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const mh=this.registry[lh];if(mh){let nh=mh.parse(ih,this);if(!nh)return null;if(this.expectedType){const oh=this.expectedType,ph=nh.type;if("string"!==oh.kind&&"number"!==oh.kind&&"boolean"!==oh.kind&&"object"!==oh.kind&&"array"!==oh.kind||"value"!==ph.kind)if("color"!==oh.kind&&"formatted"!==oh.kind&&"resolvedImage"!==oh.kind||"value"!==ph.kind&&"string"!==ph.kind){if(this.checkSubtype(oh,ph))return null}else nh=kh(nh,oh,jh.typeAnnotation||"coerce");else nh=kh(nh,oh,jh.typeAnnotation||"assert")}if(!(nh instanceof Od)&&"resolvedImage"!==nh.type.kind&&Dh(nh)){const qh=new rf;try{nh=new Od(nh.type,nh.evaluate(qh))}catch(rh){return this.error(rh.message),null}}return nh}return this.error(`Unknown expression "${lh}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===ih?"'undefined' value invalid. Use null instead.":"object"==typeof ih?"Bare objects invalid. Use [\"literal\", {...}] instead.":`Expected an array, but found ${typeof ih} instead.`)}concat(sh,th,uh){const vh="number"==typeof sh?this.path.concat(sh):this.path,wh=uh?this.scope.concat(uh):this.scope;return new Zg(this.registry,vh,th||null,wh,this.errors)}error(xh,...yh){const zh=`${this.key}${yh.map(a=>`[${a}]`).join("")}`;this.errors.push(new yc(zh,xh))}checkSubtype(Ah,Bh){const Ch=Wc(Ah,Bh);return Ch&&this.error(Ch),Ch}}function Dh(a){if(a instanceof Sg)return Dh(a.boundExpression);if(a instanceof yf&&"error"===a.name)return!1;if(a instanceof dg)return!1;if(a instanceof Fg)return!1;const b=a instanceof Xe||a instanceof Zd;let c=!0;return a.eachChild(a=>{c=b?c&&Dh(a):c&&a instanceof Od}),!!c&&Pg(a)&&Rg(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Eh(a,b){const c=a.length-1;let d,e,f=0,g=c,h=0;for(;f<=g;)if(d=a[h=Math.floor((f+g)/2)],e=a[h+1],d<=b){if(h===c||bb))throw new Wd("Input is not a number.");g=h-1}return 0}class Fh{constructor(Gh,Hh,Ih){for(const[Jh,Kh]of(this.type=Gh,this.input=Hh,this.labels=[],this.outputs=[],Ih))this.labels.push(Jh),this.outputs.push(Kh)}static parse(Lh,Mh){if(Lh.length-1<4)return Mh.error(`Expected at least 4 arguments, but found only ${Lh.length-1}.`);if((Lh.length-1)%2!=0)return Mh.error("Expected an even number of arguments.");const Nh=Mh.parse(Lh[1],1,Kc);if(!Nh)return null;const Oh=[];let Ph=null;Mh.expectedType&&"value"!==Mh.expectedType.kind&&(Ph=Mh.expectedType);for(let Qh=1;Qh=Rh)return Mh.error("Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.",Th);const Vh=Mh.parse(Sh,Uh,Ph);if(!Vh)return null;Ph=Ph||Vh.type,Oh.push([Rh,Vh])}return new Fh(Ph,Nh,Oh)}evaluate(Wh){const Xh=this.labels,Yh=this.outputs;if(1===Xh.length)return Yh[0].evaluate(Wh);const Zh=this.input.evaluate(Wh);if(Zh<=Xh[0])return Yh[0].evaluate(Wh);const $h=Xh.length;return Zh>=Xh[$h-1]?Yh[$h-1].evaluate(Wh):Yh[Eh(Xh,Zh)].evaluate(Wh)}eachChild(_h){for(const ai of(_h(this.input),this.outputs))_h(ai)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const bi=["step",this.input.serialize()];for(let ci=0;ci0&&bi.push(this.labels[ci]),bi.push(this.outputs[ci].serialize());return bi}}function di(a,b,c){return a*(1-c)+b*c}var ei=Object.freeze({__proto__:null,number:di,color:function(a,b,c){return new _c(di(a.r,b.r,c),di(a.g,b.g,c),di(a.b,b.b,c),di(a.a,b.a,c))},array:function(a,b,c){return a.map((a,d)=>di(a,b[d],c))}});const fi=4/29,gi=6/29,hi=3*gi*gi,ii=Math.PI/180,ji=180/Math.PI;function ki(a){return a>.008856451679035631?Math.pow(a,1/3):a/hi+fi}function li(a){return a>gi?a*a*a:hi*(a-fi)}function mi(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function ni(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function oi(a){const b=ni(a.r),c=ni(a.g),d=ni(a.b),e=ki((.4124564*b+.3575761*c+.1804375*d)/.95047),f=ki((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*f-16,a:500*(e-f),b:200*(f-ki((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function pi(a){let b=(a.l+16)/116,c=isNaN(a.a)?b:b+a.a/500,d=isNaN(a.b)?b:b-a.b/200;return b=1*li(b),c=.95047*li(c),d=1.08883*li(d),new _c(mi(3.2404542*c-1.5371385*b-.4985314*d),mi(-0.969266*c+1.8760108*b+.041556*d),mi(.0556434*c-.2040259*b+1.0572252*d),a.alpha)}const qi={forward:oi,reverse:pi,interpolate:function(a,b,c){return{l:di(a.l,b.l,c),a:di(a.a,b.a,c),b:di(a.b,b.b,c),alpha:di(a.alpha,b.alpha,c)}}},ri={forward:function(a){const{l:b,a:c,b:d}=oi(a),e=Math.atan2(d,c)*ji;return{h:e<0?e+360:e,c:Math.sqrt(c*c+d*d),l:b,alpha:a.a}},reverse:function(a){const b=a.h*ii,c=a.c;return pi({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){return{h:(function(a,b,c){const d=b-a;return a+c*(d>180||d< -180?d-360*Math.round(d/360):d)})(a.h,b.h,c),c:di(a.c,b.c,c),l:di(a.l,b.l,c),alpha:di(a.alpha,b.alpha,c)}}};var si=Object.freeze({__proto__:null,lab:qi,hcl:ri});class ti{constructor(ui,vi,wi,xi,yi){for(const[zi,Ai]of(this.type=ui,this.operator=vi,this.interpolation=wi,this.input=xi,this.labels=[],this.outputs=[],yi))this.labels.push(zi),this.outputs.push(Ai)}static interpolationFactor(Bi,Ci,Di,Ei){let Fi=0;if("exponential"===Bi.name)Fi=jj(Ci,Bi.base,Di,Ei);else if("linear"===Bi.name)Fi=jj(Ci,1,Di,Ei);else if("cubic-bezier"===Bi.name){const Gi=Bi.controlPoints;Fi=new e(Gi[0],Gi[1],Gi[2],Gi[3]).solve(jj(Ci,1,Di,Ei))}return Fi}static parse(Hi,Ii){let[Ji,Ki,Li,...Mi]=Hi;if(!Array.isArray(Ki)||0===Ki.length)return Ii.error("Expected an interpolation type expression.",1);if("linear"===Ki[0])Ki={name:"linear"};else if("exponential"===Ki[0]){const Ni=Ki[1];if("number"!=typeof Ni)return Ii.error("Exponential interpolation requires a numeric base.",1,1);Ki={name:"exponential",base:Ni}}else{if("cubic-bezier"!==Ki[0])return Ii.error(`Unknown interpolation type ${String(Ki[0])}`,1,0);{const Oi=Ki.slice(1);if(4!==Oi.length||Oi.some(a=>"number"!=typeof a||a<0||a>1))return Ii.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);Ki={name:"cubic-bezier",controlPoints:Oi}}}if(Hi.length-1<4)return Ii.error(`Expected at least 4 arguments, but found only ${Hi.length-1}.`);if((Hi.length-1)%2!=0)return Ii.error("Expected an even number of arguments.");if(!(Li=Ii.parse(Li,2,Kc)))return null;const Pi=[];let Qi=null;"interpolate-hcl"===Ji||"interpolate-lab"===Ji?Qi=Nc:Ii.expectedType&&"value"!==Ii.expectedType.kind&&(Qi=Ii.expectedType);for(let Ri=0;Ri=Si)return Ii.error("Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.",Ui);const Wi=Ii.parse(Ti,Vi,Qi);if(!Wi)return null;Qi=Qi||Wi.type,Pi.push([Si,Wi])}return"number"===Qi.kind||"color"===Qi.kind||"array"===Qi.kind&&"number"===Qi.itemType.kind&&"number"==typeof Qi.N?new ti(Qi,Ji,Ki,Li,Pi):Ii.error(`Type ${Uc(Qi)} is not interpolatable.`)}evaluate(Xi){const Yi=this.labels,Zi=this.outputs;if(1===Yi.length)return Zi[0].evaluate(Xi);const $i=this.input.evaluate(Xi);if($i<=Yi[0])return Zi[0].evaluate(Xi);const _i=Yi.length;if($i>=Yi[_i-1])return Zi[_i-1].evaluate(Xi);const aj=Eh(Yi,$i),bj=ti.interpolationFactor(this.interpolation,$i,Yi[aj],Yi[aj+1]),cj=Zi[aj].evaluate(Xi),dj=Zi[aj+1].evaluate(Xi);return"interpolate"===this.operator?ei[this.type.kind.toLowerCase()](cj,dj,bj):"interpolate-hcl"===this.operator?ri.reverse(ri.interpolate(ri.forward(cj),ri.forward(dj),bj)):qi.reverse(qi.interpolate(qi.forward(cj),qi.forward(dj),bj))}eachChild(ej){for(const fj of(ej(this.input),this.outputs))ej(fj)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let gj;gj="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const hj=[this.operator,gj,this.input.serialize()];for(let ij=0;ijWc(qj,a.type));return new kj(uj?Pc:pj,rj)}evaluate(vj){let wj,xj=null,yj=0;for(const zj of this.args){if(yj++,(xj=zj.evaluate(vj))&&xj instanceof Hd&&!xj.available&&(wj||(wj=xj),xj=null,yj===this.args.length))return wj;if(null!==xj)break}return xj}eachChild(Aj){this.args.forEach(Aj)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const Bj=["coalesce"];return this.eachChild(a=>{Bj.push(a.serialize())}),Bj}}class Cj{constructor(Dj,Ej){this.type=Ej.type,this.bindings=[].concat(Dj),this.result=Ej}evaluate(Fj){return this.result.evaluate(Fj)}eachChild(Gj){for(const Hj of this.bindings)Gj(Hj[1]);Gj(this.result)}static parse(Ij,Jj){if(Ij.length<4)return Jj.error(`Expected at least 3 arguments, but found ${Ij.length-1} instead.`);const Kj=[];for(let Lj=1;Lj=ak.length)throw new Wd(`Array index out of bounds: ${_j} > ${ak.length-1}.`);if(_j!==Math.floor(_j))throw new Wd(`Array index must be an integer, but found ${_j} instead.`);return ak[_j]}eachChild(bk){bk(this.index),bk(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class ck{constructor(dk,ek){this.type=Mc,this.needle=dk,this.haystack=ek}static parse(fk,gk){if(3!==fk.length)return gk.error(`Expected 2 arguments, but found ${fk.length-1} instead.`);const hk=gk.parse(fk[1],1,Pc),ik=gk.parse(fk[2],2,Pc);return hk&&ik?Xc(hk.type,[Mc,Lc,Kc,Jc,Pc])?new ck(hk,ik):gk.error(`Expected first argument to be of type boolean, string, number or null, but found ${Uc(hk.type)} instead`):null}evaluate(jk){const kk=this.needle.evaluate(jk),lk=this.haystack.evaluate(jk);if(!lk)return!1;if(!Yc(kk,["boolean","string","number","null"]))throw new Wd(`Expected first argument to be of type boolean, string, number or null, but found ${Uc(Md(kk))} instead.`);if(!Yc(lk,["string","array"]))throw new Wd(`Expected second argument to be of type array or string, but found ${Uc(Md(lk))} instead.`);return lk.indexOf(kk)>=0}eachChild(mk){mk(this.needle),mk(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class nk{constructor(ok,pk,qk){this.type=Kc,this.needle=ok,this.haystack=pk,this.fromIndex=qk}static parse(rk,sk){if(rk.length<=2||rk.length>=5)return sk.error(`Expected 3 or 4 arguments, but found ${rk.length-1} instead.`);const tk=sk.parse(rk[1],1,Pc),uk=sk.parse(rk[2],2,Pc);if(!tk||!uk)return null;if(!Xc(tk.type,[Mc,Lc,Kc,Jc,Pc]))return sk.error(`Expected first argument to be of type boolean, string, number or null, but found ${Uc(tk.type)} instead`);if(4===rk.length){const vk=sk.parse(rk[3],3,Kc);return vk?new nk(tk,uk,vk):null}return new nk(tk,uk)}evaluate(wk){const xk=this.needle.evaluate(wk),yk=this.haystack.evaluate(wk);if(!Yc(xk,["boolean","string","number","null"]))throw new Wd(`Expected first argument to be of type boolean, string, number or null, but found ${Uc(Md(xk))} instead.`);if(!Yc(yk,["string","array"]))throw new Wd(`Expected second argument to be of type array or string, but found ${Uc(Md(yk))} instead.`);if(this.fromIndex){const zk=this.fromIndex.evaluate(wk);return yk.indexOf(xk,zk)}return yk.indexOf(xk)}eachChild(Ak){Ak(this.needle),Ak(this.haystack),this.fromIndex&&Ak(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const Bk=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),Bk]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Ck{constructor(Dk,Ek,Fk,Gk,Hk,Ik){this.inputType=Dk,this.type=Ek,this.input=Fk,this.cases=Gk,this.outputs=Hk,this.otherwise=Ik}static parse(Jk,Kk){if(Jk.length<5)return Kk.error(`Expected at least 4 arguments, but found only ${Jk.length-1}.`);if(Jk.length%2!=1)return Kk.error("Expected an even number of arguments.");let Lk,Mk;Kk.expectedType&&"value"!==Kk.expectedType.kind&&(Mk=Kk.expectedType);const Nk={},Ok=[];for(let Pk=2;PkNumber.MAX_SAFE_INTEGER)return Sk.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof Tk&&Math.floor(Tk)!==Tk)return Sk.error("Numeric branch labels must be integer values.");if(Lk){if(Sk.checkSubtype(Lk,Md(Tk)))return null}else Lk=Md(Tk);if(void 0!==Nk[String(Tk)])return Sk.error("Branch labels must be unique.");Nk[String(Tk)]=Ok.length}const Uk=Kk.parse(Rk,Pk,Mk);if(!Uk)return null;Mk=Mk||Uk.type,Ok.push(Uk)}const Vk=Kk.parse(Jk[1],1,Pc);if(!Vk)return null;const Wk=Kk.parse(Jk[Jk.length-1],Jk.length-1,Mk);return Wk?"value"!==Vk.type.kind&&Kk.concat(1).checkSubtype(Lk,Vk.type)?null:new Ck(Lk,Mk,Vk,Nk,Ok,Wk):null}evaluate(Xk){const Yk=this.input.evaluate(Xk);return(Md(Yk)===this.inputType&&this.outputs[this.cases[Yk]]||this.otherwise).evaluate(Xk)}eachChild(Zk){Zk(this.input),this.outputs.forEach(Zk),Zk(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const $k=["match",this.input.serialize()],_k=Object.keys(this.cases).sort(),al=[],bl={};for(const cl of _k){const dl=bl[this.cases[cl]];void 0===dl?(bl[this.cases[cl]]=al.length,al.push([this.cases[cl],[cl]])):al[dl][1].push(cl)}const el=a=>"number"===this.inputType.kind?Number(a):a;for(const[fl,gl]of al)$k.push(1===gl.length?el(gl[0]):gl.map(el)),$k.push(this.outputs[fl].serialize());return $k.push(this.otherwise.serialize()),$k}}class hl{constructor(il,jl,kl){this.type=il,this.branches=jl,this.otherwise=kl}static parse(ll,ml){if(ll.length<4)return ml.error(`Expected at least 3 arguments, but found only ${ll.length-1}.`);if(ll.length%2!=0)return ml.error("Expected an odd number of arguments.");let nl;ml.expectedType&&"value"!==ml.expectedType.kind&&(nl=ml.expectedType);const ol=[];for(let pl=1;plb.outputDefined())&&this.otherwise.outputDefined()}serialize(){const zl=["case"];return this.eachChild(a=>{zl.push(a.serialize())}),zl}}class Al{constructor(Bl,Cl,Dl,El){this.type=Bl,this.input=Cl,this.beginIndex=Dl,this.endIndex=El}static parse(Fl,Gl){if(Fl.length<=2||Fl.length>=5)return Gl.error(`Expected 3 or 4 arguments, but found ${Fl.length-1} instead.`);const Hl=Gl.parse(Fl[1],1,Pc),Il=Gl.parse(Fl[2],2,Kc);if(!Hl||!Il)return null;if(!Xc(Hl.type,[Tc(Pc),Lc,Pc]))return Gl.error(`Expected first argument to be of type array or string, but found ${Uc(Hl.type)} instead`);if(4===Fl.length){const Jl=Gl.parse(Fl[3],3,Kc);return Jl?new Al(Hl.type,Hl,Il,Jl):null}return new Al(Hl.type,Hl,Il)}evaluate(Kl){const Ll=this.input.evaluate(Kl),Ml=this.beginIndex.evaluate(Kl);if(!Yc(Ll,["string","array"]))throw new Wd(`Expected first argument to be of type array or string, but found ${Uc(Md(Ll))} instead.`);if(this.endIndex){const Nl=this.endIndex.evaluate(Kl);return Ll.slice(Ml,Nl)}return Ll.slice(Ml)}eachChild(Ol){Ol(this.input),Ol(this.beginIndex),this.endIndex&&Ol(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const Pl=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),Pl]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Ql(a,b){return"=="===a||"!="===a?"boolean"===b.kind||"string"===b.kind||"number"===b.kind||"null"===b.kind||"value"===b.kind:"string"===b.kind||"number"===b.kind||"value"===b.kind}function Rl(a,b,c,d){return 0===d.compare(b,c)}function Sl(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(f,g,h){this.type=Mc,this.lhs=f,this.rhs=g,this.collator=h,this.hasUntypedArgument="value"===f.type.kind||"value"===g.type.kind}static parse(i,j){if(3!==i.length&&4!==i.length)return j.error("Expected two or three arguments.");const k=i[0];let l=j.parse(i[1],1,Pc);if(!l)return null;if(!Ql(k,l.type))return j.concat(1).error(`"${k}" comparisons are not supported for type '${Uc(l.type)}'.`);let m=j.parse(i[2],2,Pc);if(!m)return null;if(!Ql(k,m.type))return j.concat(2).error(`"${k}" comparisons are not supported for type '${Uc(m.type)}'.`);if(l.type.kind!==m.type.kind&&"value"!==l.type.kind&&"value"!==m.type.kind)return j.error(`Cannot compare types '${Uc(l.type)}' and '${Uc(m.type)}'.`);d&&("value"===l.type.kind&&"value"!==m.type.kind?l=new Zd(m.type,[l]):"value"!==l.type.kind&&"value"===m.type.kind&&(m=new Zd(l.type,[m])));let n=null;if(4===i.length){if("string"!==l.type.kind&&"string"!==m.type.kind&&"value"!==l.type.kind&&"value"!==m.type.kind)return j.error("Cannot use collator to compare non-string types.");if(!(n=j.parse(i[3],3,Qc)))return null}return new e(l,m,n)}evaluate(o){const p=this.lhs.evaluate(o),q=this.rhs.evaluate(o);if(d&&this.hasUntypedArgument){const r=Md(p),s=Md(q);if(r.kind!==s.kind||"string"!==r.kind&&"number"!==r.kind)throw new Wd(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${r.kind}, ${s.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const t=Md(p),u=Md(q);if("string"!==t.kind||"string"!==u.kind)return b(o,p,q)}return this.collator?c(o,p,q,this.collator.evaluate(o)):b(o,p,q)}eachChild(v){v(this.lhs),v(this.rhs),this.collator&&v(this.collator)}outputDefined(){return!0}serialize(){const w=[a];return this.eachChild(a=>{w.push(a.serialize())}),w}}}const Tl=Sl("==",function(a,b,c){return b===c},Rl),Ul=Sl("!=",function(a,b,c){return b!==c},function(a,b,c,d){return!Rl(0,b,c,d)}),Vl=Sl("<",function(a,b,c){return bd.compare(b,c)}),Wl=Sl(">",function(a,b,c){return b>c},function(a,b,c,d){return d.compare(b,c)>0}),Xl=Sl("<=",function(a,b,c){return b<=c},function(a,b,c,d){return 0>=d.compare(b,c)}),Yl=Sl(">=",function(a,b,c){return b>=c},function(a,b,c,d){return d.compare(b,c)>=0});class Zl{constructor($l,_l,am,bm,cm){this.type=Lc,this.number=$l,this.locale=_l,this.currency=am,this.minFractionDigits=bm,this.maxFractionDigits=cm}static parse(dm,em){if(3!==dm.length)return em.error("Expected two arguments.");const fm=em.parse(dm[1],1,Kc);if(!fm)return null;const gm=dm[2];if("object"!=typeof gm||Array.isArray(gm))return em.error("NumberFormat options argument must be an object.");let hm=null;if(gm.locale&&!(hm=em.parse(gm.locale,1,Lc)))return null;let im=null;if(gm.currency&&!(im=em.parse(gm.currency,1,Lc)))return null;let jm=null;if(gm["min-fraction-digits"]&&!(jm=em.parse(gm["min-fraction-digits"],1,Kc)))return null;let km=null;return!gm["max-fraction-digits"]||(km=em.parse(gm["max-fraction-digits"],1,Kc))?new Zl(fm,hm,im,jm,km):null}evaluate(lm){return new Intl.NumberFormat(this.locale?this.locale.evaluate(lm):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(lm):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(lm):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(lm):void 0}).format(this.number.evaluate(lm))}eachChild(mm){mm(this.number),this.locale&&mm(this.locale),this.currency&&mm(this.currency),this.minFractionDigits&&mm(this.minFractionDigits),this.maxFractionDigits&&mm(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const nm={};return this.locale&&(nm.locale=this.locale.serialize()),this.currency&&(nm.currency=this.currency.serialize()),this.minFractionDigits&&(nm["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(nm["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),nm]}}class om{constructor(pm){this.type=Kc,this.input=pm}static parse(qm,rm){if(2!==qm.length)return rm.error(`Expected 1 argument, but found ${qm.length-1} instead.`);const sm=rm.parse(qm[1],1);return sm?"array"!==sm.type.kind&&"string"!==sm.type.kind&&"value"!==sm.type.kind?rm.error(`Expected argument of type string or array, but found ${Uc(sm.type)} instead.`):new om(sm):null}evaluate(tm){const um=this.input.evaluate(tm);if("string"==typeof um)return um.length;if(Array.isArray(um))return um.length;throw new Wd(`Expected value to be of type string or array, but found ${Uc(Md(um))} instead.`)}eachChild(vm){vm(this.input)}outputDefined(){return!1}serialize(){const wm=["length"];return this.eachChild(a=>{wm.push(a.serialize())}),wm}}const xm={"==":Tl,"!=":Ul,">":Wl,"<":Vl,">=":Yl,"<=":Xl,array:Zd,at:Sj,boolean:Zd,case:hl,coalesce:kj,collator:dg,format:se,image:Ne,in:ck,"index-of":nk,interpolate:ti,"interpolate-hcl":ti,"interpolate-lab":ti,length:om,let:Cj,literal:Od,match:Ck,number:Zd,"number-format":Zl,object:Zd,slice:Al,step:Fh,string:Zd,"to-boolean":Xe,"to-color":Xe,"to-number":Xe,"to-string":Xe,var:Sg,within:Fg};function ym(a,[b,c,d,e]){b=b.evaluate(a),c=c.evaluate(a),d=d.evaluate(a);const f=e?e.evaluate(a):1,g=Kd(b,c,d,f);if(g)throw new Wd(g);return new _c(b/255*f,c/255*f,d/255*f,f)}function zm(a,b){return a in b}function Am(a,b){const c=b[a];return void 0===c?null:c}function Bm(a){return{type:a}}function Cm(a){return{result:"success",value:a}}function Dm(a){return{result:"error",value:a}}function Em(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function Fm(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function Gm(a){return!!a.expression&&a.expression.interpolated}function Hm(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function Im(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function Jm(a){return a}function Km(a,b){const c="color"===b.type,d=a.stops&&"object"==typeof a.stops[0][0],e=d||!(d|| void 0!==a.property),f=a.type||(Gm(b)?"exponential":"interval");if(c&&((a=vc({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],_c.parse(a[1])])),a.default=_c.parse(a.default?a.default:b.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!si[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let g,h,i;if("exponential"===f)g=Om;else if("interval"===f)g=Nm;else if("categorical"===f){for(const j of(g=Mm,h=Object.create(null),a.stops))h[j[0]]=j[1];i=typeof a.stops[0][0]}else{if("identity"!==f)throw new Error(`Unknown function type "${f}"`);g=Pm}if(d){const k={},l=[];for(let m=0;ma[0]),evaluate:({zoom:c},d)=>Om({stops:p,base:a.base},b,c).evaluate(c,d)}}if(e){const s="exponential"===f?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:s,interpolationFactor:ti.interpolationFactor.bind(void 0,s),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:c})=>g(a,b,c,h,i)}}return{kind:"source",evaluate(c,d){const e=d&&d.properties?d.properties[a.property]:void 0;return void 0===e?Lm(a.default,b.default):g(a,b,e,h,i)}}}function Lm(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function Mm(a,b,c,d,e){return Lm(typeof c===e?d[c]:void 0,a.default,b.default)}function Nm(a,b,c){if("number"!==Hm(c))return Lm(a.default,b.default);const d=a.stops.length;if(1===d)return a.stops[0][1];if(c<=a.stops[0][0])return a.stops[0][1];if(c>=a.stops[d-1][0])return a.stops[d-1][1];const e=Eh(a.stops.map(a=>a[0]),c);return a.stops[e][1]}function Om(a,b,c){const d=void 0!==a.base?a.base:1;if("number"!==Hm(c))return Lm(a.default,b.default);const e=a.stops.length;if(1===e)return a.stops[0][1];if(c<=a.stops[0][0])return a.stops[0][1];if(c>=a.stops[e-1][0])return a.stops[e-1][1];const f=Eh(a.stops.map(a=>a[0]),c),g=function(a,b,c,d){const e=d-c,f=a-c;return 0===e?0:1===b?f/e:(Math.pow(b,f)-1)/(Math.pow(b,e)-1)}(c,d,a.stops[f][0],a.stops[f+1][0]),h=a.stops[f][1],i=a.stops[f+1][1];let j=ei[b.type]||Jm;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=si[a.colorSpace];j=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),g))}return"function"==typeof h.evaluate?{evaluate(...a){const b=h.evaluate.apply(void 0,a),c=i.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return j(b,c,g)}}:j(h,i,g)}function Pm(a,b,c){return"color"===b.type?c=_c.parse(c):"formatted"===b.type?c=Ad.fromString(c.toString()):"resolvedImage"===b.type?c=Hd.fromString(c.toString()):Hm(c)===b.type||"enum"===b.type&&b.values[c]||(c=void 0),Lm(c,a.default,b.default)}yf.register(xm,{error:[{kind:"error"},[Lc],(a,[b])=>{throw new Wd(b.evaluate(a))}],typeof:[Lc,[Pc],(a,[b])=>Uc(Md(b.evaluate(a)))],"to-rgba":[Tc(Kc,4),[Nc],(a,[b])=>b.evaluate(a).toArray()],rgb:[Nc,[Kc,Kc,Kc],ym],rgba:[Nc,[Kc,Kc,Kc,Kc],ym],has:{type:Mc,overloads:[[[Lc],(a,[b])=>zm(b.evaluate(a),a.properties())],[[Lc,Oc],(a,[b,c])=>zm(b.evaluate(a),c.evaluate(a))]]},get:{type:Pc,overloads:[[[Lc],(a,[b])=>Am(b.evaluate(a),a.properties())],[[Lc,Oc],(a,[b,c])=>Am(b.evaluate(a),c.evaluate(a))]]},"feature-state":[Pc,[Lc],(a,[b])=>Am(b.evaluate(a),a.featureState||{})],properties:[Oc,[],a=>a.properties()],"geometry-type":[Lc,[],a=>a.geometryType()],id:[Pc,[],a=>a.id()],zoom:[Kc,[],a=>a.globals.zoom],pitch:[Kc,[],a=>a.globals.pitch||0],"distance-from-center":[Kc,[],a=>a.distanceFromCenter()],"heatmap-density":[Kc,[],a=>a.globals.heatmapDensity||0],"line-progress":[Kc,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[Kc,[],a=>a.globals.skyRadialProgress||0],accumulated:[Pc,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated],"+":[Kc,Bm(Kc),(a,b)=>{let c=0;for(const d of b)c+=d.evaluate(a);return c}],"*":[Kc,Bm(Kc),(a,b)=>{let c=1;for(const d of b)c*=d.evaluate(a);return c}],"-":{type:Kc,overloads:[[[Kc,Kc],(a,[b,c])=>b.evaluate(a)-c.evaluate(a)],[[Kc],(a,[b])=>-b.evaluate(a)]]},"/":[Kc,[Kc,Kc],(a,[b,c])=>b.evaluate(a)/c.evaluate(a)],"%":[Kc,[Kc,Kc],(a,[b,c])=>b.evaluate(a)%c.evaluate(a)],ln2:[Kc,[],()=>Math.LN2],pi:[Kc,[],()=>Math.PI],e:[Kc,[],()=>Math.E],"^":[Kc,[Kc,Kc],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a))],sqrt:[Kc,[Kc],(a,[b])=>Math.sqrt(b.evaluate(a))],log10:[Kc,[Kc],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10],ln:[Kc,[Kc],(a,[b])=>Math.log(b.evaluate(a))],log2:[Kc,[Kc],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2],sin:[Kc,[Kc],(a,[b])=>Math.sin(b.evaluate(a))],cos:[Kc,[Kc],(a,[b])=>Math.cos(b.evaluate(a))],tan:[Kc,[Kc],(a,[b])=>Math.tan(b.evaluate(a))],asin:[Kc,[Kc],(a,[b])=>Math.asin(b.evaluate(a))],acos:[Kc,[Kc],(a,[b])=>Math.acos(b.evaluate(a))],atan:[Kc,[Kc],(a,[b])=>Math.atan(b.evaluate(a))],min:[Kc,Bm(Kc),(a,b)=>Math.min(...b.map(b=>b.evaluate(a)))],max:[Kc,Bm(Kc),(a,b)=>Math.max(...b.map(b=>b.evaluate(a)))],abs:[Kc,[Kc],(a,[b])=>Math.abs(b.evaluate(a))],round:[Kc,[Kc],(a,[b])=>{const c=b.evaluate(a);return c<0?-Math.round(-c):Math.round(c)}],floor:[Kc,[Kc],(a,[b])=>Math.floor(b.evaluate(a))],ceil:[Kc,[Kc],(a,[b])=>Math.ceil(b.evaluate(a))],"filter-==":[Mc,[Lc,Pc],(a,[b,c])=>a.properties()[b.value]===c.value],"filter-id-==":[Mc,[Pc],(a,[b])=>a.id()===b.value],"filter-type-==":[Mc,[Lc],(a,[b])=>a.geometryType()===b.value],"filter-<":[Mc,[Lc,Pc],(a,[b,c])=>{const d=a.properties()[b.value],e=c.value;return typeof d==typeof e&&d{const c=a.id(),d=b.value;return typeof c==typeof d&&c":[Mc,[Lc,Pc],(a,[b,c])=>{const d=a.properties()[b.value],e=c.value;return typeof d==typeof e&&d>e}],"filter-id->":[Mc,[Pc],(a,[b])=>{const c=a.id(),d=b.value;return typeof c==typeof d&&c>d}],"filter-<=":[Mc,[Lc,Pc],(a,[b,c])=>{const d=a.properties()[b.value],e=c.value;return typeof d==typeof e&&d<=e}],"filter-id-<=":[Mc,[Pc],(a,[b])=>{const c=a.id(),d=b.value;return typeof c==typeof d&&c<=d}],"filter->=":[Mc,[Lc,Pc],(a,[b,c])=>{const d=a.properties()[b.value],e=c.value;return typeof d==typeof e&&d>=e}],"filter-id->=":[Mc,[Pc],(a,[b])=>{const c=a.id(),d=b.value;return typeof c==typeof d&&c>=d}],"filter-has":[Mc,[Pc],(a,[b])=>b.value in a.properties()],"filter-has-id":[Mc,[],a=>null!==a.id()&& void 0!==a.id()],"filter-type-in":[Mc,[Tc(Lc)],(a,[b])=>b.value.indexOf(a.geometryType())>=0],"filter-id-in":[Mc,[Tc(Pc)],(a,[b])=>b.value.indexOf(a.id())>=0],"filter-in-small":[Mc,[Lc,Tc(Pc)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0],"filter-in-large":[Mc,[Lc,Tc(Pc)],(a,[b,c])=>(function(a,b,c,d){for(;c<=d;){const e=c+d>>1;if(b[e]===a)return!0;b[e]>a?d=e-1:c=e+1}return!1})(a.properties()[b.value],c.value,0,c.value.length-1)],all:{type:Mc,overloads:[[[Mc,Mc],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a)],[Bm(Mc),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0}]]},any:{type:Mc,overloads:[[[Mc,Mc],(a,[b,c])=>b.evaluate(a)||c.evaluate(a)],[Bm(Mc),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1}]]},"!":[Mc,[Mc],(a,[b])=>!b.evaluate(a)],"is-supported-script":[Mc,[Lc],(a,[b])=>{const c=a.globals&&a.globals.isSupportedScript;return!c||c(b.evaluate(a))}],upcase:[Lc,[Lc],(a,[b])=>b.evaluate(a).toUpperCase()],downcase:[Lc,[Lc],(a,[b])=>b.evaluate(a).toLowerCase()],concat:[Lc,Bm(Pc),(a,b)=>b.map(b=>Nd(b.evaluate(a))).join("")],"resolved-locale":[Lc,[Qc],(a,[b])=>b.evaluate(a).resolvedLocale()]});class Qm{constructor(Rm,Sm){var Tm;this.expression=Rm,this._warningHistory={},this._evaluator=new rf,this._defaultValue=Sm?"color"===(Tm=Sm).type&&Im(Tm.default)?new _c(0,0,0,0):"color"===Tm.type?_c.parse(Tm.default)||null:void 0===Tm.default?null:Tm.default:null,this._enumValues=Sm&&"enum"===Sm.type?Sm.values:null}evaluateWithoutErrorHandling(Um,Vm,Wm,Xm,Ym,Zm,$m,_m){return this._evaluator.globals=Um,this._evaluator.feature=Vm,this._evaluator.featureState=Wm,this._evaluator.canonical=Xm,this._evaluator.availableImages=Ym||null,this._evaluator.formattedSection=Zm,this._evaluator.featureTileCoord=$m||null,this._evaluator.featureDistanceData=_m||null,this.expression.evaluate(this._evaluator)}evaluate(an,bn,cn,dn,en,fn,gn,hn){this._evaluator.globals=an,this._evaluator.feature=bn||null,this._evaluator.featureState=cn||null,this._evaluator.canonical=dn,this._evaluator.availableImages=en||null,this._evaluator.formattedSection=fn||null,this._evaluator.featureTileCoord=gn||null,this._evaluator.featureDistanceData=hn||null;try{const jn=this.expression.evaluate(this._evaluator);if(null==jn||"number"==typeof jn&&jn!=jn)return this._defaultValue;if(this._enumValues&&!(jn in this._enumValues))throw new Wd(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(jn)} instead.`);return jn}catch(kn){return this._warningHistory[kn.message]||(this._warningHistory[kn.message]=!0,"undefined"!=typeof console&&console.warn(kn.message)),this._defaultValue}}}function ln(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in xm}function mn(a,b){const c=new Zg(xm,[],b?function(a){const b={color:Nc,string:Lc,number:Kc,enum:Lc,boolean:Mc,formatted:Rc,resolvedImage:Sc};return"array"===a.type?Tc(b[a.value]||Pc,a.length):b[a.type]}(b):void 0),d=c.parse(a,void 0,void 0,void 0,b&&"string"===b.type?{typeAnnotation:"coerce"}:void 0);return d?Cm(new Qm(d,b)):Dm(c.errors)}class nn{constructor(on,pn){this.kind=on,this._styleExpression=pn,this.isStateDependent="constant"!==on&&!Qg(pn.expression)}evaluateWithoutErrorHandling(qn,rn,sn,tn,un,vn){return this._styleExpression.evaluateWithoutErrorHandling(qn,rn,sn,tn,un,vn)}evaluate(wn,xn,yn,zn,An,Bn){return this._styleExpression.evaluate(wn,xn,yn,zn,An,Bn)}}class Cn{constructor(Dn,En,Fn,Gn){this.kind=Dn,this.zoomStops=Fn,this._styleExpression=En,this.isStateDependent="camera"!==Dn&&!Qg(En.expression),this.interpolationType=Gn}evaluateWithoutErrorHandling(Hn,In,Jn,Kn,Ln,Mn){return this._styleExpression.evaluateWithoutErrorHandling(Hn,In,Jn,Kn,Ln,Mn)}evaluate(Nn,On,Pn,Qn,Rn,Sn){return this._styleExpression.evaluate(Nn,On,Pn,Qn,Rn,Sn)}interpolationFactor(Tn,Un,Vn){return this.interpolationType?ti.interpolationFactor(this.interpolationType,Tn,Un,Vn):0}}function Wn(a,b){if("error"===(a=mn(a,b)).result)return a;const c=a.value.expression,d=Pg(c);if(!d&&!Em(b))return Dm([new yc("","data expressions not supported")]);const e=Rg(c,["zoom","pitch","distance-from-center"]);if(!e&&!Fm(b))return Dm([new yc("","zoom expressions not supported")]);const f=ao(c);return f||e?f instanceof yc?Dm([f]):f instanceof ti&&!Gm(b)?Dm([new yc("","\"interpolate\" expressions cannot be used with this property")]):Cm(f?new Cn(d?"camera":"composite",a.value,f.labels,f instanceof ti?f.interpolation:void 0):new nn(d?"constant":"source",a.value)):Dm([new yc("","\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.")])}class Xn{constructor(Yn,Zn){this._parameters=Yn,this._specification=Zn,vc(this,Km(this._parameters,this._specification))}static deserialize($n){return new Xn($n._parameters,$n._specification)}static serialize(_n){return{_parameters:_n._parameters,_specification:_n._specification}}}function ao(a){let b=null;if(a instanceof Cj)b=ao(a.result);else if(a instanceof kj){for(const c of a.args)if(b=ao(c))break}else(a instanceof Fh||a instanceof ti)&&a.input instanceof yf&&"zoom"===a.input.name&&(b=a);return b instanceof yc||a.eachChild(a=>{const c=ao(a);c instanceof yc?b=c:!b&&c?b=new yc("","\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression."):b&&c&&b!==c&&(b=new yc("","Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression."))}),b}function bo(a){const b=a.key,c=a.value,d=a.valueSpec||{},e=a.objectElementValidators||{},f=a.style,g=a.styleSpec;let h=[];const i=Hm(c);if("object"!==i)return[new pc(b,c,`object expected, ${i} found`)];for(const j in c){const k=j.split(".")[0],l=d[k]||d["*"];let m;if(e[k])m=e[k];else if(d[k])m=Jo;else if(e["*"])m=e["*"];else{if(!d["*"]){h.push(new pc(b,c[j],`unknown property "${j}"`));continue}m=Jo}h=h.concat(m({key:(b?`${b}.`:b)+j,value:c[j],valueSpec:l,style:f,styleSpec:g,object:c,objectKey:j},c))}for(const n in d)e[n]||d[n].required&& void 0===d[n].default&& void 0===c[n]&&h.push(new pc(b,c,`missing required property "${n}"`));return h}function co(a){const b=a.value,c=a.valueSpec,d=a.style,e=a.styleSpec,f=a.key,g=a.arrayElementValidator||Jo;if("array"!==Hm(b))return[new pc(f,b,`array expected, ${Hm(b)} found`)];if(c.length&&b.length!==c.length)return[new pc(f,b,`array length ${c.length} expected, length ${b.length} found`)];if(c["min-length"]&&b.lengthg)return[new pc(b,c,`${c} is greater than the maximum value ${g}`)]}return[]}function fo(a){const b=a.valueSpec,c=wc(a.value.type);let d,e,f,g={};const h="categorical"!==c&& void 0===a.value.property,i="array"===Hm(a.value.stops)&&"array"===Hm(a.value.stops[0])&&"object"===Hm(a.value.stops[0][0]),j=bo({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(a){if("identity"===c)return[new pc(a.key,a.value,"identity function may not have a \"stops\" property")];let b=[];const d=a.value;return b=b.concat(co({key:a.key,value:d,valueSpec:a.valueSpec,style:a.style,styleSpec:a.styleSpec,arrayElementValidator:k})),"array"===Hm(d)&&0===d.length&&b.push(new pc(a.key,d,"array must have at least one stop")),b},default:function(a){return Jo({key:a.key,value:a.value,valueSpec:b,style:a.style,styleSpec:a.styleSpec})}}});return"identity"===c&&h&&j.push(new pc(a.key,a.value,"missing required property \"property\"")),"identity"===c||a.value.stops||j.push(new pc(a.key,a.value,"missing required property \"stops\"")),"exponential"===c&&a.valueSpec.expression&&!Gm(a.valueSpec)&&j.push(new pc(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(h||Em(a.valueSpec)?h&&!Fm(a.valueSpec)&&j.push(new pc(a.key,a.value,"zoom functions not supported")):j.push(new pc(a.key,a.value,"property functions not supported"))),("categorical"===c||i)&& void 0===a.value.property&&j.push(new pc(a.key,a.value,"\"property\" property is required")),j;function k(a){let c=[];const d=a.value,h=a.key;if("array"!==Hm(d))return[new pc(h,d,`array expected, ${Hm(d)} found`)];if(2!==d.length)return[new pc(h,d,`array length 2 expected, length ${d.length} found`)];if(i){if("object"!==Hm(d[0]))return[new pc(h,d,`object expected, ${Hm(d[0])} found`)];if(void 0===d[0].zoom)return[new pc(h,d,"object stop key must have zoom")];if(void 0===d[0].value)return[new pc(h,d,"object stop key must have value")];if(f&&f>wc(d[0].zoom))return[new pc(h,d[0].zoom,"stop zoom values must appear in ascending order")];wc(d[0].zoom)!==f&&(f=wc(d[0].zoom),e=void 0,g={}),c=c.concat(bo({key:`${h}[0]`,value:d[0],valueSpec:{zoom:{}},style:a.style,styleSpec:a.styleSpec,objectElementValidators:{zoom:eo,value:l}}))}else c=c.concat(l({key:`${h}[0]`,value:d[0],valueSpec:{},style:a.style,styleSpec:a.styleSpec},d));return ln(xc(d[1]))?c.concat([new pc(`${h}[1]`,d[1],"expressions are not allowed in function stops.")]):c.concat(Jo({key:`${h}[1]`,value:d[1],valueSpec:b,style:a.style,styleSpec:a.styleSpec}))}function l(a,f){const h=Hm(a.value),i=wc(a.value),j=null!==a.value?a.value:f;if(d){if(h!==d)return[new pc(a.key,j,`${h} stop domain type must match previous stop domain type ${d}`)]}else d=h;if("number"!==h&&"string"!==h&&"boolean"!==h)return[new pc(a.key,j,"stop domain value must be a number, string, or boolean")];if("number"!==h&&"categorical"!==c){let k=`number expected, ${h} found`;return Em(b)&& void 0===c&&(k+="\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`."),[new pc(a.key,j,k)]}return"categorical"!==c||"number"!==h||isFinite(i)&&Math.floor(i)===i?"categorical"!==c&&"number"===h&& void 0!==e&&inew pc(`${a.key}${b.key}`,a.value,b.message));const c=b.value.expression||b.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!c.outputDefined())return[new pc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===a.expressionContext&&"layout"===a.propertyType&&!Qg(c))return[new pc(a.key,a.value,"\"feature-state\" data expressions are not supported with layout properties.")];if("filter"===a.expressionContext)return ho(c,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!Rg(c,["zoom","feature-state"]))return[new pc(a.key,a.value,"\"zoom\" and \"feature-state\" expressions are not supported with cluster properties.")];if("cluster-initial"===a.expressionContext&&!Pg(c))return[new pc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ho(a,b){const c=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const d of b.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return a instanceof yf&&c.has(a.name)?[new pc(b.key,b.value,`["${a.name}"] expression is not supported in a filter for a ${b.object.type} layer with id: ${b.object.id}`)]:(a.eachChild(a=>{e.push(...ho(a,b))}),e)}function io(a){const b=a.key,c=a.value,d=a.valueSpec,e=[];return Array.isArray(d.values)?-1===d.values.indexOf(wc(c))&&e.push(new pc(b,c,`expected one of [${d.values.join(", ")}], ${JSON.stringify(c)} found`)):-1===Object.keys(d.values).indexOf(wc(c))&&e.push(new pc(b,c,`expected one of [${Object.keys(d.values).join(", ")}], ${JSON.stringify(c)} found`)),e}function jo(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!jo(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function ko(a,b="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};jo(a)||(a=ro(a));const c=a;let d=!0;try{d=(function(a){if(!no(a))return a;let b=xc(a);return mo(b),b=lo(b)})(c)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(c,null,2)}\n `)}const f=oc[`filter_${b}`],g=mn(d,f);let h=null;if("error"===g.result)throw new Error(g.value.map(a=>`${a.key}: ${a.message}`).join(", "));h=(a,b,c)=>g.value.evaluate(a,b,{},c);let i=null,j=null;if(d!==c){const k=mn(c,f);if("error"===k.result)throw new Error(k.value.map(a=>`${a.key}: ${a.message}`).join(", "));i=(a,b,c,d,e)=>k.value.evaluate(a,b,{},c,void 0,void 0,d,e),j=!Pg(k.value.expression)}return{filter:h,dynamicFilter:i||void 0,needGeometry:qo(d),needFeature:!!j}}function lo(a){if(!Array.isArray(a))return a;const b=function(a){if(oo.has(a[0])){for(let b=1;blo(a))}function mo(a){let b=!1;const c=[];if("case"===a[0]){for(let d=1;d",">=","<","<=","to-boolean"]);function po(a,b){return ab?1:0}function qo(a){if(!Array.isArray(a))return!1;if("within"===a[0])return!0;for(let b=1;b"===c||"<="===c||">="===c?so(a[1],a[2],c):"any"===c?(b=a.slice(1),["any"].concat(b.map(ro))):"all"===c?["all"].concat(a.slice(1).map(ro)):"none"===c?["all"].concat(a.slice(1).map(ro).map(vo)):"in"===c?to(a[1],a.slice(2)):"!in"===c?vo(to(a[1],a.slice(2))):"has"===c?uo(a[1]):"!has"===c?vo(uo(a[1])):"within"!==c||a}function so(a,b,c){switch(a){case"$type":return[`filter-type-${c}`,b];case"$id":return[`filter-id-${c}`,b];default:return[`filter-${c}`,a,b]}}function to(a,b){if(0===b.length)return!1;switch(a){case"$type":return["filter-type-in",["literal",b]];case"$id":return["filter-id-in",["literal",b]];default:return b.length>200&&!b.some(a=>typeof a!=typeof b[0])?["filter-in-large",a,["literal",b.sort(po)]]:["filter-in-small",a,["literal",b]]}}function uo(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function vo(a){return["!",a]}function wo(a){if(jo(xc(a.value))){const b=xc(a.layerType);return go(vc({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${b||"fill"}`]}))}return xo(a)}function xo(a){const b=a.value,c=a.key;if("array"!==Hm(b))return[new pc(c,b,`array expected, ${Hm(b)} found`)];const d=a.styleSpec;let e,f=[];if(b.length<1)return[new pc(c,b,"filter array must have at least 1 element")];switch(f=f.concat(io({key:`${c}[0]`,value:b[0],valueSpec:d.filter_operator,style:a.style,styleSpec:a.styleSpec})),wc(b[0])){case"<":case"<=":case">":case">=":b.length>=2&&"$type"===wc(b[1])&&f.push(new pc(c,b,`"$type" cannot be use with operator "${b[0]}"`));case"==":case"!=":3!==b.length&&f.push(new pc(c,b,`filter array for operator "${b[0]}" must have 3 elements`));case"in":case"!in":b.length>=2&&"string"!==(e=Hm(b[1]))&&f.push(new pc(`${c}[1]`,b[1],`string expected, ${e} found`));for(let g=2;g{a in c&&b.push(new pc(d,c[a],`"${a}" is prohibited for ref layers`))}),e.layers.forEach(a=>{wc(a.id)===h&&(l=a)}),l?l.ref?b.push(new pc(d,c.ref,"ref cannot reference another ref layer")):g=wc(l.type):b.push(new pc(d,c.ref,`ref layer "${h}" not found`))}else if("background"!==g&&"sky"!==g)if(c.source){const m=e.sources&&e.sources[c.source],n=m&&wc(m.type);m?"vector"===n&&"raster"===g?b.push(new pc(d,c.source,`layer "${c.id}" requires a raster source`)):"raster"===n&&"raster"!==g?b.push(new pc(d,c.source,`layer "${c.id}" requires a vector source`)):"vector"!==n||c["source-layer"]?"raster-dem"===n&&"hillshade"!==g?b.push(new pc(d,c.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===g&&c.paint&&c.paint["line-gradient"]&&("geojson"!==n||!m.lineMetrics)&&b.push(new pc(d,c,`layer "${c.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):b.push(new pc(d,c,`layer "${c.id}" must specify a "source-layer"`)):b.push(new pc(d,c.source,`source "${c.source}" not found`))}else b.push(new pc(d,c,"missing required property \"source\""));return b=b.concat(bo({key:d,value:c,valueSpec:f.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Jo({key:`${d}.type`,value:c.type,valueSpec:f.layer.type,style:a.style,styleSpec:a.styleSpec,object:c,objectKey:"type"}),filter:a=>wo(vc({layerType:g},a)),layout:a=>bo({layer:c,key:a.key,value:a.value,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":a=>Ao(vc({layerType:g},a))}}),paint:a=>bo({layer:c,key:a.key,value:a.value,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":a=>zo(vc({layerType:g},a))}})}}))}function Co(a){const b=a.value,c=a.key,d=Hm(b);return"string"!==d?[new pc(c,b,`string expected, ${d} found`)]:[]}const Do={promoteId:function({key:a,value:b}){if("string"===Hm(b))return Co({key:a,value:b});{const c=[];for(const d in b)c.push(...Co({key:`${a}.${d}`,value:b[d]}));return c}}};function Eo(a){const b=a.value,c=a.key,d=a.styleSpec,e=a.style;if(!b.type)return[new pc(c,b,"\"type\" is required")];const f=wc(b.type);let g;switch(f){case"vector":case"raster":case"raster-dem":return g=bo({key:c,value:b,valueSpec:d[`source_${f.replace("-","_")}`],style:a.style,styleSpec:d,objectElementValidators:Do});case"geojson":if(g=bo({key:c,value:b,valueSpec:d.source_geojson,style:e,styleSpec:d,objectElementValidators:Do}),b.cluster)for(const h in b.clusterProperties){const[i,j]=b.clusterProperties[h],k="string"==typeof i?[i,["accumulated"],["get",h]]:i;g.push(...go({key:`${c}.${h}.map`,value:j,expressionContext:"cluster-map"})),g.push(...go({key:`${c}.${h}.reduce`,value:k,expressionContext:"cluster-reduce"}))}return g;case"video":return bo({key:c,value:b,valueSpec:d.source_video,style:e,styleSpec:d});case"image":return bo({key:c,value:b,valueSpec:d.source_image,style:e,styleSpec:d});case"canvas":return[new pc(c,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return io({key:`${c}.type`,value:b.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:e,styleSpec:d})}}function Fo(a){const b=a.value,c=a.styleSpec,d=c.light,e=a.style;let f=[];const g=Hm(b);if(void 0===b)return f;if("object"!==g)return f=f.concat([new pc("light",b,`object expected, ${g} found`)]);for(const h in b){const i=h.match(/^(.*)-transition$/);f=f.concat(i&&d[i[1]]&&d[i[1]].transition?Jo({key:h,value:b[h],valueSpec:c.transition,style:e,styleSpec:c}):d[h]?Jo({key:h,value:b[h],valueSpec:d[h],style:e,styleSpec:c}):[new pc(h,b[h],`unknown property "${h}"`)])}return f}function Go(a){const b=a.value,c=a.key,d=a.style,e=a.styleSpec,f=e.terrain;let g=[];const h=Hm(b);if(void 0===b)return g;if("object"!==h)return g=g.concat([new pc("terrain",b,`object expected, ${h} found`)]);for(const i in b){const j=i.match(/^(.*)-transition$/);g=g.concat(j&&f[j[1]]&&f[j[1]].transition?Jo({key:i,value:b[i],valueSpec:e.transition,style:d,styleSpec:e}):f[i]?Jo({key:i,value:b[i],valueSpec:f[i],style:d,styleSpec:e}):[new pc(i,b[i],`unknown property "${i}"`)])}if(b.source){const k=d.sources&&d.sources[b.source],l=k&&wc(k.type);k?"raster-dem"!==l&&g.push(new pc(c,b.source,`terrain cannot be used with a source of type ${l}, it only be used with a "raster-dem" source type`)):g.push(new pc(c,b.source,`source "${b.source}" not found`))}else g.push(new pc(c,b,"terrain is missing required property \"source\""));return g}function Ho(a){const b=a.value,c=a.style,d=a.styleSpec,e=d.fog;let f=[];const g=Hm(b);if(void 0===b)return f;if("object"!==g)return f=f.concat([new pc("fog",b,`object expected, ${g} found`)]);for(const h in b){const i=h.match(/^(.*)-transition$/);f=f.concat(i&&e[i[1]]&&e[i[1]].transition?Jo({key:h,value:b[h],valueSpec:d.transition,style:c,styleSpec:d}):e[h]?Jo({key:h,value:b[h],valueSpec:e[h],style:c,styleSpec:d}):[new pc(h,b[h],`unknown property "${h}"`)])}return f}const Io={"*":()=>[],array:co,boolean:function(a){const b=a.value,c=a.key,d=Hm(b);return"boolean"!==d?[new pc(c,b,`boolean expected, ${d} found`)]:[]},number:eo,color:function(a){const b=a.key,c=a.value,d=Hm(c);return"string"!==d?[new pc(b,c,`color expected, ${d} found`)]:null===$c.parseCSSColor(c)?[new pc(b,c,`color expected, "${c}" found`)]:[]},constants:uc,enum:io,filter:wo,function:fo,layer:Bo,object:bo,source:Eo,light:Fo,terrain:Go,fog:Ho,string:Co,formatted:function(a){return 0===Co(a).length?[]:go(a)},resolvedImage:function(a){return 0===Co(a).length?[]:go(a)},projection:function(a){const b=a.value,c=a.styleSpec,d=c.projection,e=a.style;let f=[];const g=Hm(b);if("object"===g)for(const h in b)f=f.concat(Jo({key:h,value:b[h],valueSpec:d[h],style:e,styleSpec:c}));else"string"!==g&&(f=f.concat([new pc("projection",b,`object or string expected, ${g} found`)]));return f}};function Jo(a){const b=a.value,c=a.valueSpec,d=a.styleSpec;return c.expression&&Im(wc(b))?fo(a):c.expression&&ln(xc(b))?go(a):c.type&&Io[c.type]?Io[c.type](a):bo(vc({},a,{valueSpec:c.type?d[c.type]:c}))}function Ko(a){const b=a.value,c=a.key,d=Co(a);return d.length||(-1===b.indexOf("{fontstack}")&&d.push(new pc(c,b,"\"glyphs\" url must include a \"{fontstack}\" token")),-1===b.indexOf("{range}")&&d.push(new pc(c,b,"\"glyphs\" url must include a \"{range}\" token"))),d}function Lo(a,b=oc){let c=[];return c=c.concat(Jo({key:"",value:a,valueSpec:b.$root,styleSpec:b,style:a,objectElementValidators:{glyphs:Ko,"*":()=>[]}})),a.constants&&(c=c.concat(uc({key:"constants",value:a.constants,style:a,styleSpec:b}))),Mo(c)}function Mo(a){return[].concat(a).sort((a,b)=>a.line-b.line)}function No(a){return function(...b){return Mo(a.apply(this,b))}}Lo.source=No(Eo),Lo.light=No(Fo),Lo.terrain=No(Go),Lo.fog=No(Ho),Lo.layer=No(Bo),Lo.filter=No(wo),Lo.paintProperty=No(zo),Lo.layoutProperty=No(Ao);const Oo=Lo,Po=Oo.light,Qo=Oo.fog,Ro=Oo.paintProperty,So=Oo.layoutProperty;function To(a,b){let c=!1;if(b&&b.length)for(const d of b)a.fire(new Vb(new Error(d.message))),c=!0;return c}var Uo=Vo;function Vo(a,b,c){var d=this.cells=[];if(a instanceof ArrayBuffer){this.arrayBuffer=a;var e=new Int32Array(this.arrayBuffer);a=e[0],this.d=(b=e[1])+2*(c=e[2]);for(var f=0;f=k[n+0]&&d>=k[n+1])?(g[m]=!0,f.push(j[m])):g[m]=!1}}},Vo.prototype._forEachCell=function(a,b,c,d,e,f,g,h){for(var i=this._convertToCellCoord(a),j=this._convertToCellCoord(b),k=this._convertToCellCoord(c),l=this._convertToCellCoord(d),m=i;m<=k;m++)for(var n=j;n<=l;n++){var o=this.d*n+m;if((!h||h(this._convertFromCellCoord(m),this._convertFromCellCoord(n),this._convertFromCellCoord(m+1),this._convertFromCellCoord(n+1)))&&e.call(this,a,b,c,d,o,f,g,h))return}},Vo.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},Vo.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},Vo.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var a=this.cells,b=3+this.cells.length+1+1,c=0,d=0;d=0)continue;const j=a[i];h[i]=Yo[g].shallow.indexOf(i)>=0?j:bp(j,b)}a instanceof Error&&(h.message=a.message)}if(h.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==g&&(h.$name=g),h}throw new Error("can't serialize object of type "+typeof a)}function cp(a){if(null==a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||_o(a)||ap(a)||ArrayBuffer.isView(a)||a instanceof Wo)return a;if(Array.isArray(a))return a.map(cp);if("object"==typeof a){const b=a.$name||"Object",{klass:c}=Yo[b];if(!c)throw new Error(`can't deserialize unregistered class ${b}`);if(c.deserialize)return c.deserialize(a);const d=Object.create(c.prototype);for(const e of Object.keys(a)){if("$name"===e)continue;const f=a[e];d[e]=Yo[b].shallow.indexOf(e)>=0?f:cp(f)}return d}throw new Error("can't deserialize object of type "+typeof a)}class dp{constructor(){this.first=!0}update(ep,fp){const gp=Math.floor(ep);return this.first?(this.first=!1,this.lastIntegerZoom=gp,this.lastIntegerZoomTime=0,this.lastZoom=ep,this.lastFloorZoom=gp,!0):(this.lastFloorZoom>gp?(this.lastIntegerZoom=gp+1,this.lastIntegerZoomTime=fp):this.lastFloorZooma>=1536&&a<=1791,ip=a=>a>=1872&&a<=1919,jp=a=>a>=2208&&a<=2303,kp=a=>a>=11904&&a<=12031,lp=a=>a>=12032&&a<=12255,mp=a=>a>=12272&&a<=12287,np=a=>a>=12288&&a<=12351,op=a=>a>=12352&&a<=12447,pp=a=>a>=12448&&a<=12543,qp=a=>a>=12544&&a<=12591,rp=a=>a>=12704&&a<=12735,sp=a=>a>=12736&&a<=12783,tp=a=>a>=12784&&a<=12799,up=a=>a>=12800&&a<=13055,vp=a=>a>=13056&&a<=13311,wp=a=>a>=13312&&a<=19903,xp=a=>a>=19968&&a<=40959,yp=a=>a>=40960&&a<=42127,zp=a=>a>=42128&&a<=42191,Ap=a=>a>=44032&&a<=55215,Bp=a=>a>=63744&&a<=64255,Cp=a=>a>=64336&&a<=65023,Dp=a=>a>=65040&&a<=65055,Ep=a=>a>=65072&&a<=65103,Fp=a=>a>=65104&&a<=65135,Gp=a=>a>=65136&&a<=65279,Hp=a=>a>=65280&&a<=65519;function Ip(a){for(const b of a)if(Lp(b.charCodeAt(0)))return!0;return!1}function Jp(a){for(const b of a)if(!Kp(b.charCodeAt(0)))return!1;return!0}function Kp(a){return!(hp(a)||ip(a)||jp(a)||Cp(a)||Gp(a))}function Lp(a){var b,c,d,e,f,g,h,i;return!(746!==a&&747!==a&&(a<4352||!(rp(a)||qp(a)||Ep(a)&&!(a>=65097&&a<=65103)||Bp(a)||vp(a)||kp(a)||sp(a)||!(!np(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||12336===a)||wp(a)||xp(a)||up(a)||(b=a)>=12592&&b<=12687||(c=a)>=43360&&c<=43391||(d=a)>=55216&&d<=55295||(e=a)>=4352&&e<=4607||Ap(a)||op(a)||mp(a)||(f=a)>=12688&&f<=12703||lp(a)||tp(a)||pp(a)&&12540!==a||!(!Hp(a)||65288===a||65289===a||65293===a||a>=65306&&a<=65310||65339===a||65341===a||65343===a||a>=65371&&a<=65503||65507===a||a>=65512&&a<=65519)||!(!Fp(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(g=a)>=5120&&g<=5759||(h=a)>=6320&&h<=6399||Dp(a)||(i=a)>=19904&&i<=19967||yp(a)||zp(a))))}function Mp(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;return!(Lp(a)||(c=b=a)>=128&&c<=255&&(167===b||169===b||174===b||177===b||188===b||189===b||190===b||215===b||247===b)||(d=b)>=8192&&d<=8303&&(8214===b||8224===b||8225===b||8240===b||8241===b||8251===b||8252===b||8258===b||8263===b||8264===b||8265===b||8273===b)||(e=b)>=8448&&e<=8527||(f=b)>=8528&&f<=8591||(g=b)>=8960&&g<=9215&&(b>=8960&&b<=8967||b>=8972&&b<=8991||b>=8996&&b<=9e3||9003===b||b>=9085&&b<=9114||b>=9150&&b<=9165||9167===b||b>=9169&&b<=9179||b>=9186&&b<=9215)||(h=b)>=9216&&h<=9279&&9251!==b||(i=b)>=9280&&i<=9311||(j=b)>=9312&&j<=9471||(k=b)>=9632&&k<=9727||(l=b)>=9728&&l<=9983&&!(b>=9754&&b<=9759)||(m=b)>=11008&&m<=11263&&(b>=11026&&b<=11055||b>=11088&&b<=11097||b>=11192&&b<=11243)||np(b)||pp(b)||(n=b)>=57344&&n<=63743||Ep(b)||Fp(b)||Hp(b)||8734===b||8756===b||8757===b||b>=9984&&b<=10087||b>=10102&&b<=10131||65532===b||65533===b)}function Np(a){return a>=1424&&a<=2303||Cp(a)||Gp(a)}function Op(a,b){var c;return!(!b&&Np(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(c=a)>=6016&&c<=6143)}function Pp(a){for(const b of a)if(Np(b.charCodeAt(0)))return!0;return!1}const Qp="deferred",Rp="loading",Sp="loaded";let Tp=null,Up="unavailable",Vp=null;const Wp=function(a){a&&"string"==typeof a&&a.indexOf("NetworkError")> -1&&(Up="error"),Tp&&Tp(a)};function Xp(){Yp.fire(new Sb("pluginStateChange",{pluginStatus:Up,pluginURL:Vp}))}const Yp=new Yb,Zp=function(){return Up},$p=function(){if(Up!==Qp||!Vp)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Up=Rp,Xp(),Vp&&Ib({url:Vp},a=>{a?Wp(a):(Up=Sp,Xp())})},_p={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Up===Sp||null!=_p.applyArabicShaping,isLoading:()=>Up===Rp,setState(a){Up=a.pluginStatus,Vp=a.pluginURL},isParsed:()=>null!=_p.applyArabicShaping&&null!=_p.processBidirectionalText&&null!=_p.processStyledBidirectionalText,getPluginURL:()=>Vp};class aq{constructor(bq,cq){this.zoom=bq,cq?(this.now=cq.now,this.fadeDuration=cq.fadeDuration,this.zoomHistory=cq.zoomHistory,this.transition=cq.transition,this.pitch=cq.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new dp,this.transition={},this.pitch=0)}isSupportedScript(dq){return(function(a,b){for(const c of a)if(!Op(c.charCodeAt(0),b))return!1;return!0})(dq,_p.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const eq=this.zoom,fq=eq-Math.floor(eq),gq=this.crossFadingFactor();return eq>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:fq+(1-fq)*gq}:{fromScale:.5,toScale:1,t:1-(1-gq)*fq}}}class hq{constructor(iq,jq){this.property=iq,this.value=jq,this.expression=(function(a,b){if(Im(a))return new Xn(a,b);if(ln(a)){const c=Wn(a,b);if("error"===c.result)throw new Error(c.value.map(a=>`${a.key}: ${a.message}`).join(", "));return c.value}{let d=a;return"string"==typeof a&&"color"===b.type&&(d=_c.parse(a)),{kind:"constant",evaluate:()=>d}}})(void 0===jq?iq.specification.default:jq,iq.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(kq,lq,mq){return this.property.possiblyEvaluate(this,kq,lq,mq)}}class nq{constructor(oq){this.property=oq,this.value=new hq(oq,void 0)}transitioned(pq,qq){return new Jq(this.property,this.value,qq,_({},pq.transition,this.transition),pq.now)}untransitioned(){return new Jq(this.property,this.value,null,{},0)}}class rq{constructor(sq){this._properties=sq,this._values=Object.create(sq.defaultTransitionablePropertyValues)}getValue(tq){return ja(this._values[tq].value.value)}setValue(uq,vq){this._values.hasOwnProperty(uq)||(this._values[uq]=new nq(this._values[uq].property)),this._values[uq].value=new hq(this._values[uq].property,null===vq?void 0:ja(vq))}getTransition(wq){return ja(this._values[wq].transition)}setTransition(xq,yq){this._values.hasOwnProperty(xq)||(this._values[xq]=new nq(this._values[xq].property)),this._values[xq].transition=ja(yq)||void 0}serialize(){const zq={};for(const Aq of Object.keys(this._values)){const Bq=this.getValue(Aq);void 0!==Bq&&(zq[Aq]=Bq);const Cq=this.getTransition(Aq);void 0!==Cq&&(zq[`${Aq}-transition`]=Cq)}return zq}transitioned(Dq,Eq){const Fq=new Yq(this._properties);for(const Gq of Object.keys(this._values))Fq._values[Gq]=this._values[Gq].transitioned(Dq,Eq._values[Gq]);return Fq}untransitioned(){const Hq=new Yq(this._properties);for(const Iq of Object.keys(this._values))Hq._values[Iq]=this._values[Iq].untransitioned();return Hq}}class Jq{constructor(Kq,Lq,Mq,Nq,Oq){const Pq=Nq.delay||0,Qq=Nq.duration||0;Oq=Oq||0,this.property=Kq,this.value=Lq,this.begin=Oq+Pq,this.end=this.begin+Qq,Kq.specification.transition&&(Nq.delay||Nq.duration)&&(this.prior=Mq)}possiblyEvaluate(Rq,Sq,Tq){const Uq=Rq.now||0,Vq=this.value.possiblyEvaluate(Rq,Sq,Tq),Wq=this.prior;if(Wq){if(Uq>this.end)return this.prior=null,Vq;if(this.value.isDataDriven())return this.prior=null,Vq;if(Uqgs.zoomHistory.lastIntegerZoom?{from:ds,to:es,other:fs}:{from:fs,to:es,other:ds}}interpolate(hs){return hs}}class is{constructor(js){this.specification=js}possiblyEvaluate(ks,ls,ms,ns){if(void 0!==ks.value){if("constant"===ks.expression.kind){const os=ks.expression.evaluate(ls,null,{},ms,ns);return this._calculate(os,os,os,ls)}return this._calculate(ks.expression.evaluate(new aq(Math.floor(ls.zoom-1),ls)),ks.expression.evaluate(new aq(Math.floor(ls.zoom),ls)),ks.expression.evaluate(new aq(Math.floor(ls.zoom+1),ls)),ls)}}_calculate(ps,qs,rs,ss){return ss.zoom>ss.zoomHistory.lastIntegerZoom?{from:ps,to:qs}:{from:rs,to:qs}}interpolate(ts){return ts}}class us{constructor(vs){this.specification=vs}possiblyEvaluate(ws,xs,ys,zs){return!!ws.expression.evaluate(xs,null,{},ys,zs)}interpolate(){return!1}}class As{constructor(Bs){for(const Cs in this.properties=Bs,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],Bs){const Ds=Bs[Cs];Ds.specification.overridable&&this.overridableProperties.push(Cs);const Es=this.defaultPropertyValues[Cs]=new hq(Ds,void 0),Fs=this.defaultTransitionablePropertyValues[Cs]=new nq(Ds);this.defaultTransitioningPropertyValues[Cs]=Fs.untransitioned(),this.defaultPossiblyEvaluatedValues[Cs]=Es.possiblyEvaluate({})}}}function Gs(a,b){return 256*(a=W(Math.floor(a),0,255))+W(Math.floor(b),0,255)}Zo("DataDrivenProperty",yr),Zo("DataConstantProperty",qr),Zo("CrossFadedDataDrivenProperty",Pr),Zo("CrossFadedProperty",is),Zo("ColorRampProperty",us);const Hs={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Is{constructor(Js,Ks){this._structArray=Js,this._pos1=Ks*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Ls{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(Ms,Ns){return Ms._trim(),Ns&&(Ms.isTransferred=!0,Ns.push(Ms.arrayBuffer)),{length:Ms.length,arrayBuffer:Ms.arrayBuffer}}static deserialize(Os){const Ps=Object.create(this.prototype);return Ps.arrayBuffer=Os.arrayBuffer,Ps.length=Os.length,Ps.capacity=Os.arrayBuffer.byteLength/Ps.bytesPerElement,Ps._refreshViews(),Ps}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(Qs){this.reserve(Qs),this.length=Qs}reserve(Rs){if(Rs>this.capacity){this.capacity=Math.max(Rs,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const Ss=this.uint8;this._refreshViews(),Ss&&this.uint8.set(Ss)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Ts(a,b=1){let c=0,d=0;return{members:a.map(a=>{const e=Hs[a.type].BYTES_PER_ELEMENT,f=c=Us(c,Math.max(b,e)),g=a.components||1;return d=Math.max(d,e),c+=e*g,{name:a.name,type:a.type,components:g,offset:f}}),size:Us(c,Math.max(d,b)),alignment:b}}function Us(a,b){return Math.ceil(a/b)*b}class Vs extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(Ws,Xs){const Ys=this.length;return this.resize(Ys+1),this.emplace(Ys,Ws,Xs)}emplace(Zs,$s,_s){const at=2*Zs;return this.int16[at+0]=$s,this.int16[at+1]=_s,Zs}}Vs.prototype.bytesPerElement=4,Zo("StructArrayLayout2i4",Vs);class bt extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(ct,dt,et,ft){const gt=this.length;return this.resize(gt+1),this.emplace(gt,ct,dt,et,ft)}emplace(ht,it,jt,kt,lt){const mt=4*ht;return this.int16[mt+0]=it,this.int16[mt+1]=jt,this.int16[mt+2]=kt,this.int16[mt+3]=lt,ht}}bt.prototype.bytesPerElement=8,Zo("StructArrayLayout4i8",bt);class nt extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(ot,pt,qt,rt,st,tt,ut){const vt=this.length;return this.resize(vt+1),this.emplace(vt,ot,pt,qt,rt,st,tt,ut)}emplace(wt,xt,yt,zt,At,Bt,Ct,Dt){const Et=6*wt,Ft=12*wt,Gt=3*wt;return this.int16[Et+0]=xt,this.int16[Et+1]=yt,this.uint8[Ft+4]=zt,this.uint8[Ft+5]=At,this.uint8[Ft+6]=Bt,this.uint8[Ft+7]=Ct,this.float32[Gt+2]=Dt,wt}}nt.prototype.bytesPerElement=12,Zo("StructArrayLayout2i4ub1f12",nt);class Ht extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(It,Jt,Kt){const Lt=this.length;return this.resize(Lt+1),this.emplace(Lt,It,Jt,Kt)}emplace(Mt,Nt,Ot,Pt){const Qt=3*Mt;return this.float32[Qt+0]=Nt,this.float32[Qt+1]=Ot,this.float32[Qt+2]=Pt,Mt}}Ht.prototype.bytesPerElement=12,Zo("StructArrayLayout3f12",Ht);class Rt extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(St,Tt,Ut,Vt,Wt,Xt,Yt,Zt,$t,_t){const au=this.length;return this.resize(au+1),this.emplace(au,St,Tt,Ut,Vt,Wt,Xt,Yt,Zt,$t,_t)}emplace(bu,cu,du,eu,fu,gu,hu,iu,ju,ku,lu){const mu=10*bu;return this.uint16[mu+0]=cu,this.uint16[mu+1]=du,this.uint16[mu+2]=eu,this.uint16[mu+3]=fu,this.uint16[mu+4]=gu,this.uint16[mu+5]=hu,this.uint16[mu+6]=iu,this.uint16[mu+7]=ju,this.uint16[mu+8]=ku,this.uint16[mu+9]=lu,bu}}Rt.prototype.bytesPerElement=20,Zo("StructArrayLayout10ui20",Rt);class nu extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(ou,pu,qu,ru,su,tu,uu,vu){const wu=this.length;return this.resize(wu+1),this.emplace(wu,ou,pu,qu,ru,su,tu,uu,vu)}emplace(xu,yu,zu,Au,Bu,Cu,Du,Eu,Fu){const Gu=8*xu;return this.uint16[Gu+0]=yu,this.uint16[Gu+1]=zu,this.uint16[Gu+2]=Au,this.uint16[Gu+3]=Bu,this.uint16[Gu+4]=Cu,this.uint16[Gu+5]=Du,this.uint16[Gu+6]=Eu,this.uint16[Gu+7]=Fu,xu}}nu.prototype.bytesPerElement=16,Zo("StructArrayLayout8ui16",nu);class Hu extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(Iu,Ju,Ku,Lu,Mu,Nu,Ou,Pu,Qu,Ru,Su,Tu,Uu,Vu,Wu,Xu){const Yu=this.length;return this.resize(Yu+1),this.emplace(Yu,Iu,Ju,Ku,Lu,Mu,Nu,Ou,Pu,Qu,Ru,Su,Tu,Uu,Vu,Wu,Xu)}emplace(Zu,$u,_u,av,bv,cv,dv,ev,fv,gv,hv,iv,jv,kv,lv,mv,nv){const ov=16*Zu;return this.int16[ov+0]=$u,this.int16[ov+1]=_u,this.int16[ov+2]=av,this.int16[ov+3]=bv,this.uint16[ov+4]=cv,this.uint16[ov+5]=dv,this.uint16[ov+6]=ev,this.uint16[ov+7]=fv,this.int16[ov+8]=gv,this.int16[ov+9]=hv,this.int16[ov+10]=iv,this.int16[ov+11]=jv,this.int16[ov+12]=kv,this.int16[ov+13]=lv,this.int16[ov+14]=mv,this.int16[ov+15]=nv,Zu}}Hu.prototype.bytesPerElement=32,Zo("StructArrayLayout4i4ui4i4i32",Hu);class pv extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(qv){const rv=this.length;return this.resize(rv+1),this.emplace(rv,qv)}emplace(sv,tv){return this.uint32[1*sv+0]=tv,sv}}pv.prototype.bytesPerElement=4,Zo("StructArrayLayout1ul4",pv);class uv extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(vv,wv,xv,yv,zv,Av,Bv,Cv,Dv,Ev,Fv,Gv,Hv){const Iv=this.length;return this.resize(Iv+1),this.emplace(Iv,vv,wv,xv,yv,zv,Av,Bv,Cv,Dv,Ev,Fv,Gv,Hv)}emplace(Jv,Kv,Lv,Mv,Nv,Ov,Pv,Qv,Rv,Sv,Tv,Uv,Vv,Wv){const Xv=20*Jv,Yv=10*Jv;return this.int16[Xv+0]=Kv,this.int16[Xv+1]=Lv,this.int16[Xv+2]=Mv,this.int16[Xv+3]=Nv,this.int16[Xv+4]=Ov,this.float32[Yv+3]=Pv,this.float32[Yv+4]=Qv,this.float32[Yv+5]=Rv,this.float32[Yv+6]=Sv,this.int16[Xv+14]=Tv,this.uint32[Yv+8]=Uv,this.uint16[Xv+18]=Vv,this.uint16[Xv+19]=Wv,Jv}}uv.prototype.bytesPerElement=40,Zo("StructArrayLayout5i4f1i1ul2ui40",uv);class Zv extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack($v,_v,aw,bw,cw,dw,ew){const fw=this.length;return this.resize(fw+1),this.emplace(fw,$v,_v,aw,bw,cw,dw,ew)}emplace(gw,hw,iw,jw,kw,lw,mw,nw){const ow=8*gw;return this.int16[ow+0]=hw,this.int16[ow+1]=iw,this.int16[ow+2]=jw,this.int16[ow+4]=kw,this.int16[ow+5]=lw,this.int16[ow+6]=mw,this.int16[ow+7]=nw,gw}}Zv.prototype.bytesPerElement=16,Zo("StructArrayLayout3i2i2i16",Zv);class pw extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(qw,rw,sw,tw,uw){const vw=this.length;return this.resize(vw+1),this.emplace(vw,qw,rw,sw,tw,uw)}emplace(ww,xw,yw,zw,Aw,Bw){const Cw=4*ww,Dw=8*ww;return this.float32[Cw+0]=xw,this.float32[Cw+1]=yw,this.float32[Cw+2]=zw,this.int16[Dw+6]=Aw,this.int16[Dw+7]=Bw,ww}}pw.prototype.bytesPerElement=16,Zo("StructArrayLayout2f1f2i16",pw);class Ew extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(Fw,Gw,Hw,Iw){const Jw=this.length;return this.resize(Jw+1),this.emplace(Jw,Fw,Gw,Hw,Iw)}emplace(Kw,Lw,Mw,Nw,Ow){const Pw=12*Kw,Qw=3*Kw;return this.uint8[Pw+0]=Lw,this.uint8[Pw+1]=Mw,this.float32[Qw+1]=Nw,this.float32[Qw+2]=Ow,Kw}}Ew.prototype.bytesPerElement=12,Zo("StructArrayLayout2ub2f12",Ew);class Rw extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(Sw,Tw,Uw){const Vw=this.length;return this.resize(Vw+1),this.emplace(Vw,Sw,Tw,Uw)}emplace(Ww,Xw,Yw,Zw){const $w=3*Ww;return this.uint16[$w+0]=Xw,this.uint16[$w+1]=Yw,this.uint16[$w+2]=Zw,Ww}}Rw.prototype.bytesPerElement=6,Zo("StructArrayLayout3ui6",Rw);class _w extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(ax,bx,cx,dx,ex,fx,gx,hx,ix,jx,kx,lx,mx,nx,ox,px,qx,rx,sx,tx,ux){const vx=this.length;return this.resize(vx+1),this.emplace(vx,ax,bx,cx,dx,ex,fx,gx,hx,ix,jx,kx,lx,mx,nx,ox,px,qx,rx,sx,tx,ux)}emplace(wx,xx,yx,zx,Ax,Bx,Cx,Dx,Ex,Fx,Gx,Hx,Ix,Jx,Kx,Lx,Mx,Nx,Ox,Px,Qx,Rx){const Sx=30*wx,Tx=15*wx,Ux=60*wx;return this.int16[Sx+0]=xx,this.int16[Sx+1]=yx,this.int16[Sx+2]=zx,this.float32[Tx+2]=Ax,this.float32[Tx+3]=Bx,this.uint16[Sx+8]=Cx,this.uint16[Sx+9]=Dx,this.uint32[Tx+5]=Ex,this.uint32[Tx+6]=Fx,this.uint32[Tx+7]=Gx,this.uint16[Sx+16]=Hx,this.uint16[Sx+17]=Ix,this.uint16[Sx+18]=Jx,this.float32[Tx+10]=Kx,this.float32[Tx+11]=Lx,this.uint8[Ux+48]=Mx,this.uint8[Ux+49]=Nx,this.uint8[Ux+50]=Ox,this.uint32[Tx+13]=Px,this.int16[Sx+28]=Qx,this.uint8[Ux+58]=Rx,wx}}_w.prototype.bytesPerElement=60,Zo("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",_w);class Vx extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(Wx,Xx,Yx,Zx,$x,_x,ay,by,cy,dy,ey,fy,gy,hy,iy,jy,ky,ly,my,ny,oy,py,qy,ry,sy,ty,uy,vy,wy,xy){const yy=this.length;return this.resize(yy+1),this.emplace(yy,Wx,Xx,Yx,Zx,$x,_x,ay,by,cy,dy,ey,fy,gy,hy,iy,jy,ky,ly,my,ny,oy,py,qy,ry,sy,ty,uy,vy,wy,xy)}emplace(zy,Ay,By,Cy,Dy,Ey,Fy,Gy,Hy,Iy,Jy,Ky,Ly,My,Ny,Oy,Py,Qy,Ry,Sy,Ty,Uy,Vy,Wy,Xy,Yy,Zy,$y,_y,az,bz){const cz=38*zy,dz=19*zy;return this.int16[cz+0]=Ay,this.int16[cz+1]=By,this.int16[cz+2]=Cy,this.float32[dz+2]=Dy,this.float32[dz+3]=Ey,this.int16[cz+8]=Fy,this.int16[cz+9]=Gy,this.int16[cz+10]=Hy,this.int16[cz+11]=Iy,this.int16[cz+12]=Jy,this.int16[cz+13]=Ky,this.uint16[cz+14]=Ly,this.uint16[cz+15]=My,this.uint16[cz+16]=Ny,this.uint16[cz+17]=Oy,this.uint16[cz+18]=Py,this.uint16[cz+19]=Qy,this.uint16[cz+20]=Ry,this.uint16[cz+21]=Sy,this.uint16[cz+22]=Ty,this.uint16[cz+23]=Uy,this.uint16[cz+24]=Vy,this.uint16[cz+25]=Wy,this.uint16[cz+26]=Xy,this.uint16[cz+27]=Yy,this.uint16[cz+28]=Zy,this.uint32[dz+15]=$y,this.float32[dz+16]=_y,this.float32[dz+17]=az,this.float32[dz+18]=bz,zy}}Vx.prototype.bytesPerElement=76,Zo("StructArrayLayout3i2f6i15ui1ul3f76",Vx);class ez extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(fz){const gz=this.length;return this.resize(gz+1),this.emplace(gz,fz)}emplace(hz,iz){return this.float32[1*hz+0]=iz,hz}}ez.prototype.bytesPerElement=4,Zo("StructArrayLayout1f4",ez);class jz extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(kz,lz,mz){const nz=this.length;return this.resize(nz+1),this.emplace(nz,kz,lz,mz)}emplace(oz,pz,qz,rz){const sz=3*oz;return this.int16[sz+0]=pz,this.int16[sz+1]=qz,this.int16[sz+2]=rz,oz}}jz.prototype.bytesPerElement=6,Zo("StructArrayLayout3i6",jz);class tz extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(uz,vz,wz,xz,yz,zz,Az){const Bz=this.length;return this.resize(Bz+1),this.emplace(Bz,uz,vz,wz,xz,yz,zz,Az)}emplace(Cz,Dz,Ez,Fz,Gz,Hz,Iz,Jz){const Kz=7*Cz;return this.float32[Kz+0]=Dz,this.float32[Kz+1]=Ez,this.float32[Kz+2]=Fz,this.float32[Kz+3]=Gz,this.float32[Kz+4]=Hz,this.float32[Kz+5]=Iz,this.float32[Kz+6]=Jz,Cz}}tz.prototype.bytesPerElement=28,Zo("StructArrayLayout7f28",tz);class Lz extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(Mz,Nz,Oz,Pz){const Qz=this.length;return this.resize(Qz+1),this.emplace(Qz,Mz,Nz,Oz,Pz)}emplace(Rz,Sz,Tz,Uz,Vz){const Wz=6*Rz;return this.uint32[3*Rz+0]=Sz,this.uint16[Wz+2]=Tz,this.uint16[Wz+3]=Uz,this.uint16[Wz+4]=Vz,Rz}}Lz.prototype.bytesPerElement=12,Zo("StructArrayLayout1ul3ui12",Lz);class Xz extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(Yz,Zz){const $z=this.length;return this.resize($z+1),this.emplace($z,Yz,Zz)}emplace(_z,aA,bA){const cA=2*_z;return this.uint16[cA+0]=aA,this.uint16[cA+1]=bA,_z}}Xz.prototype.bytesPerElement=4,Zo("StructArrayLayout2ui4",Xz);class dA extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(eA){const fA=this.length;return this.resize(fA+1),this.emplace(fA,eA)}emplace(gA,hA){return this.uint16[1*gA+0]=hA,gA}}dA.prototype.bytesPerElement=2,Zo("StructArrayLayout1ui2",dA);class iA extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(jA,kA){const lA=this.length;return this.resize(lA+1),this.emplace(lA,jA,kA)}emplace(mA,nA,oA){const pA=2*mA;return this.float32[pA+0]=nA,this.float32[pA+1]=oA,mA}}iA.prototype.bytesPerElement=8,Zo("StructArrayLayout2f8",iA);class qA extends Ls{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(rA,sA,tA,uA){const vA=this.length;return this.resize(vA+1),this.emplace(vA,rA,sA,tA,uA)}emplace(wA,xA,yA,zA,AA){const BA=4*wA;return this.float32[BA+0]=xA,this.float32[BA+1]=yA,this.float32[BA+2]=zA,this.float32[BA+3]=AA,wA}}qA.prototype.bytesPerElement=16,Zo("StructArrayLayout4f16",qA);class CA extends Is{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}CA.prototype.size=40;class DA extends uv{get(EA){return new CA(this,EA)}}Zo("CollisionBoxArray",DA);class FA extends Is{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(GA){this._structArray.uint8[this._pos1+49]=GA}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(HA){this._structArray.uint8[this._pos1+50]=HA}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(IA){this._structArray.uint32[this._pos4+13]=IA}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(JA){this._structArray.uint8[this._pos1+58]=JA}}FA.prototype.size=60;class KA extends _w{get(LA){return new FA(this,LA)}}Zo("PlacedSymbolArray",KA);class MA extends Is{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(NA){this._structArray.uint32[this._pos4+15]=NA}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}MA.prototype.size=76;class OA extends Vx{get(PA){return new MA(this,PA)}}Zo("SymbolInstanceArray",OA);class QA extends ez{getoffsetX(RA){return this.float32[1*RA+0]}}Zo("GlyphOffsetArray",QA);class SA extends jz{getx(TA){return this.int16[3*TA+0]}gety(UA){return this.int16[3*UA+1]}gettileUnitDistanceFromAnchor(VA){return this.int16[3*VA+2]}}Zo("SymbolLineVertexArray",SA);class WA extends Is{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}WA.prototype.size=12;class XA extends Lz{get(YA){return new WA(this,YA)}}Zo("FeatureIndexArray",XA);class ZA extends Is{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}ZA.prototype.size=4;class $A extends Xz{get(_A){return new ZA(this,_A)}}Zo("FillExtrusionCentroidArray",$A);const aB=Ts([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),bB=Ts([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var cB=Zc(function(a){a.exports=function(a,b){var c,d,e,f,g,h,i,j;for(d=a.length-(c=3&a.length),e=b,g=3432918353,h=461845907,j=0;j>>16)*g&65535)<<16)&4294967295)<<15|i>>>17))*h+(((i>>>16)*h&65535)<<16)&4294967295)<<13|e>>>19))+((5*(e>>>16)&65535)<<16)&4294967295))+((58964+(f>>>16)&65535)<<16);switch(i=0,c){case 3:i^=(255&a.charCodeAt(j+2))<<16;case 2:i^=(255&a.charCodeAt(j+1))<<8;case 1:e^=i=(65535&(i=(i=(65535&(i^=255&a.charCodeAt(j)))*g+(((i>>>16)*g&65535)<<16)&4294967295)<<15|i>>>17))*h+(((i>>>16)*h&65535)<<16)&4294967295}return e^=a.length,e=2246822507*(65535&(e^=e>>>16))+((2246822507*(e>>>16)&65535)<<16)&4294967295,e=3266489909*(65535&(e^=e>>>13))+((3266489909*(e>>>16)&65535)<<16)&4294967295,(e^=e>>>16)>>>0}}),dB=Zc(function(a){a.exports=function(a,b){for(var c,d=a.length,e=b^d,f=0;d>=4;)c=1540483477*(65535&(c=255&a.charCodeAt(f)|(255&a.charCodeAt(++f))<<8|(255&a.charCodeAt(++f))<<16|(255&a.charCodeAt(++f))<<24))+((1540483477*(c>>>16)&65535)<<16),e=1540483477*(65535&e)+((1540483477*(e>>>16)&65535)<<16)^(c=1540483477*(65535&(c^=c>>>24))+((1540483477*(c>>>16)&65535)<<16)),d-=4,++f;switch(d){case 3:e^=(255&a.charCodeAt(f+2))<<16;case 2:e^=(255&a.charCodeAt(f+1))<<8;case 1:e=1540483477*(65535&(e^=255&a.charCodeAt(f)))+((1540483477*(e>>>16)&65535)<<16)}return e=1540483477*(65535&(e^=e>>>13))+((1540483477*(e>>>16)&65535)<<16),(e^=e>>>15)>>>0}}),eB=cB;eB.murmur3=cB,eB.murmur2=dB;class fB{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(gB,hB,iB,jB){this.ids.push(wB(gB)),this.positions.push(hB,iB,jB)}getPositions(kB){const lB=wB(kB);let mB=0,nB=this.ids.length-1;for(;mB>1;this.ids[oB]>=lB?nB=oB:mB=oB+1}const pB=[];for(;this.ids[mB]===lB;)pB.push({index:this.positions[3*mB],start:this.positions[3*mB+1],end:this.positions[3*mB+2]}),mB++;return pB}static serialize(qB,rB){const sB=new Float64Array(qB.ids),tB=new Uint32Array(qB.positions);return xB(sB,tB,0,sB.length-1),rB&&rB.push(sB.buffer,tB.buffer),{ids:sB,positions:tB}}static deserialize(uB){const vB=new fB;return vB.ids=uB.ids,vB.positions=uB.positions,vB.indexed=!0,vB}}function wB(a){const b=+a;return!isNaN(b)&&Number.MIN_SAFE_INTEGER<=b&&b<=Number.MAX_SAFE_INTEGER?b:eB(String(a))}function xB(a,b,c,d){for(;c>1];let f=c-1,g=d+1;for(;;){do f++;while(a[f]e)if(f>=g)break;yB(a,f,g),yB(b,3*f,3*g),yB(b,3*f+1,3*g+1),yB(b,3*f+2,3*g+2)}g-c`u_${a}`),this.type=VB}setUniform(WB,XB,YB){WB.set(YB.constantOr(this.value))}getBinding(ZB,$B,_B){return"color"===this.type?new KB(ZB,$B):new CB(ZB,$B)}}class aC{constructor(bC,cC){this.uniformNames=cC.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(dC,eC){this.pixelRatioFrom=eC.pixelRatio,this.pixelRatioTo=dC.pixelRatio,this.patternFrom=eC.tl.concat(eC.br),this.patternTo=dC.tl.concat(dC.br)}setUniform(fC,gC,hC,iC){const jC="u_pattern_to"===iC||"u_dash_to"===iC?this.patternTo:"u_pattern_from"===iC||"u_dash_from"===iC?this.patternFrom:"u_pixel_ratio_to"===iC?this.pixelRatioTo:"u_pixel_ratio_from"===iC?this.pixelRatioFrom:null;jC&&fC.set(jC)}getBinding(kC,lC,mC){return"u_pattern_from"===mC||"u_pattern_to"===mC||"u_dash_from"===mC||"u_dash_to"===mC?new GB(kC,lC):new CB(kC,lC)}}class nC{constructor(oC,pC,qC,rC){this.expression=oC,this.type=qC,this.maxValue=0,this.paintVertexAttributes=pC.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===qC?2:1,offset:0})),this.paintVertexArray=new rC}populatePaintArray(sC,tC,uC,vC,wC,xC){const yC=this.paintVertexArray.length,zC=this.expression.evaluate(new aq(0),tC,{},wC,vC,xC);this.paintVertexArray.resize(sC),this._setPaintValue(yC,sC,zC)}updatePaintArray(AC,BC,CC,DC,EC){const FC=this.expression.evaluate({zoom:0},CC,DC,void 0,EC);this._setPaintValue(AC,BC,FC)}_setPaintValue(GC,HC,IC){if("color"===this.type){const JC=RB(IC);for(let KC=GC;KC`u_${a}_t`),this.type=QC,this.useIntegerZoom=RC,this.zoom=SC,this.maxValue=0,this.paintVertexAttributes=PC.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===QC?4:2,offset:0})),this.paintVertexArray=new TC}populatePaintArray(UC,VC,WC,XC,YC,ZC){const $C=this.expression.evaluate(new aq(this.zoom),VC,{},YC,XC,ZC),_C=this.expression.evaluate(new aq(this.zoom+1),VC,{},YC,XC,ZC),aD=this.paintVertexArray.length;this.paintVertexArray.resize(UC),this._setPaintValue(aD,UC,$C,_C)}updatePaintArray(bD,cD,dD,eD,fD){const gD=this.expression.evaluate({zoom:this.zoom},dD,eD,void 0,fD),hD=this.expression.evaluate({zoom:this.zoom+1},dD,eD,void 0,fD);this._setPaintValue(bD,cD,gD,hD)}_setPaintValue(iD,jD,kD,lD){if("color"===this.type){const mD=RB(kD),nD=RB(lD);for(let oD=iD;oD!0){this.binders={},this._buffers=[];const jE=[];for(const kE in gE.paint._values){if(!iE(kE))continue;const lE=gE.paint.get(kE);if(!(lE instanceof er&&Em(lE.property.specification)))continue;const mE=_F(kE,gE.type),nE=lE.value,oE=lE.property.specification.type,pE=lE.property.useIntegerZoom,qE=lE.property.specification["property-type"],rE="cross-faded"===qE||"cross-faded-data-driven"===qE,sE="line-dasharray"===String(kE)&&"constant"!==gE.layout.get("line-cap").value.kind;if("constant"!==nE.kind||sE)if("source"===nE.kind||sE||rE){const tE=cG(kE,oE,"source");this.binders[kE]=rE?new yD(nE,mE,oE,pE,hE,tE,gE.id):new nC(nE,mE,oE,tE),jE.push(`/a_${kE}`)}else{const uE=cG(kE,oE,"composite");this.binders[kE]=new NC(nE,mE,oE,pE,hE,uE),jE.push(`/z_${kE}`)}else this.binders[kE]=rE?new aC(nE.value,mE):new SB(nE.value,mE,oE),jE.push(`/u_${kE}`)}this.cacheKey=jE.sort().join("")}getMaxValue(vE){const wE=this.binders[vE];return wE instanceof nC||wE instanceof NC?wE.maxValue:0}populatePaintArrays(xE,yE,zE,AE,BE,CE){for(const DE in this.binders){const EE=this.binders[DE];(EE instanceof nC||EE instanceof NC||EE instanceof yD)&&EE.populatePaintArray(xE,yE,zE,AE,BE,CE)}}setConstantPatternPositions(FE,GE){for(const HE in this.binders){const IE=this.binders[HE];IE instanceof aC&&IE.setConstantPatternPositions(FE,GE)}}updatePaintArrays(JE,KE,LE,ME,NE,OE){let PE=!1;for(const QE in JE){const RE=KE.getPositions(QE);for(const SE of RE){const TE=LE.feature(SE.index);for(const UE in this.binders){const VE=this.binders[UE];if((VE instanceof nC||VE instanceof NC||VE instanceof yD)&& !0===VE.expression.isStateDependent){const WE=ME.paint.get(UE);VE.expression=WE.value,VE.updatePaintArray(SE.start,SE.end,TE,JE[QE],NE,OE),PE=!0}}}}return PE}defines(){const XE=[];for(const YE in this.binders){const ZE=this.binders[YE];(ZE instanceof SB||ZE instanceof aC)&&XE.push(...ZE.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return XE}getBinderAttributes(){const $E=[];for(const _E in this.binders){const aF=this.binders[_E];if(aF instanceof nC||aF instanceof NC||aF instanceof yD)for(let bF=0;bF!0){for(const HF of(this.programConfigurations={},EF))this.programConfigurations[HF.id]=new fE(HF,FF,GF);this.needsUpload=!1,this._featureMap=new fB,this._bufferOffset=0}populatePaintArrays(IF,JF,KF,LF,MF,NF,OF){for(const PF in this.programConfigurations)this.programConfigurations[PF].populatePaintArrays(IF,JF,LF,MF,NF,OF);void 0!==JF.id&&this._featureMap.add(JF.id,KF,this._bufferOffset,IF),this._bufferOffset=IF,this.needsUpload=!0}updatePaintArrays(QF,RF,SF,TF,UF){for(const VF of SF)this.needsUpload=this.programConfigurations[VF.id].updatePaintArrays(QF,this._featureMap,RF,VF,TF,UF)||this.needsUpload}get(WF){return this.programConfigurations[WF]}upload(XF){if(this.needsUpload){for(const YF in this.programConfigurations)this.programConfigurations[YF].upload(XF);this.needsUpload=!1}}destroy(){for(const ZF in this.programConfigurations)this.programConfigurations[ZF].destroy()}}const $F={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function _F(a,b){return $F[a]||[a.replace(`${b}-`,"").replace(/-/g,"_")]}const aG={"line-pattern":{source:Rt,composite:Rt},"fill-pattern":{source:Rt,composite:Rt},"fill-extrusion-pattern":{source:Rt,composite:Rt},"line-dasharray":{source:nu,composite:nu}},bG={color:{source:iA,composite:qA},number:{source:ez,composite:iA}};function cG(a,b,c){const d=aG[a];return d&&d[c]||bG[b][c]}Zo("ConstantBinder",SB),Zo("CrossFadedConstantBinder",aC),Zo("SourceExpressionBinder",nC),Zo("CrossFadedCompositeBinder",yD),Zo("CompositeExpressionBinder",NC),Zo("ProgramConfiguration",fE,{omit:["_buffers"]}),Zo("ProgramConfigurationSet",DF);const dG="-transition";class eG extends Yb{constructor(fG,gG){if(super(),this.id=fG.id,this.type=fG.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==fG.type&&(this.metadata=(fG=fG).metadata,this.minzoom=fG.minzoom,this.maxzoom=fG.maxzoom,"background"!==fG.type&&"sky"!==fG.type&&(this.source=fG.source,this.sourceLayer=fG["source-layer"],this.filter=fG.filter),gG.layout&&(this._unevaluatedLayout=new class{constructor(a){this._properties=a,this._values=Object.create(a.defaultPropertyValues)}getValue(b){return ja(this._values[b].value)}setValue(c,d){this._values[c]=new hq(this._values[c].property,null===d?void 0:ja(d))}serialize(){const e={};for(const f of Object.keys(this._values)){const g=this.getValue(f);void 0!==g&&(e[f]=g)}return e}possiblyEvaluate(h,i,j){const k=new nr(this._properties);for(const l of Object.keys(this._values))k._values[l]=this._values[l].possiblyEvaluate(h,i,j);return k}}(gG.layout)),gG.paint)){for(const hG in this._transitionablePaint=new rq(gG.paint),fG.paint)this.setPaintProperty(hG,fG.paint[hG],{validate:!1});for(const iG in fG.layout)this.setLayoutProperty(iG,fG.layout[iG],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nr(gG.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(jG){return"visibility"===jG?this.visibility:this._unevaluatedLayout.getValue(jG)}setLayoutProperty(kG,lG,mG={}){null!=lG&&this._validate(So,`layers.${this.id}.layout.${kG}`,kG,lG,mG)||("visibility"!==kG?this._unevaluatedLayout.setValue(kG,lG):this.visibility=lG)}getPaintProperty(nG){return ga(nG,dG)?this._transitionablePaint.getTransition(nG.slice(0,-dG.length)):this._transitionablePaint.getValue(nG)}setPaintProperty(oG,pG,qG={}){if(null!=pG&&this._validate(Ro,`layers.${this.id}.paint.${oG}`,oG,pG,qG))return!1;if(ga(oG,dG))return this._transitionablePaint.setTransition(oG.slice(0,-dG.length),pG||void 0),!1;{const rG=this._transitionablePaint._values[oG],sG="cross-faded-data-driven"===rG.property.specification["property-type"],tG=rG.value.isDataDriven(),uG=rG.value;this._transitionablePaint.setValue(oG,pG),this._handleSpecialPaintPropertyUpdate(oG);const vG=this._transitionablePaint._values[oG].value;return vG.isDataDriven()||tG||sG||this._handleOverridablePaintPropertyUpdate(oG,uG,vG)}}_handleSpecialPaintPropertyUpdate(wG){}getProgramIds(){return null}getProgramConfiguration(xG){return null}_handleOverridablePaintPropertyUpdate(yG,zG,AG){return!1}isHidden(BG){return!!(this.minzoom&&BG=this.maxzoom)||"none"===this.visibility}updateTransitions(CG){this._transitioningPaint=this._transitionablePaint.transitioned(CG,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(DG,EG){DG.getCrossfadeParameters&&(this._crossfadeParameters=DG.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(DG,void 0,EG)),this.paint=this._transitioningPaint.possiblyEvaluate(DG,void 0,EG)}serialize(){const FG={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(FG.layout=FG.layout||{},FG.layout.visibility=this.visibility),ia(FG,(a,b)=>!(void 0===a||"layout"===b&&!Object.keys(a).length||"paint"===b&&!Object.keys(a).length))}_validate(GG,HG,IG,JG,KG={}){return(!KG|| !1!==KG.validate)&&To(this,GG.call(Oo,{key:HG,layerType:this.type,objectKey:IG,value:JG,styleSpec:oc,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const LG in this.paint._values){const MG=this.paint.get(LG);if(MG instanceof er&&Em(MG.property.specification)&&("source"===MG.value.kind||"composite"===MG.value.kind)&&MG.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=ko(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const NG=Ts([{name:"a_pos",components:2,type:"Int16"}],4),{members:OG}=NG;class PG{constructor(QG=[]){this.segments=QG}prepareSegment(RG,SG,TG,UG){let VG=this.segments[this.segments.length-1];return RG>PG.MAX_VERTEX_ARRAY_LENGTH&&la(`Max vertices per segment is ${PG.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${RG}`),(!VG||VG.vertexLength+RG>PG.MAX_VERTEX_ARRAY_LENGTH||VG.sortKey!==UG)&&(VG={vertexOffset:SG.length,primitiveOffset:TG.length,vertexLength:0,primitiveLength:0},void 0!==UG&&(VG.sortKey=UG),this.segments.push(VG)),VG}get(){return this.segments}destroy(){for(const WG of this.segments)for(const XG in WG.vaos)WG.vaos[XG].destroy()}static simpleSegment(YG,ZG,$G,_G){return new PG([{vertexOffset:YG,primitiveOffset:ZG,vertexLength:$G,primitiveLength:_G,vaos:{},sortKey:0}])}}PG.MAX_VERTEX_ARRAY_LENGTH=65535,Zo("SegmentVector",PG);class aH{constructor(bH,cH){bH&&(cH?this.setSouthWest(bH).setNorthEast(cH):4===bH.length?this.setSouthWest([bH[0],bH[1]]).setNorthEast([bH[2],bH[3]]):this.setSouthWest(bH[0]).setNorthEast(bH[1]))}setNorthEast(dH){return this._ne=dH instanceof pH?new pH(dH.lng,dH.lat):pH.convert(dH),this}setSouthWest(eH){return this._sw=eH instanceof pH?new pH(eH.lng,eH.lat):pH.convert(eH),this}extend(fH){const gH=this._sw,hH=this._ne;let iH,jH;if(fH instanceof pH)iH=fH,jH=fH;else{if(!(fH instanceof aH))return Array.isArray(fH)?4===fH.length||fH.every(Array.isArray)?this.extend(aH.convert(fH)):this.extend(pH.convert(fH)):this;if(iH=fH._sw,jH=fH._ne,!iH||!jH)return this}return gH||hH?(gH.lng=Math.min(iH.lng,gH.lng),gH.lat=Math.min(iH.lat,gH.lat),hH.lng=Math.max(jH.lng,hH.lng),hH.lat=Math.max(jH.lat,hH.lat)):(this._sw=new pH(iH.lng,iH.lat),this._ne=new pH(jH.lng,jH.lat)),this}getCenter(){return new pH((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new pH(this.getWest(),this.getNorth())}getSouthEast(){return new pH(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(kH){const{lng:lH,lat:mH}=pH.convert(kH);let nH=this._sw.lng<=lH&&lH<=this._ne.lng;return this._sw.lng>this._ne.lng&&(nH=this._sw.lng>=lH&&lH>=this._ne.lng),this._sw.lat<=mH&&mH<=this._ne.lat&&nH}static convert(oH){return!oH||oH instanceof aH?oH:new aH(oH)}}class pH{constructor(qH,rH){if(isNaN(qH)||isNaN(rH))throw new Error(`Invalid LngLat object: (${qH}, ${rH})`);if(this.lng=+qH,this.lat=+rH,this.lat>90||this.lat< -90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new pH(Y(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(sH){const tH=Math.PI/180,uH=this.lat*tH,vH=sH.lat*tH,wH=Math.sin(uH)*Math.sin(vH)+Math.cos(uH)*Math.cos(vH)*Math.cos((sH.lng-this.lng)*tH);return 6371008.8*Math.acos(Math.min(wH,1))}toBounds(xH=0){const yH=360*xH/40075017,zH=yH/Math.cos(Math.PI/180*this.lat);return new aH(new pH(this.lng-zH,this.lat-yH),new pH(this.lng+zH,this.lat+yH))}static convert(AH){if(AH instanceof pH)return AH;if(Array.isArray(AH)&&(2===AH.length||3===AH.length))return new pH(Number(AH[0]),Number(AH[1]));if(!Array.isArray(AH)&&"object"==typeof AH&&null!==AH)return new pH(Number("lng"in AH?AH.lng:AH.lon),Number(AH.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const BH=2*Math.PI*6371008.8;function CH(a){return BH*Math.cos(a*Math.PI/180)}function DH(a){return(180+a)/360}function EH(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function FH(a,b){return a/CH(b)}function GH(a){return 360*a-180}function HH(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function IH(a,b){return a*CH(HH(b))}class JH{constructor(KH,LH,MH=0){this.x=+KH,this.y=+LH,this.z=+MH}static fromLngLat(NH,OH=0){const PH=pH.convert(NH);return new JH(DH(PH.lng),EH(PH.lat),FH(OH,PH.lat))}toLngLat(){return new pH(GH(this.x),HH(this.y))}toAltitude(){return IH(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/BH*(1/Math.cos(HH(this.y)*Math.PI/180))}}function QH(a,b,c,d,e,f,h,i,j){const k=(b+d)/2,l=(c+e)/2,m=new g(k,l);i(m),(function(a,b,c,d,e,f){const g=c-e,h=d-f;return Math.abs((d-b)*g-(c-a)*h)/Math.hypot(g,h)})(m.x,m.y,f.x,f.y,h.x,h.y)>=j?(QH(a,b,c,k,l,f,m,i,j),QH(a,k,l,d,e,m,h,i,j)):a.push(h)}function RH(a,b,c){const d=[];let e,f,g;for(const h of a){const{x:i,y:j}=h;b(h),g?QH(d,e,f,i,j,g,h,b,c):d.push(h),e=i,f=j,g=h}return d}function SH(a,b){const c=Math.round(a.x*b),d=Math.round(a.y*b);return a.x=W(c,-16384,16383),a.y=W(d,-16384,16383),(ca.x+1||da.y+1)&&la("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function TH(a,b,c){const d=a.loadGeometry(),e=a.extent,f=8192/e;if(b&&c&&c.projection.isReprojectedInTileSpace){const g=1<{const c=GH((b.x+a.x/e)/g),d=HH((b.y+a.y/e)/g),f=k.project(c,d);a.x=(f.x*h-i)*e,a.y=(f.y*h-j)*e};for(let m=0;m=e||o.y<0||o.y>=e||(l(o),n.push(o));d[m]=n}}for(const p of d)for(const q of p)SH(q,f);return d}function UH(a,b){return{type:a.type,id:a.id,properties:a.properties,geometry:b?TH(a):[]}}function VH(a,b,c,d,e){a.emplaceBack(2*b+(d+1)/2,2*c+(e+1)/2)}class WH{constructor(XH){this.zoom=XH.zoom,this.overscaling=XH.overscaling,this.layers=XH.layers,this.layerIds=this.layers.map(a=>a.id),this.index=XH.index,this.hasPattern=!1,this.layoutVertexArray=new Vs,this.indexArray=new Rw,this.segments=new PG,this.programConfigurations=new DF(XH.layers,XH.zoom),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(YH,ZH,$H,_H){const aI=this.layers[0],bI=[];let cI=null;for(const{feature:dI,id:eI,index:fI,sourceLayerIndex:gI}of("circle"===aI.type&&(cI=aI.layout.get("circle-sort-key")),YH)){const hI=this.layers[0]._featureFilter.needGeometry,iI=UH(dI,hI);if(!this.layers[0]._featureFilter.filter(new aq(this.zoom),iI,$H))continue;const jI=cI?cI.evaluate(iI,{},$H):void 0,kI={id:eI,properties:dI.properties,type:dI.type,sourceLayerIndex:gI,index:fI,geometry:hI?iI.geometry:TH(dI,$H,_H),patterns:{},sortKey:jI};bI.push(kI)}for(const lI of(cI&&bI.sort((a,b)=>a.sortKey-b.sortKey),bI)){const{geometry:mI,index:nI,sourceLayerIndex:oI}=lI,pI=YH[nI].feature;this.addFeature(lI,mI,nI,ZH.availableImages,$H),ZH.featureIndex.insert(pI,mI,nI,oI,this.index)}}update(qI,rI,sI,tI){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(qI,rI,this.stateDependentLayers,sI,tI)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(uI){this.uploaded||(this.layoutVertexBuffer=uI.createVertexBuffer(this.layoutVertexArray,OG),this.indexBuffer=uI.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(uI),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(vI,wI,xI,yI,zI){for(const AI of wI)for(const BI of AI){const CI=BI.x,DI=BI.y;if(CI<0||CI>=8192||DI<0||DI>=8192)continue;const EI=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,vI.sortKey),FI=EI.vertexLength;VH(this.layoutVertexArray,CI,DI,-1,-1),VH(this.layoutVertexArray,CI,DI,1,-1),VH(this.layoutVertexArray,CI,DI,1,1),VH(this.layoutVertexArray,CI,DI,-1,1),this.indexArray.emplaceBack(FI,FI+1,FI+2),this.indexArray.emplaceBack(FI,FI+3,FI+2),EI.vertexLength+=4,EI.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,vI,xI,{},yI,zI)}}function GI(a,b){for(let c=0;c1){if(KI(a,b))return!0;for(let d=0;d1?c:c.sub(b)._mult(e)._add(b))}function OI(a,b){let c,d,e,f=!1;for(let g=0;gb.y!=e.y>b.y&&b.x<(e.x-d.x)*(b.y-d.y)/(e.y-d.y)+d.x&&(f=!f)}return f}function PI(a,b){let c=!1;for(let d=0,e=a.length-1;db.y!=g.y>b.y&&b.x<(g.x-f.x)*(b.y-f.y)/(g.y-f.y)+f.x&&(c=!c)}return c}function QI(a,b,c,d,e){for(const f of a)if(b<=f.x&&c<=f.y&&d>=f.x&&e>=f.y)return!0;const h=[new g(b,c),new g(b,e),new g(d,e),new g(d,c)];if(a.length>2){for(const i of h)if(PI(a,i))return!0}for(let j=0;je.x&&b.x>e.x||a.ye.y&&b.y>e.y)return!1;const f=ma(a,b,c[0]);return f!==ma(a,b,c[1])||f!==ma(a,b,c[2])||f!==ma(a,b,c[3])}function SI(a,b,c){const d=b.paint.get(a).value;return"constant"===d.kind?d.value:c.programConfigurations.get(b.id).getMaxValue(a)}function TI(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function UI(a,b,c,d,e){if(!b[0]&&!b[1])return a;const f=g.convert(b)._mult(e);"viewport"===c&&f._rotate(-d);const h=[];for(let i=0;i{var b,c,d;const e=J([],a,_I),f=1/e[3]/aJ*dJ;return b=e,c=e,d=[f,f,cJ?1/e[3]:f,f],b[0]=c[0]*d[0],b[1]=c[1]*d[1],b[2]=c[2]*d[2],b[3]=c[3]*d[3],b}),fJ=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(a=>{const b=C([],E([],I([],eJ[a[0]],eJ[a[1]]),I([],eJ[a[2]],eJ[a[1]]))),c=-D(b,eJ[a[1]]);return b.concat(c)});return new YI(eJ,fJ)}}class gJ{constructor(hJ,iJ){this.min=hJ,this.max=iJ,this.center=A([],w([],this.min,this.max),.5)}quadrant(jJ){const kJ=[jJ%2==0,jJ<2],lJ=t(this.min),mJ=t(this.max);for(let nJ=0;nJ=0;if(0===yJ)return 0;yJ!==uJ.length&&(vJ=!1)}if(vJ)return 2;for(let AJ=0;AJ<3;AJ++){let BJ=Number.MAX_VALUE,CJ=-Number.MAX_VALUE;for(let DJ=0;DJthis.max[AJ]-this.min[AJ])return 0}return 1}}function FJ(a,b,c,d,e,f,g,h,i){if(f&&a.queryGeometry.isAboveHorizon)return!1;for(const j of(f&&(i*=a.pixelToTileUnitsFactor),b))for(const k of j){const l=k.add(h),m=e&&c.elevation?c.elevation.exaggeration()*e.getElevationAt(l.x,l.y,!0):0,n=f?l:GJ(l,m,d),o=f?a.tilespaceRays.map(a=>JJ(a,m)):a.queryGeometry.screenGeometry,p=J([],[k.x,k.y,m,1],d);if(!g&&f?i*=p[3]/c.cameraToCenterDistance:g&&!f&&(i*=c.cameraToCenterDistance/p[3]),HI(o,n,i))return!0}return!1}function GJ(a,b,c){const d=J([],[a.x,a.y,b,1],c);return new g(d[0]/d[3],d[1]/d[3])}const HJ=v(0,0,0),IJ=v(0,0,1);function JJ(a,b){const c=s();return HJ[2]=b,a.intersectsPlane(HJ,IJ,c),new g(c[0],c[1])}class KJ extends WH{}function LJ(a,{width:b,height:c},d,e){if(e){if(e instanceof Uint8ClampedArray)e=new Uint8Array(e.buffer);else if(e.length!==b*c*d)throw new RangeError("mismatched image size")}else e=new Uint8Array(b*c*d);return a.width=b,a.height=c,a.data=e,a}function MJ(a,{width:b,height:c},d){if(b===a.width&&c===a.height)return;const e=LJ({},{width:b,height:c},d);NJ(a,e,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,b),height:Math.min(a.height,c)},d),a.width=b,a.height=c,a.data=e.data}function NJ(a,b,c,d,e,f){if(0===e.width||0===e.height)return b;if(e.width>a.width||e.height>a.height||c.x>a.width-e.width||c.y>a.height-e.height)throw new RangeError("out of range source coordinates for image copy");if(e.width>b.width||e.height>b.height||d.x>b.width-e.width||d.y>b.height-e.height)throw new RangeError("out of range destination coordinates for image copy");const g=a.data,h=b.data;for(let i=0;i{b[a.evaluationKey]=f;const g=a.expression.evaluate(b);e.data[c+d+0]=Math.floor(255*g.r/g.a),e.data[c+d+1]=Math.floor(255*g.g/g.a),e.data[c+d+2]=Math.floor(255*g.b/g.a),e.data[c+d+3]=Math.floor(255*g.a)};if(a.clips)for(let g=0,h=0;g80*c){d=f=a[0],e=g=a[1];for(var o=c;of&&(f=h),i>g&&(g=i);j=0!==(j=Math.max(f-d,g-e))?1/j:0}return pK(m,n,c,d,e,j),n}function nK(a,b,c,d,e){var f,g;if(e===LK(a,b,c,d)>0)for(f=b;f=b;f-=d)g=IK(f,a[f],a[f+1],g);return g&&CK(g,g.next)&&(JK(g),g=g.next),g}function oK(a,b){if(!a)return a;b||(b=a);var c,d=a;do if(c=!1,d.steiner|| !CK(d,d.next)&&0!==BK(d.prev,d,d.next))d=d.next;else{if(JK(d),(d=b=d.prev)===d.next)break;c=!0}while(c||d!==b)return b}function pK(a,b,c,d,e,f,g){if(a){!g&&f&&(function(a,b,c,d){var e=a;do null===e.z&&(e.z=xK(e.x,e.y,b,c,d)),e.prevZ=e.prev,e.nextZ=e.next,e=e.next;while(e!==a)e.prevZ.nextZ=null,e.prevZ=null,(function(a){var b,c,d,e,f,g,h,i,j=1;do{for(c=a,a=null,f=null,g=0;c;){for(g++,d=c,h=0,b=0;b0||i>0&&d;)0!==h&&(0===i||!d||c.z<=d.z)?(e=c,c=c.nextZ,h--):(e=d,d=d.nextZ,i--),f?f.nextZ=e:a=e,e.prevZ=f,f=e;c=d}f.nextZ=null,j*=2}while(g>1)})(e)})(a,d,e,f);for(var h,i,j=a;a.prev!==a.next;)if(h=a.prev,i=a.next,f?rK(a,d,e,f):qK(a))b.push(h.i/c),b.push(a.i/c),b.push(i.i/c),JK(a),a=i.next,j=i.next;else if((a=i)===j){g?1===g?pK(a=sK(oK(a),b,c),b,c,d,e,f,2):2===g&&tK(a,b,c,d,e,f):pK(oK(a),b,c,d,e,f,1);break}}}function qK(a){var b=a.prev,c=a,d=a.next;if(BK(b,c,d)>=0)return!1;for(var e=a.next.next;e!==a.prev;){if(zK(b.x,b.y,c.x,c.y,d.x,d.y,e.x,e.y)&&BK(e.prev,e,e.next)>=0)return!1;e=e.next}return!0}function rK(a,b,c,d){var e=a.prev,f=a,g=a.next;if(BK(e,f,g)>=0)return!1;for(var h=e.x>f.x?e.x>g.x?e.x:g.x:f.x>g.x?f.x:g.x,i=e.y>f.y?e.y>g.y?e.y:g.y:f.y>g.y?f.y:g.y,j=xK(e.x=j&&m&&m.z<=k;){if(l!==a.prev&&l!==a.next&&zK(e.x,e.y,f.x,f.y,g.x,g.y,l.x,l.y)&&BK(l.prev,l,l.next)>=0)return!1;if(l=l.prevZ,m!==a.prev&&m!==a.next&&zK(e.x,e.y,f.x,f.y,g.x,g.y,m.x,m.y)&&BK(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;l&&l.z>=j;){if(l!==a.prev&&l!==a.next&&zK(e.x,e.y,f.x,f.y,g.x,g.y,l.x,l.y)&&BK(l.prev,l,l.next)>=0)return!1;l=l.prevZ}for(;m&&m.z<=k;){if(m!==a.prev&&m!==a.next&&zK(e.x,e.y,f.x,f.y,g.x,g.y,m.x,m.y)&&BK(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function sK(a,b,c){var d=a;do{var e=d.prev,f=d.next.next;!CK(e,f)&&DK(e,d,d.next,f)&&GK(e,f)&&GK(f,e)&&(b.push(e.i/c),b.push(d.i/c),b.push(f.i/c),JK(d),JK(d.next),d=a=f),d=d.next}while(d!==a)return oK(d)}function tK(a,b,c,d,e,f){var g=a;do{for(var h=g.next.next;h!==g.prev;){if(g.i!==h.i&&AK(g,h)){var i=HK(g,h);return g=oK(g,g.next),i=oK(i,i.next),pK(g,b,c,d,e,f),void pK(i,b,c,d,e,f)}h=h.next}g=g.next}while(g!==a)}function uK(a,b){return a.x-b.x}function vK(a,b){var c=function(a,b){var c,d=b,e=a.x,f=a.y,g=-1/0;do{if(f<=d.y&&f>=d.next.y&&d.next.y!==d.y){var h=d.x+(f-d.y)*(d.next.x-d.x)/(d.next.y-d.y);if(h<=e&&h>g){if(g=h,h===e){if(f===d.y)return d;if(f===d.next.y)return d.next}c=d.x=d.x&&d.x>=k&&e!==d.x&&zK(fc.x||d.x===c.x&&wK(c,d)))&&(c=d,m=i)),d=d.next;while(d!==j)return c}(a,b);if(!c)return b;var d=HK(c,a),e=oK(c,c.next);return oK(d,d.next),b===c?e:b}function wK(a,b){return 0>BK(a.prev,a,b.prev)&&0>BK(b.next,a,a.next)}function xK(a,b,c,d,e){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-c)*e)|a<<8))|a<<4))|a<<2))|a<<1))|(b=1431655765&((b=858993459&((b=252645135&((b=16711935&((b=32767*(b-d)*e)|b<<8))|b<<4))|b<<2))|b<<1))<<1}function yK(a){var b=a,c=a;do(b.x=0&&(a-g)*(d-h)-(c-g)*(b-h)>=0&&(c-g)*(f-h)-(e-g)*(d-h)>=0}function AK(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(a,b){var c=a;do{if(c.i!==a.i&&c.next.i!==a.i&&c.i!==b.i&&c.next.i!==b.i&&DK(c,c.next,a,b))return!0;c=c.next}while(c!==a)return!1}(a,b)&&(GK(a,b)&&GK(b,a)&&(function(a,b){var c=a,d=!1,e=(a.x+b.x)/2,f=(a.y+b.y)/2;do c.y>f!=c.next.y>f&&c.next.y!==c.y&&e<(c.next.x-c.x)*(f-c.y)/(c.next.y-c.y)+c.x&&(d=!d),c=c.next;while(c!==a)return d})(a,b)&&(BK(a.prev,a,b.prev)||BK(a,b.prev,b))||CK(a,b)&&BK(a.prev,a,a.next)>0&&BK(b.prev,b,b.next)>0)}function BK(a,b,c){return(b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y)}function CK(a,b){return a.x===b.x&&a.y===b.y}function DK(a,b,c,d){var e=FK(BK(a,b,c)),f=FK(BK(a,b,d)),g=FK(BK(c,d,a)),h=FK(BK(c,d,b));return e!==f&&g!==h||!(0!==e||!EK(a,c,b))||!(0!==f||!EK(a,d,b))||!(0!==g||!EK(c,a,d))||!(0!==h||!EK(c,b,d))}function EK(a,b,c){return b.x<=Math.max(a.x,c.x)&&b.x>=Math.min(a.x,c.x)&&b.y<=Math.max(a.y,c.y)&&b.y>=Math.min(a.y,c.y)}function FK(a){return a>0?1:a<0?-1:0}function GK(a,b){return 0>BK(a.prev,a,a.next)?BK(a,b,a.next)>=0&&BK(a,a.prev,b)>=0:0>BK(a,b,a.prev)||0>BK(a,a.next,b)}function HK(a,b){var c=new KK(a.i,a.x,a.y),d=new KK(b.i,b.x,b.y),e=a.next,f=b.prev;return a.next=b,b.prev=a,c.next=e,e.prev=c,d.next=c,c.prev=d,f.next=d,d.prev=f,d}function IK(a,b,c,d){var e=new KK(a,b,c);return d?(e.next=d.next,e.prev=d,d.next.prev=e,d.next=e):(e.prev=e,e.next=e),e}function JK(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function KK(a,b,c){this.i=a,this.x=b,this.y=c,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function LK(a,b,c,d){for(var e=0,f=b,g=c-d;fc;){if(d-c>600){var f=d-c+1,g=b-c+1,h=Math.log(f),i=.5*Math.exp(2*h/3),j=.5*Math.sqrt(h*i*(f-i)/f)*(g-f/2<0?-1:1);NK(a,b,Math.max(c,Math.floor(b-g*i/f+j)),Math.min(d,Math.floor(b+(f-g)*i/f+j)),e)}var k=a[b],l=c,m=d;for(OK(a,c,b),e(a[d],k)>0&&OK(a,c,d);le(a[l],k);)l++;for(;e(a[m],k)>0;)m--}0===e(a[c],k)?OK(a,c,m):OK(a,++m,d),m<=b&&(c=m+1),b<=m&&(d=m-1)}}function OK(a,b,c){var d=a[b];a[b]=a[c],a[c]=d}function PK(a,b){return ab?1:0}function QK(a,b){const c=a.length;if(c<=1)return[a];const d=[];let e,f;for(let g=0;g1)for(let i=0;i0&&c.holes.push(d+=a[e-1].length)}return c},lK.default=mK;class UK{constructor(VK){this.zoom=VK.zoom,this.overscaling=VK.overscaling,this.layers=VK.layers,this.layerIds=this.layers.map(a=>a.id),this.index=VK.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Vs,this.indexArray=new Rw,this.indexArray2=new Xz,this.programConfigurations=new DF(VK.layers,VK.zoom),this.segments=new PG,this.segments2=new PG,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(WK,XK,YK,ZK){this.hasPattern=SK("fill",this.layers,XK);const $K=this.layers[0].layout.get("fill-sort-key"),_K=[];for(const{feature:aL,id:bL,index:cL,sourceLayerIndex:dL}of WK){const eL=this.layers[0]._featureFilter.needGeometry,fL=UH(aL,eL);if(!this.layers[0]._featureFilter.filter(new aq(this.zoom),fL,YK))continue;const gL=$K?$K.evaluate(fL,{},YK,XK.availableImages):void 0,hL={id:bL,properties:aL.properties,type:aL.type,sourceLayerIndex:dL,index:cL,geometry:eL?fL.geometry:TH(aL,YK,ZK),patterns:{},sortKey:gL};_K.push(hL)}for(const iL of($K&&_K.sort((a,b)=>a.sortKey-b.sortKey),_K)){const{geometry:jL,index:kL,sourceLayerIndex:lL}=iL;if(this.hasPattern){const mL=TK("fill",this.layers,iL,this.zoom,XK);this.patternFeatures.push(mL)}else this.addFeature(iL,jL,kL,YK,{},XK.availableImages);XK.featureIndex.insert(WK[kL].feature,jL,kL,lL,this.index)}}update(nL,oL,pL,qL){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(nL,oL,this.stateDependentLayers,pL,qL)}addFeatures(rL,sL,tL,uL){for(const vL of this.patternFeatures)this.addFeature(vL,vL.geometry,vL.index,sL,tL,uL)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(wL){this.uploaded||(this.layoutVertexBuffer=wL.createVertexBuffer(this.layoutVertexArray,kK),this.indexBuffer=wL.createIndexBuffer(this.indexArray),this.indexBuffer2=wL.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(wL),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(xL,yL,zL,AL,BL,CL=[]){for(const DL of QK(yL,500)){let EL=0;for(const FL of DL)EL+=FL.length;const GL=this.segments.prepareSegment(EL,this.layoutVertexArray,this.indexArray),HL=GL.vertexLength,IL=[],JL=[];for(const KL of DL){if(0===KL.length)continue;KL!==DL[0]&&JL.push(IL.length/2);const LL=this.segments2.prepareSegment(KL.length,this.layoutVertexArray,this.indexArray2),ML=LL.vertexLength;this.layoutVertexArray.emplaceBack(KL[0].x,KL[0].y),this.indexArray2.emplaceBack(ML+KL.length-1,ML),IL.push(KL[0].x),IL.push(KL[0].y);for(let NL=1;NL>3}if(e--,1===d||2===d)f+=a.readSVarint(),h+=a.readSVarint(),1===d&&(b&&i.push(b),b=[]),b.push(new g(f,h));else{if(7!==d)throw new Error("unknown command "+d);b&&b.push(b[0].clone())}}return b&&i.push(b),i},WL.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var b=a.readVarint()+a.pos,c=1,d=0,e=0,f=0,g=1/0,h=-1/0,i=1/0,j=-1/0;a.pos>3}if(d--,1===c||2===c)(e+=a.readSVarint())h&&(h=e),(f+=a.readSVarint())j&&(j=f);else if(7!==c)throw new Error("unknown command "+c)}return[g,i,h,j]},WL.prototype.toGeoJSON=function(a,b,c){var d,e,f=this.extent*Math.pow(2,c),g=this.extent*a,h=this.extent*b,i=this.loadGeometry(),j=WL.types[this.type];function k(a){for(var b=0;b>3;b=1===d?a.readString():2===d?a.readFloat():3===d?a.readDouble():4===d?a.readVarint64():5===d?a.readVarint():6===d?a.readSVarint():7===d?a.readBoolean():null}return b}(c))}function aM(a,b,c){if(3===a){var d=new ZL(c,c.readVarint()+c.pos);d.length&&(b[d.name]=d)}}$L.prototype.feature=function(a){if(a<0||a>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[a];var b=this._pbf.readVarint()+this._pbf.pos;return new VL(this._pbf,b,this.extent,this._keys,this._values)};var bM={VectorTile:function(a,b){this.layers=a.readFields(aM,{},b)},VectorTileFeature:VL,VectorTileLayer:ZL};const cM=bM.VectorTileFeature.types;function dM(a,b,c,d,e,f,g,h){a.emplaceBack((b<<1)+g,(c<<1)+f,(Math.floor(8192*d)<<1)+e,Math.round(h))}class eM{constructor(){this.acc=new g(0,0),this.polyCount=[]}startRing(fM){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new g(fM.x,fM.y),this.max=new g(fM.x,fM.y))}append(gM,hM){this.currentPolyCount.edges++,this.acc._add(gM);let iM=!!this.borders;const jM=this.min,kM=this.max;gM.xkM.x&&(kM.x=gM.x,iM=!0),gM.ykM.y&&(kM.y=gM.y,iM=!0),((0===gM.x||8192===gM.x)&&gM.x===hM.x)!=((0===gM.y||8192===gM.y)&&gM.y===hM.y)&&this.processBorderOverlap(gM,hM),iM&&this.checkBorderIntersection(gM,hM)}checkBorderIntersection(lM,mM){mM.x<0!=lM.x<0&&this.addBorderIntersection(0,di(mM.y,lM.y,(0-mM.x)/(lM.x-mM.x))),mM.x>8192!=lM.x>8192&&this.addBorderIntersection(1,di(mM.y,lM.y,(8192-mM.x)/(lM.x-mM.x))),mM.y<0!=lM.y<0&&this.addBorderIntersection(2,di(mM.x,lM.x,(0-mM.y)/(lM.y-mM.y))),mM.y>8192!=lM.y>8192&&this.addBorderIntersection(3,di(mM.x,lM.x,(8192-mM.y)/(lM.y-mM.y)))}addBorderIntersection(nM,oM){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const pM=this.borders[nM];oMpM[1]&&(pM[1]=oM)}processBorderOverlap(qM,rM){if(qM.x===rM.x){if(qM.y===rM.y)return;const sM=0===qM.x?0:1;this.addBorderIntersection(sM,rM.y),this.addBorderIntersection(sM,qM.y)}else{const tM=0===qM.y?2:3;this.addBorderIntersection(tM,rM.x),this.addBorderIntersection(tM,qM.x)}}centroid(){const uM=this.polyCount.reduce((a,b)=>a+b.edges,0);return 0!==uM?this.acc.div(uM)._round():new g(0,0)}span(){return new g(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((a,b)=>a+ +(b[0]!==Number.MAX_VALUE),0)}}class vM{constructor(wM){this.zoom=wM.zoom,this.overscaling=wM.overscaling,this.layers=wM.layers,this.layerIds=this.layers.map(a=>a.id),this.index=wM.index,this.hasPattern=!1,this.layoutVertexArray=new bt,this.centroidVertexArray=new $A,this.indexArray=new Rw,this.programConfigurations=new DF(wM.layers,wM.zoom),this.segments=new PG,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.enableTerrain=wM.enableTerrain}populate(xM,yM,zM,AM){for(const{feature:BM,id:CM,index:DM,sourceLayerIndex:EM}of(this.features=[],this.hasPattern=SK("fill-extrusion",this.layers,yM),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=(function(a){const b=Math.exp(Math.PI*(1-a.y/(1<a.x<=0)||_M.every(a=>a.x>=8192)||_M.every(a=>a.y<=0)||_M.every(a=>a.y>=8192))continue;for(let eN=0;eN=1){const jN=fN[hN-1];if(!MN(iN,jN)){aN&&aN.append(iN,jN),dN.vertexLength+4>PG.MAX_VERTEX_ARRAY_LENGTH&&(dN=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const kN=iN.sub(jN)._perp(),lN=kN.x/(Math.abs(kN.x)+Math.abs(kN.y)),mN=kN.y>0?1:0,nN=jN.dist(iN);gN+nN>32768&&(gN=0),dM(this.layoutVertexArray,iN.x,iN.y,lN,mN,0,0,gN),dM(this.layoutVertexArray,iN.x,iN.y,lN,mN,0,1,gN),gN+=nN,dM(this.layoutVertexArray,jN.x,jN.y,lN,mN,0,0,gN),dM(this.layoutVertexArray,jN.x,jN.y,lN,mN,0,1,gN);const oN=dN.vertexLength;this.indexArray.emplaceBack(oN,oN+2,oN+1),this.indexArray.emplaceBack(oN+1,oN+2,oN+3),dN.vertexLength+=4,dN.primitiveLength+=2}}}}if(dN.vertexLength+cN>PG.MAX_VERTEX_ARRAY_LENGTH&&(dN=this.segments.prepareSegment(cN,this.layoutVertexArray,this.indexArray)),"Polygon"!==cM[VM.type])continue;const pN=[],qN=[],rN=dN.vertexLength;for(let sN=0;sN0){if(aN.borders){aN.vertexArrayOffset=this.centroidVertexArray.length;const yN=aN.borders,zN=this.featuresOnBorder.push(aN)-1;for(let AN=0;AN<4;AN++)yN[AN][0]!==Number.MAX_VALUE&&this.borders[AN].push(zN)}this.encodeCentroid(aN.borders?void 0:aN.centroid(),aN)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,VM,XM,ZM,$M,YM)}sortBorders(){for(let BN=0;BN<4;BN++)this.borders[BN].sort((a,b)=>this.featuresOnBorder[a].borders[BN][0]-this.featuresOnBorder[b].borders[BN][0])}encodeCentroid(CN,DN,EN=!0){let FN,GN;if(CN)if(0!==CN.y){const HN=DN.span()._mult(this.tileToMeter);FN=(Math.max(CN.x,1)<<3)+Math.min(7,Math.round(HN.x/10)),GN=(Math.max(CN.y,1)<<3)+Math.min(7,Math.round(HN.y/10))}else FN=Math.ceil(7*(CN.x+450)),GN=0;else FN=0,GN=+EN;let IN=EN?this.centroidVertexArray.length:DN.vertexArrayOffset;for(const JN of DN.polyCount){EN&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*JN.edges+JN.top);for(let KN=0;KN<2*JN.edges;KN++)this.centroidVertexArray.emplace(IN++,0,GN),this.centroidVertexArray.emplace(IN++,FN,GN);for(let LN=0;LN8192)||a.y===b.y&&(a.y<0||a.y>8192)}Zo("FillExtrusionBucket",vM,{omit:["layers","features"]}),Zo("PartMetadata",eM);var NN={paint:new As({"fill-extrusion-opacity":new qr(oc["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new yr(oc["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new qr(oc["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new qr(oc["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Pr(oc["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new yr(oc["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new yr(oc["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new qr(oc["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function ON(a,b){return a.x*b.x+a.y*b.y}function PN(a,b){if(1===a.length){let c=0;const d=b[c++];let e;for(;!e||d.equals(e);)if(!(e=b[c++]))return 1/0;for(;ca.id),this.index=ZN.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(a=>{this.gradients[a.id]={}}),this.layoutVertexArray=new nt,this.layoutVertexArray2=new Ht,this.indexArray=new Rw,this.programConfigurations=new DF(ZN.layers,ZN.zoom),this.segments=new PG,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate($N,_N,aO,bO){this.hasPattern=SK("line",this.layers,_N);const cO=this.layers[0].layout.get("line-sort-key"),dO=[];for(const{feature:eO,id:fO,index:gO,sourceLayerIndex:hO}of $N){const iO=this.layers[0]._featureFilter.needGeometry,jO=UH(eO,iO);if(!this.layers[0]._featureFilter.filter(new aq(this.zoom),jO,aO))continue;const kO=cO?cO.evaluate(jO,{},aO):void 0,lO={id:fO,properties:eO.properties,type:eO.type,sourceLayerIndex:hO,index:gO,geometry:iO?jO.geometry:TH(eO,aO,bO),patterns:{},sortKey:kO};dO.push(lO)}cO&&dO.sort((a,b)=>a.sortKey-b.sortKey);const{lineAtlas:mO,featureIndex:nO}=_N,oO=this.addConstantDashes(mO);for(const pO of dO){const{geometry:qO,index:rO,sourceLayerIndex:sO}=pO;if(oO&&this.addFeatureDashes(pO,mO),this.hasPattern){const tO=TK("line",this.layers,pO,this.zoom,_N);this.patternFeatures.push(tO)}else this.addFeature(pO,qO,rO,aO,mO.positions,_N.availableImages);nO.insert($N[rO].feature,qO,rO,sO,this.index)}}addConstantDashes(uO){let vO=!1;for(const wO of this.layers){const xO=wO.paint.get("line-dasharray").value,yO=wO.layout.get("line-cap").value;if("constant"!==xO.kind||"constant"!==yO.kind)vO=!0;else{const zO=yO.value,AO=xO.value;if(!AO)continue;uO.addDash(AO.from,zO),uO.addDash(AO.to,zO),AO.other&&uO.addDash(AO.other,zO)}}return vO}addFeatureDashes(BO,CO){const DO=this.zoom;for(const EO of this.layers){const FO=EO.paint.get("line-dasharray").value,GO=EO.layout.get("line-cap").value;if("constant"===FO.kind&&"constant"===GO.kind)continue;let HO,IO,JO,KO,LO,MO;if("constant"===FO.kind){const NO=FO.value;if(!NO)continue;HO=NO.other||NO.to,IO=NO.to,JO=NO.from}else HO=FO.evaluate({zoom:DO-1},BO),IO=FO.evaluate({zoom:DO},BO),JO=FO.evaluate({zoom:DO+1},BO);"constant"===GO.kind?KO=LO=MO=GO.value:(KO=GO.evaluate({zoom:DO-1},BO),LO=GO.evaluate({zoom:DO},BO),MO=GO.evaluate({zoom:DO+1},BO)),CO.addDash(HO,KO),CO.addDash(IO,LO),CO.addDash(JO,MO);const OO=CO.getKey(HO,KO),PO=CO.getKey(IO,LO),QO=CO.getKey(JO,MO);BO.patterns[EO.id]={min:OO,mid:PO,max:QO}}}update(RO,SO,TO,UO){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(RO,SO,this.stateDependentLayers,TO,UO)}addFeatures(VO,WO,XO,YO){for(const ZO of this.patternFeatures)this.addFeature(ZO,ZO.geometry,ZO.index,WO,XO,YO)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload($O){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=$O.createVertexBuffer(this.layoutVertexArray2,VN)),this.layoutVertexBuffer=$O.createVertexBuffer(this.layoutVertexArray,TN),this.indexBuffer=$O.createIndexBuffer(this.indexArray)),this.programConfigurations.upload($O),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(_O){if(_O.properties&&_O.properties.hasOwnProperty("mapbox_clip_start")&&_O.properties.hasOwnProperty("mapbox_clip_end"))return{start:+_O.properties.mapbox_clip_start,end:+_O.properties.mapbox_clip_end}}addFeature(aP,bP,cP,dP,eP,fP){const gP=this.layers[0].layout,hP=gP.get("line-join").evaluate(aP,{}),iP=gP.get("line-cap").evaluate(aP,{}),jP=gP.get("line-miter-limit"),kP=gP.get("line-round-limit");for(const lP of(this.lineClips=this.lineFeatureClips(aP),bP))this.addLine(lP,aP,hP,iP,jP,kP);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,aP,cP,eP,fP,dP)}addLine(mP,nP,oP,pP,qP,rP){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let sP=0;sP=2&&mP[uP-1].equals(mP[uP-2]);)uP--;let vP=0;for(;vP0;if(JP&&DP>vP){const LP=yP.dist(zP);if(LP>2*wP){const MP=yP.sub(yP.sub(zP)._mult(wP/LP)._round());this.updateDistance(zP,MP),this.addCurrentVertex(MP,BP,0,0,xP),zP=MP}}const NP=zP&&AP;let OP=NP?oP:tP?"butt":pP;if(NP&&"round"===OP&&(HPqP&&(OP="bevel"),"bevel"===OP&&(HP>2&&(OP="flipbevel"),HP100)EP=CP.mult(-1);else{const PP=HP*BP.add(CP).mag()/BP.sub(CP).mag();EP._perp()._mult(PP*(KP?-1:1))}this.addCurrentVertex(yP,EP,0,0,xP),this.addCurrentVertex(yP,EP.mult(-1),0,0,xP)}else if("bevel"===OP||"fakeround"===OP){const QP=-Math.sqrt(HP*HP-1),RP=KP?QP:0,SP=KP?0:QP;if(zP&&this.addCurrentVertex(yP,BP,RP,SP,xP),"fakeround"===OP){const TP=Math.round(180*IP/Math.PI/20);for(let UP=1;UP2*wP){const $P=yP.add(AP.sub(yP)._mult(wP/ZP)._round());this.updateDistance(yP,$P),this.addCurrentVertex($P,CP,0,0,xP),yP=$P}}}}addCurrentVertex(_P,aQ,bQ,cQ,dQ,eQ=!1){const fQ=aQ.y*cQ-aQ.x,gQ=-aQ.y-aQ.x*cQ;this.addHalfVertex(_P,aQ.x+aQ.y*bQ,aQ.y-aQ.x*bQ,eQ,!1,bQ,dQ),this.addHalfVertex(_P,fQ,gQ,eQ,!0,-cQ,dQ)}addHalfVertex({x:hQ,y:iQ},jQ,kQ,lQ,mQ,nQ,oQ){this.layoutVertexArray.emplaceBack((hQ<<1)+(lQ?1:0),(iQ<<1)+(mQ?1:0),Math.round(63*jQ)+128,Math.round(63*kQ)+128,1+(0===nQ?0:nQ<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const pQ=oQ.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,pQ),oQ.primitiveLength++),mQ?this.e2=pQ:this.e1=pQ}updateScaledDistance(){if(this.lineClips){const qQ=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=qQ*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(rQ,sQ){this.distance+=rQ.dist(sQ),this.updateScaledDistance()}}Zo("LineBucket",YN,{omit:["layers","patternFeatures"]});const tQ=new As({"line-cap":new yr(oc.layout_line["line-cap"]),"line-join":new yr(oc.layout_line["line-join"]),"line-miter-limit":new qr(oc.layout_line["line-miter-limit"]),"line-round-limit":new qr(oc.layout_line["line-round-limit"]),"line-sort-key":new yr(oc.layout_line["line-sort-key"])});var uQ={paint:new As({"line-opacity":new yr(oc.paint_line["line-opacity"]),"line-color":new yr(oc.paint_line["line-color"]),"line-translate":new qr(oc.paint_line["line-translate"]),"line-translate-anchor":new qr(oc.paint_line["line-translate-anchor"]),"line-width":new yr(oc.paint_line["line-width"]),"line-gap-width":new yr(oc.paint_line["line-gap-width"]),"line-offset":new yr(oc.paint_line["line-offset"]),"line-blur":new yr(oc.paint_line["line-blur"]),"line-dasharray":new Pr(oc.paint_line["line-dasharray"]),"line-pattern":new Pr(oc.paint_line["line-pattern"]),"line-gradient":new us(oc.paint_line["line-gradient"])}),layout:tQ};const vQ=new class extends yr{possiblyEvaluate(a,b){return b=new aq(Math.floor(b.zoom),{now:b.now,fadeDuration:b.fadeDuration,zoomHistory:b.zoomHistory,transition:b.transition}),super.possiblyEvaluate(a,b)}evaluate(c,d,e,f){return d=_({},d,{zoom:Math.floor(d.zoom)}),super.evaluate(c,d,e,f)}}(uQ.paint.properties["line-width"].specification);function wQ(a,b){return b>0?b+2*a:a}vQ.useIntegerZoom=!0;const xQ=Ts([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),yQ=Ts([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ts([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const zQ=Ts([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),AQ=Ts([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Ts([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const BQ=Ts([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),CQ=Ts([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function DQ(a,b){const{expression:c}=b;if("constant"===c.kind)return{kind:"constant",layoutSize:c.evaluate(new aq(a+1))};if("source"===c.kind)return{kind:"source"};{const{zoomStops:d,interpolationType:e}=c;let f=0;for(;f{a.text=(function(a,b,c){const d=b.layout.get("text-transform").evaluate(c,{});return"uppercase"===d?a=a.toLocaleUpperCase():"lowercase"===d&&(a=a.toLocaleLowerCase()),_p.applyArabicShaping&&(a=_p.applyArabicShaping(a)),a})(a.text,b,c)}),a}const IQ={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function JQ(a){return"︶"===a||"﹈"===a||"︸"===a||"﹄"===a||"﹂"===a||"︾"===a||"︼"===a||"︺"===a||"︘"===a||"﹀"===a||"︐"===a||"︓"===a||"︔"===a||"`"===a||" ̄"===a||"︑"===a||"︒"===a}function KQ(a){return"︵"===a||"﹇"===a||"︷"===a||"﹃"===a||"﹁"===a||"︽"===a||"︻"===a||"︹"===a||"︗"===a||"︿"===a}var LQ=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<< -k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<< -k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},MQ=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?5960464477539062e-23:0,n=d?0:f-1,o=d?1:-1,p=b<0||0===b&&1/b<0?1:0;for(isNaN(b=Math.abs(b))||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),(b+=g+l>=1?m/i:m*Math.pow(2,1-l))*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p},NQ=OQ;function OQ(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}OQ.Varint=0,OQ.Fixed64=1,OQ.Bytes=2,OQ.Fixed32=5;var PQ="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function QQ(a){return a.type===OQ.Bytes?a.readVarint()+a.pos:a.pos+1}function RQ(a,b,c){return c?4294967296*b+(a>>>0):4294967296*(b>>>0)+(a>>>0)}function SQ(a,b,c){var d=b<=16383?1:b<=2097151?2:b<=268435455?3:Math.floor(Math.log(b)/(7*Math.LN2));c.realloc(d);for(var e=c.pos-1;e>=a;e--)c.buf[e+d]=c.buf[e]}function TQ(a,b){for(var c=0;c>>8,a[c+2]=b>>>16,a[c+3]=b>>>24}function cR(a,b){return(a[b]|a[b+1]<<8|a[b+2]<<16)+(a[b+3]<<24)}function dR(a,b,c){b.glyphs=[],1===a&&c.readMessage(eR,b)}function eR(a,b,c){if(3===a){const{id:d,bitmap:e,width:f,height:g,left:h,top:i,advance:j}=c.readMessage(fR,{});b.glyphs.push({id:d,bitmap:new OJ({width:f+6,height:g+6},e),metrics:{width:f,height:g,left:h,top:i,advance:j}})}else 4===a?b.ascender=c.readSVarint():5===a&&(b.descender=c.readSVarint())}function fR(a,b,c){1===a?b.id=c.readVarint():2===a?b.bitmap=c.readBytes():3===a?b.width=c.readVarint():4===a?b.height=c.readVarint():5===a?b.left=c.readSVarint():6===a?b.top=c.readSVarint():7===a&&(b.advance=c.readVarint())}function gR(a){let b=0,c=0;for(const d of a)b+=d.w*d.h,c=Math.max(c,d.w);a.sort((a,b)=>b.h-a.h);const e=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(b/.95)),c),h:1/0}];let f=0,g=0;for(const h of a)for(let i=e.length-1;i>=0;i--){const j=e[i];if(!(h.w>j.w||h.h>j.h)){if(h.x=j.x,h.y=j.y,g=Math.max(g,h.y+h.h),f=Math.max(f,h.x+h.w),h.w===j.w&&h.h===j.h){const k=e.pop();i>3,f=this.pos;this.type=7&d,a(e,b,this),this.pos===f&&this.skip(d)}return b},readMessage:function(a,b){return this.readFields(a,b,this.readVarint()+this.pos)},readFixed32:function(){var a=aR(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=cR(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=aR(this.buf,this.pos)+4294967296*aR(this.buf,this.pos+4);return this.pos+=8,a},readSFixed64:function(){var a=aR(this.buf,this.pos)+4294967296*cR(this.buf,this.pos+4);return this.pos+=8,a},readFloat:function(){var a=LQ(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=LQ(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(a){var b,c,d=this.buf;return b=127&(c=d[this.pos++]),c<128?b:(b|=(127&(c=d[this.pos++]))<<7,c<128?b:(b|=(127&(c=d[this.pos++]))<<14,c<128?b:(b|=(127&(c=d[this.pos++]))<<21,c<128?b:(function(a,b,c){var d,e,f=c.buf;if(d=(112&(e=f[c.pos++]))>>4,e<128)return RQ(a,d,b);if(d|=(127&(e=f[c.pos++]))<<3,e<128)return RQ(a,d,b);if(d|=(127&(e=f[c.pos++]))<<10,e<128)return RQ(a,d,b);if(d|=(127&(e=f[c.pos++]))<<17,e<128)return RQ(a,d,b);if(d|=(127&(e=f[c.pos++]))<<24,e<128)return RQ(a,d,b);if(d|=(1&(e=f[c.pos++]))<<31,e<128)return RQ(a,d,b);throw new Error("Expected varint not more than 10 bytes")})(b|=(15&(c=d[this.pos]))<<28,a,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?-((a+1)/2):a/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var a,b,c,d=this.readVarint()+this.pos,e=this.pos;return this.pos=d,d-e>=12&&PQ?(a=this.buf,b=e,c=d,PQ.decode(a.subarray(b,c))):(function(a,b,c){for(var d="",e=b;e239?4:i>223?3:i>191?2:1;if(e+k>c)break;1===k?i<128&&(j=i):2===k?128==(192&(f=a[e+1]))&&(j=(31&i)<<6|63&f)<=127&&(j=null):3===k?(g=a[e+2],128==(192&(f=a[e+1]))&&128==(192&g)&&((j=(15&i)<<12|(63&f)<<6|63&g)<=2047||j>=55296&&j<=57343)&&(j=null)):4===k&&(g=a[e+2],h=a[e+3],128==(192&(f=a[e+1]))&&128==(192&g)&&128==(192&h)&&((j=(15&i)<<18|(63&f)<<12|(63&g)<<6|63&h)<=65535||j>=1114112)&&(j=null)),null===j?(j=65533,k=1):j>65535&&(j-=65536,d+=String.fromCharCode(j>>>10&1023|55296),j=56320|1023&j),d+=String.fromCharCode(j),e+=k}return d})(this.buf,e,d)},readBytes:function(){var a=this.readVarint()+this.pos,b=this.buf.subarray(this.pos,a);return this.pos=a,b},readPackedVarint:function(a,b){if(this.type!==OQ.Bytes)return a.push(this.readVarint(b));var c=QQ(this);for(a=a||[];this.pos127;);else if(b===OQ.Bytes)this.pos=this.readVarint()+this.pos;else if(b===OQ.Fixed32)this.pos+=4;else{if(b!==OQ.Fixed64)throw new Error("Unimplemented type: "+b);this.pos+=8}},writeTag:function(a,b){this.writeVarint(a<<3|b)},realloc:function(a){for(var b=this.length||16;b268435455||a<0?(function(a,b){var c,d,e,f,g,h,i;if(a>=0?(c=a%4294967296|0,d=a/4294967296|0):(d=~(-a/4294967296),4294967295^(c=~(-a%4294967296))?c=c+1|0:(c=0,d=d+1|0)),a>=0x7fffffffffffffff||a< 0x8000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");b.realloc(10),e=c,(f=b).buf[f.pos++]=127&e|128,e>>>=7,f.buf[f.pos++]=127&e|128,e>>>=7,f.buf[f.pos++]=127&e|128,e>>>=7,f.buf[f.pos++]=127&e|128,f.buf[f.pos]=127&(e>>>=7),g=d,h=b,i=(7&g)<<4,h.buf[h.pos++]|=i|((g>>>=3)?128:0),g&&(h.buf[h.pos++]=127&g|((g>>>=7)?128:0),g&&(h.buf[h.pos++]=127&g|((g>>>=7)?128:0),g&&(h.buf[h.pos++]=127&g|((g>>>=7)?128:0),g&&(h.buf[h.pos++]=127&g|((g>>>=7)?128:0),g&&(h.buf[h.pos++]=127&g)))))})(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?-(2*a)-1:2*a)},writeBoolean:function(a){this.writeVarint(Boolean(a))},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var b=this.pos;this.pos=(function(a,b,c){for(var d,e,f=0;f55295&&d<57344){if(!e){d>56319||f+1===b.length?(a[c++]=239,a[c++]=191,a[c++]=189):e=d;continue}if(d<56320){a[c++]=239,a[c++]=191,a[c++]=189,e=d;continue}d=e-55296<<10|d-56320|65536,e=null}else e&&(a[c++]=239,a[c++]=191,a[c++]=189,e=null);d<128?a[c++]=d:(d<2048?a[c++]=d>>6|192:(d<65536?a[c++]=d>>12|224:(a[c++]=d>>18|240,a[c++]=d>>12&63|128),a[c++]=d>>6&63|128),a[c++]=63&d|128)}return c})(this.buf,a,this.pos);var c=this.pos-b;c>=128&&SQ(b,c,this),this.pos=b-1,this.writeVarint(c),this.pos+=c},writeFloat:function(a){this.realloc(4),MQ(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),MQ(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(a){var b=a.length;this.writeVarint(b),this.realloc(b);for(var c=0;c=128&&SQ(c,d,this),this.pos=c-1,this.writeVarint(d),this.pos+=d},writeMessage:function(a,b,c){this.writeTag(a,OQ.Bytes),this.writeRawMessage(b,c)},writePackedVarint:function(a,b){b.length&&this.writeMessage(a,TQ,b)},writePackedSVarint:function(a,b){b.length&&this.writeMessage(a,UQ,b)},writePackedBoolean:function(a,b){b.length&&this.writeMessage(a,XQ,b)},writePackedFloat:function(a,b){b.length&&this.writeMessage(a,VQ,b)},writePackedDouble:function(a,b){b.length&&this.writeMessage(a,WQ,b)},writePackedFixed32:function(a,b){b.length&&this.writeMessage(a,YQ,b)},writePackedSFixed32:function(a,b){b.length&&this.writeMessage(a,ZQ,b)},writePackedFixed64:function(a,b){b.length&&this.writeMessage(a,$Q,b)},writePackedSFixed64:function(a,b){b.length&&this.writeMessage(a,_Q,b)},writeBytesField:function(a,b){this.writeTag(a,OQ.Bytes),this.writeBytes(b)},writeFixed32Field:function(a,b){this.writeTag(a,OQ.Fixed32),this.writeFixed32(b)},writeSFixed32Field:function(a,b){this.writeTag(a,OQ.Fixed32),this.writeSFixed32(b)},writeFixed64Field:function(a,b){this.writeTag(a,OQ.Fixed64),this.writeFixed64(b)},writeSFixed64Field:function(a,b){this.writeTag(a,OQ.Fixed64),this.writeSFixed64(b)},writeVarintField:function(a,b){this.writeTag(a,OQ.Varint),this.writeVarint(b)},writeSVarintField:function(a,b){this.writeTag(a,OQ.Varint),this.writeSVarint(b)},writeStringField:function(a,b){this.writeTag(a,OQ.Bytes),this.writeString(b)},writeFloatField:function(a,b){this.writeTag(a,OQ.Fixed32),this.writeFloat(b)},writeDoubleField:function(a,b){this.writeTag(a,OQ.Fixed64),this.writeDouble(b)},writeBooleanField:function(a,b){this.writeVarintField(a,Boolean(b))}};class hR{constructor(iR,{pixelRatio:jR,version:kR,stretchX:lR,stretchY:mR,content:nR}){this.paddedRect=iR,this.pixelRatio=jR,this.stretchX=lR,this.stretchY=mR,this.content=nR,this.version=kR}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class oR{constructor(pR,qR){const rR={},sR={};this.haveRenderCallbacks=[];const tR=[];this.addImages(pR,rR,tR),this.addImages(qR,sR,tR);const{w:uR,h:vR}=gR(tR),wR=new XJ({width:uR||1,height:vR||1});for(const xR in pR){const yR=pR[xR],zR=rR[xR].paddedRect;XJ.copy(yR.data,wR,{x:0,y:0},{x:zR.x+1,y:zR.y+1},yR.data)}for(const AR in qR){const BR=qR[AR],CR=sR[AR].paddedRect,DR=CR.x+1,ER=CR.y+1,FR=BR.data.width,GR=BR.data.height;XJ.copy(BR.data,wR,{x:0,y:0},{x:DR,y:ER},BR.data),XJ.copy(BR.data,wR,{x:0,y:GR-1},{x:DR,y:ER-1},{width:FR,height:1}),XJ.copy(BR.data,wR,{x:0,y:0},{x:DR,y:ER+GR},{width:FR,height:1}),XJ.copy(BR.data,wR,{x:FR-1,y:0},{x:DR-1,y:ER},{width:1,height:GR}),XJ.copy(BR.data,wR,{x:0,y:0},{x:DR+FR,y:ER},{width:1,height:GR})}this.image=wR,this.iconPositions=rR,this.patternPositions=sR}addImages(HR,IR,JR){for(const KR in HR){const LR=HR[KR],MR={x:0,y:0,w:LR.data.width+2,h:LR.data.height+2};JR.push(MR),IR[KR]=new hR(MR,LR),LR.hasRenderCallback&&this.haveRenderCallbacks.push(KR)}}patchUpdatedImages(NR,OR){for(const PR in NR.dispatchRenderCallbacks(this.haveRenderCallbacks),NR.updatedImages)this.patchUpdatedImage(this.iconPositions[PR],NR.getImage(PR),OR),this.patchUpdatedImage(this.patternPositions[PR],NR.getImage(PR),OR)}patchUpdatedImage(QR,RR,SR){if(!QR||!RR)return;if(QR.version===RR.version)return;QR.version=RR.version;const[TR,UR]=QR.tl;SR.update(RR.data,void 0,{x:TR,y:UR})}}Zo("ImagePosition",hR),Zo("ImageAtlas",oR);const VR={horizontal:1,vertical:2,horizontalOnly:3};class WR{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(XR,YR){const ZR=new WR;return ZR.scale=XR||1,ZR.fontStack=YR,ZR}static forImage($R){const _R=new WR;return _R.imageName=$R,_R}}class aS{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(bS,cS){const dS=new aS;for(let eS=0;eS=0&&nS>=kS&&zS[this.text.charCodeAt(nS)];nS--)mS--;this.text=this.text.substring(kS,mS),this.sectionIndex=this.sectionIndex.slice(kS,mS)}substring(oS,pS){const qS=new aS;return qS.text=this.text.substring(oS,pS),qS.sectionIndex=this.sectionIndex.slice(oS,pS),qS.sections=this.sections,qS}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((a,b)=>Math.max(a,this.sections[b].scale),0)}addTextSection(rS,sS){this.text+=rS.text,this.sections.push(WR.forText(rS.scale,rS.fontStack||sS));const tS=this.sections.length-1;for(let uS=0;uS=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function yS(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){const q=aS.fromFeature(a,e);let r;l===VR.vertical&&q.verticalizePunctuation(m);const{processBidirectionalText:s,processStyledBidirectionalText:t}=_p;if(s&&1===q.sections.length){r=[];const u=s(q.toString(),GS(q,j,f,b,d,n,o));for(const v of u){const w=new aS;w.text=v,w.sections=q.sections;for(let x=0;x0&&S>C&&(C=S)}else{const T=c[G.fontStack];if(!T)continue;T[I]&&(L=T[I]);const U=b[G.fontStack];if(!U)continue;const V=U.glyphs[I];if(!V)continue;if(K=V.metrics,N=8203!==I?24:0,r){const W=void 0!==U.ascender?Math.abs(U.ascender):0,X=void 0!==U.descender?Math.abs(U.descender):0,Y=(W+X)*J;D=0;let l=0;for(let m=0;m -c/2;){if(g--,g<0)return!1;h-=a[g].dist(f),f=a[g]}h+=a[g].dist(a[g+1]),g++;const i=[];let j=0;for(;hd;)j-=i.shift().angleDelta;if(j>e)return!1;g++,h+=k.dist(l)}return!0}function SS(a){let b=0;for(let c=0;cj){const o=(j-i)/n,p=di(l.x,m.x,o),q=di(l.y,m.y,o),r=new LS(p,q,0,m.angleTo(l),k);return!g||RS(a,r,h,g,b)?r:void 0}i+=n}}function WS(a,b,c,d,e,f,g,h,i){const j=TS(d,f,g),k=US(d,e),l=k*g,m=0===a[0].x||a[0].x===i||0===a[0].y||a[0].y===i;return b-l=0&&u=0&&v=0&&m+j<=k){const w=new LS(u,v,0,s,o);w._round(),d&&!RS(a,w,f,d,e)||n.push(w)}}l+=r}return h||n.length||g||(n=XS(a,l/2,c,d,e,f,g,!0,i)),n}function YS(a,b,c,d,e){const f=[];for(let h=0;h=d&&m.x>=d||(l.x>=d?l=new g(d,l.y+(d-l.x)/(m.x-l.x)*(m.y-l.y))._round():m.x>=d&&(m=new g(d,l.y+(d-l.x)/(m.x-l.x)*(m.y-l.y))._round()),l.y>=e&&m.y>=e||(l.y>=e?l=new g(l.x+(e-l.y)/(m.y-l.y)*(m.x-l.x),e)._round():m.y>=e&&(m=new g(l.x+(e-l.y)/(m.y-l.y)*(m.x-l.x),e)._round()),j&&l.equals(j[j.length-1])||(j=[l],f.push(j)),j.push(m)))))}}return f}function ZS(a,b,c,d,e,f,g,h,i){for(let j=b;j -1)i++,f[i]=h,g[i]=j,g[i+1]=1e20}for(let m=0,n=0;m{let d=this.entries[a];d||(d=this.entries[a]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let e=d.glyphs[b];if(void 0!==e)return void c(null,{stack:a,id:b,glyph:e});if(e=this._tinySDF(d,a,b))return d.glyphs[b]=e,void c(null,{stack:a,id:b,glyph:e});const f=Math.floor(b/256);if(256*f>65535)return void c(new Error("glyphs > 65535 not supported"));if(d.ranges[f])return void c(null,{stack:a,id:b,glyph:e});let g=d.requests[f];g||(g=d.requests[f]=[],aT.loadGlyphRange(a,f,this.url,this.requestManager,(a,b)=>{if(b){for(const c in d.ascender=b.ascender,d.descender=b.descender,b.glyphs)this._doesCharSupportLocalGlyph(+c)||(d.glyphs[+c]=b.glyphs[+c]);d.ranges[f]=!0}for(const e of g)e(a,b);delete d.requests[f]})),g.push((d,e)=>{d?c(d):e&&c(null,{stack:a,id:b,glyph:e.glyphs[b]||null})})},(a,b)=>{if(a)gT(a);else if(b){const c={};for(const{stack:d,id:e,glyph:f}of b)void 0===c[d]&&(c[d]={}),void 0===c[d].glyphs&&(c[d].glyphs={}),c[d].glyphs[e]=f&&{id:f.id,bitmap:f.bitmap.clone(),metrics:f.metrics},c[d].ascender=this.entries[d].ascender,c[d].descender=this.entries[d].descender;gT(null,c)}})}_doesCharSupportLocalGlyph(kT){return this.localGlyphMode!==_S.none&&(this.localGlyphMode===_S.all?!!this.localFontFamily:!!this.localFontFamily&&(xp(kT)||Ap(kT)||op(kT)||pp(kT))||np(kT))}_tinySDF(lT,mT,nT){const oT=this.localFontFamily;if(!oT||!this._doesCharSupportLocalGlyph(nT))return;let pT=lT.tinySDF;if(!pT){let qT="400";/bold/i.test(mT)?qT="900":/medium/i.test(mT)?qT="500":/light/i.test(mT)&&(qT="200"),(pT=lT.tinySDF=new aT.TinySDF({fontFamily:oT,fontWeight:qT,fontSize:48,buffer:6,radius:16})).fontWeight=qT}if(this.localGlyphs[pT.fontWeight][nT])return this.localGlyphs[pT.fontWeight][nT];const rT=String.fromCharCode(nT),{data:sT,width:tT,height:uT,glyphWidth:vT,glyphHeight:wT,glyphLeft:xT,glyphTop:yT,glyphAdvance:zT}=pT.draw(rT);return this.localGlyphs[pT.fontWeight][nT]={id:nT,bitmap:new OJ({width:tT,height:uT},sT),metrics:{width:vT/2,height:wT/2,left:xT/2,top:yT/2-27,advance:zT/2,localGlyph:!0}}}}function AT(a,b,c,d){const e=[],f=a.image,h=f.pixelRatio,i=f.paddedRect.w-2,j=f.paddedRect.h-2,k=a.right-a.left,l=a.bottom-a.top,m=f.stretchX||[[0,i]],n=f.stretchY||[[0,j]],o=(a,b)=>a+b[1]-b[0],p=m.reduce(o,0),q=n.reduce(o,0),r=i-p,s=j-q;let t=0,u=p,v=0,w=q,x=0,y=r,z=0,A=s;if(f.content&&d){const B=f.content;t=BT(m,0,B[0]),v=BT(n,0,B[1]),u=BT(m,B[0],B[2]),w=BT(n,B[1],B[3]),x=B[0]-t,z=B[1]-v,y=B[2]-B[0]-u,A=B[3]-B[1]-w}const C=(d,e,i,j)=>{const m=DT(d.stretch-t,u,k,a.left),n=ET(d.fixed-x,y,d.stretch,p),o=DT(e.stretch-v,w,l,a.top),r=ET(e.fixed-z,A,e.stretch,q),s=DT(i.stretch-t,u,k,a.left),B=ET(i.fixed-x,y,i.stretch,p),C=DT(j.stretch-v,w,l,a.top),D=ET(j.fixed-z,A,j.stretch,q),E=new g(m,o),F=new g(s,o),G=new g(s,C),H=new g(m,C),I=new g(n/h,r/h),J=new g(B/h,D/h),K=b*Math.PI/180;if(K){const L=Math.sin(K),M=Math.cos(K),N=[M,-L,L,M];E._matMult(N),F._matMult(N),H._matMult(N),G._matMult(N)}const O=d.stretch+d.fixed,P=e.stretch+e.fixed;return{tl:E,tr:F,bl:H,br:G,tex:{x:f.paddedRect.x+1+O,y:f.paddedRect.y+1+P,w:i.stretch+i.fixed-O,h:j.stretch+j.fixed-P},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:I,pixelOffsetBR:J,minFontScaleX:y/h/k,minFontScaleY:A/h/l,isSDF:c}};if(d&&(f.stretchX||f.stretchY)){const D=CT(m,r,p),E=CT(n,s,q);for(let F=0;F{if(a)e(a);else if(b){var c;const d={},f=(c=b,new NQ(c).readFields(dR,{}));for(const g of f.glyphs)d[g.id]=g;e(null,{glyphs:d,ascender:f.ascender,descender:f.descender})}})},aT.TinySDF=class{constructor({fontSize:a=24,buffer:b=3,radius:c=8,cutoff:d=.25,fontFamily:e="sans-serif",fontWeight:f="normal",fontStyle:g="normal"}){this.buffer=b,this.cutoff=d,this.radius=c;const h=this.size=a+4*b,i=this._createCanvas(h),j=this.ctx=i.getContext("2d",{willReadFrequently:!0});j.font=`${g} ${f} ${a}px ${e}`,j.textBaseline="alphabetic",j.textAlign="left",j.fillStyle="black",this.gridOuter=new Float64Array(h*h),this.gridInner=new Float64Array(h*h),this.f=new Float64Array(h),this.z=new Float64Array(h+1),this.v=new Uint16Array(h)}_createCanvas(k){const l=document.createElement("canvas");return l.width=l.height=k,l}draw(m){const{width:n,actualBoundingBoxAscent:o,actualBoundingBoxDescent:p,actualBoundingBoxLeft:q,actualBoundingBoxRight:r}=this.ctx.measureText(m),s=Math.floor(o),t=Math.min(this.size-this.buffer,Math.ceil(r-q)),u=Math.min(this.size-this.buffer,Math.ceil(o)+Math.ceil(p)),v=t+2*this.buffer,w=u+2*this.buffer,x=v*w,y=new Uint8ClampedArray(x),z={data:y,width:v,height:w,glyphWidth:t,glyphHeight:u,glyphTop:s,glyphLeft:0,glyphAdvance:n};if(0===t||0===u)return z;const{ctx:A,buffer:B,gridInner:C,gridOuter:D}=this;A.clearRect(B,B,t,u),A.fillText(m,B,B+s+1);const E=A.getImageData(B,B,t,u);D.fill(1e20,0,x),C.fill(0,0,x);for(let F=0;F0?J*J:0,C[I]=J<0?J*J:0}}ZS(D,0,0,v,w,v,this.f,this.v,this.z),ZS(C,B,B,t,u,v,this.f,this.v,this.z);for(let K=0;Kb?1:0}){if(this.data=HT,this.length=this.data.length,this.compare=IT,this.length>0)for(let JT=(this.length>>1)-1;JT>=0;JT--)this._down(JT)}push(KT){this.data.push(KT),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const LT=this.data[0],MT=this.data.pop();return this.length--,this.length>0&&(this.data[0]=MT,this._down(0)),LT}peek(){return this.data[0]}_up(NT){const{data:OT,compare:PT}=this,QT=OT[NT];for(;NT>0;){const RT=NT-1>>1,ST=OT[RT];if(PT(QT,ST)>=0)break;OT[NT]=ST,NT=RT}OT[NT]=QT}_down(TT){const{data:UT,compare:VT}=this,WT=this.length>>1,XT=UT[TT];for(;TTVT(UT[$T],ZT)&&(YT=$T,ZT=UT[$T]),VT(ZT,XT)>=0)break;UT[TT]=ZT,TT=YT}UT[TT]=XT}}function _T(a,b=1,c=!1){let d=1/0,e=1/0,f=-1/0,h=-1/0;const i=a[0];for(let j=0;jf)&&(f=k.x),(!j||k.y>h)&&(h=k.y)}const l=Math.min(f-d,h-e);let m=l/2;const n=new GT([],aU);if(0===l)return new g(d,e);for(let o=d;oq.d||!q.d)&&(q=s,c&&console.log("found best %d after %d probes",Math.round(1e4*s.d)/1e4,r)),s.max-q.d<=b||(m=s.h/2,n.push(new bU(s.p.x-m,s.p.y-m,m,a)),n.push(new bU(s.p.x+m,s.p.y-m,m,a)),n.push(new bU(s.p.x-m,s.p.y+m,m,a)),n.push(new bU(s.p.x+m,s.p.y+m,m,a)),r+=4)}return c&&(console.log(`num probes: ${r}`),console.log(`best distance: ${q.d}`)),q.p}function aU(a,b){return b.max-a.max}function bU(a,b,c,d){this.p=new g(a,b),this.h=c,this.d=(function(a,b){let c=!1,d=1/0;for(let e=0;ea.y!=k.y>a.y&&a.x<(k.x-j.x)*(a.y-j.y)/(k.y-j.y)+j.x&&(c=!c),d=Math.min(d,NI(a,j,k))}}return(c?1:-1)*Math.sqrt(d)})(this.p,d),this.max=this.d+this.h*Math.SQRT2}const cU=Number.POSITIVE_INFINITY,dU=Math.sqrt(2);function eU(a,b){return b[1]!==cU?(function(a,b,c){let d=0,e=0;switch(b=Math.abs(b),c=Math.abs(c),a){case"top-right":case"top-left":case"top":e=c-7;break;case"bottom-right":case"bottom-left":case"bottom":e=7-c}switch(a){case"top-right":case"bottom-right":case"right":d=-b;break;case"top-left":case"bottom-left":case"left":d=b}return[d,e]})(a,b[0],b[1]):(function(a,b){let c=0,d=0;b<0&&(b=0);const e=b/dU;switch(a){case"top-right":case"top-left":d=e-7;break;case"bottom-right":case"bottom-left":d=7-e;break;case"bottom":d=7-b;break;case"top":d=b-7}switch(a){case"top-right":case"bottom-right":c=-e;break;case"top-left":case"bottom-left":c=e;break;case"left":c=b;break;case"right":c=-b}return[c,d]})(a,b[0])}function fU(a,b,c,d,e,f,g,h,i,j){a.createArrays(),a.tilePixelRatio=8192/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const k=a.layers[0].layout,l=a.layers[0]._unevaluatedLayout._values,m={};if("composite"===a.textSizeData.kind){const{minZoom:n,maxZoom:o}=a.textSizeData;m.compositeTextSizes=[l["text-size"].possiblyEvaluate(new aq(n),h),l["text-size"].possiblyEvaluate(new aq(o),h)]}if("composite"===a.iconSizeData.kind){const{minZoom:p,maxZoom:q}=a.iconSizeData;m.compositeIconSizes=[l["icon-size"].possiblyEvaluate(new aq(p),h),l["icon-size"].possiblyEvaluate(new aq(q),h)]}m.layoutTextSize=l["text-size"].possiblyEvaluate(new aq(i+1),h),m.layoutIconSize=l["icon-size"].possiblyEvaluate(new aq(i+1),h),m.textMaxSize=l["text-size"].possiblyEvaluate(new aq(18),h);const r="map"===k.get("text-rotation-alignment")&&"point"!==k.get("symbol-placement"),s=k.get("text-size");for(const t of a.features){const u=k.get("text-font").evaluate(t,{},h).join(","),v=s.evaluate(t,{},h),w=m.layoutTextSize.evaluate(t,{},h),x=(m.layoutIconSize.evaluate(t,{},h),{horizontal:{},vertical:void 0}),y=t.text;let z,A=[0,0];if(y){const B=y.toString(),C=24*k.get("text-letter-spacing").evaluate(t,{},h),D=24*k.get("text-line-height").evaluate(t,{},h),E=Jp(B)?C:0,F=k.get("text-anchor").evaluate(t,{},h),G=k.get("text-variable-anchor");if(!G){const H=k.get("text-radial-offset").evaluate(t,{},h);A=H?eU(F,[24*H,cU]):k.get("text-offset").evaluate(t,{},h).map(a=>24*a)}let I=r?"center":k.get("text-justify").evaluate(t,{},h);const J=k.get("symbol-placement"),K="point"===J,L="point"===J?24*k.get("text-max-width").evaluate(t,{},h):0,M=d=>{a.allowVerticalPlacement&&Ip(B)&&(x.vertical=yS(y,b,c,e,u,L,D,F,d,E,A,VR.vertical,!0,J,w,v))};if(!r&&G){const N="auto"===I?G.map(a=>gU(a)):[I];let O=!1;for(let P=0;P=0||!Ip(B)){const S=yS(y,b,c,e,u,L,D,F,I,E,A,VR.horizontal,!1,J,w,v);S&&(x.horizontal[I]=S)}M("point"===J?"left":I)}}let T=!1;if(t.icon&&t.icon.name){const U=d[t.icon.name];U&&(z=JS(e[t.icon.name],k.get("icon-offset").evaluate(t,{},h),k.get("icon-anchor").evaluate(t,{},h)),T=U.sdf,void 0===a.sdfIcons?a.sdfIcons=U.sdf:a.sdfIcons!==U.sdf&&la("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(U.pixelRatio!==a.pixelRatio||0!==k.get("icon-rotate").constantOr(1))&&(a.iconsNeedLinear=!0))}const V=kU(x.horizontal)||x.vertical;a.iconsInText||(a.iconsInText=!!V&&V.iconsInText),(V||z)&&hU(a,t,x,z,d,m,w,0,A,T,g,h,j)}f&&a.generateCollisionDebugBuffers(i,a.collisionBoxArray)}function gU(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function hU(a,b,c,d,e,f,g,h,i,j,k,l,m){let n=f.textMaxSize.evaluate(b,{},l);void 0===n&&(n=g);const o=a.layers[0].layout,p=o.get("icon-offset").evaluate(b,{},l),q=kU(c.horizontal)||c.vertical,r=g/24,s=a.tilePixelRatio*n/24,t=a.tilePixelRatio*o.get("symbol-spacing"),u=o.get("text-padding")*a.tilePixelRatio,v=o.get("icon-padding")*a.tilePixelRatio,w=Q(o.get("text-max-angle")),x="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement"),y="map"===o.get("icon-rotation-alignment")&&"point"!==o.get("symbol-placement"),z=o.get("symbol-placement"),A=t/2,B=o.get("icon-text-fit");let C;d&&"none"!==B&&(a.allowVerticalPlacement&&c.vertical&&(C=KS(d,c.vertical,B,o.get("icon-text-fit-padding"),p,r)),q&&(d=KS(d,q,B,o.get("icon-text-fit-padding"),p,r)));const D=(g,h,n)=>{if(h.x<0||h.x>=8192||h.y<0||h.y>=8192)return;const{x:o,y:q,z:r}=m.projectTilePoint(h.x,h.y,n),s=new LS(o,q,r,0,void 0);!function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y){const z=a.addToLineVertexArray(b,d);let A,B,C,D,E,F,G,H=0,I=0,J=0,K=0,L=-1,M=-1;const N={};let O=eB(""),P=0,Q=0;if(void 0===i._unevaluatedLayout.getValue("text-radial-offset")?[P,Q]=i.layout.get("text-offset").evaluate(u,{},y).map(a=>24*a):(P=24*i.layout.get("text-radial-offset").evaluate(u,{},y),Q=cU),a.allowVerticalPlacement&&e.vertical){const R=e.vertical;if(o)F=mU(R),h&&(G=mU(h));else{const S=i.layout.get("text-rotate").evaluate(u,{},y)+90;C=lU(j,c,b,k,l,m,R,n,S,p),h&&(D=lU(j,c,b,k,l,m,h,r,S))}}if(f){const T=i.layout.get("icon-rotate").evaluate(u,{},y),U="none"!==i.layout.get("icon-text-fit"),V=AT(f,T,w,U),W=h?AT(h,T,w,U):void 0;B=lU(j,c,b,k,l,m,f,r,T),H=4*V.length;const X=a.iconSizeData;let Y=null;"source"===X.kind?(Y=[128*i.layout.get("icon-size").evaluate(u,{},y)])[0]>iU&&la(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===X.kind&&((Y=[128*v.compositeIconSizes[0].evaluate(u,{},y),128*v.compositeIconSizes[1].evaluate(u,{},y)])[0]>iU||Y[1]>iU)&&la(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),a.addSymbols(a.icon,V,Y,t,s,u,!1,c,b,z.lineStartIndex,z.lineLength,-1,x,y),L=a.icon.placedSymbolArray.length-1,W&&(I=4*W.length,a.addSymbols(a.icon,W,Y,t,s,u,VR.vertical,c,b,z.lineStartIndex,z.lineLength,-1,x,y),M=a.icon.placedSymbolArray.length-1)}for(const Z in e.horizontal){const $=e.horizontal[Z];A||(O=eB($.text),o?E=mU($):A=lU(j,c,b,k,l,m,$,n,i.layout.get("text-rotate").evaluate(u,{},y),p));const _=1===$.positionedLines.length;if(J+=jU(a,c,b,$,g,i,o,u,p,z,e.vertical?VR.horizontal:VR.horizontalOnly,_?Object.keys(e.horizontal):[Z],N,L,v,x,y),_)break}e.vertical&&(K+=jU(a,c,b,e.vertical,g,i,o,u,p,z,VR.vertical,["vertical"],N,M,v,x,y));let aa=-1;const ba=(a,b)=>a?Math.max(a,b):b;aa=ba(E,aa),aa=ba(F,aa),aa=ba(G,aa);const ca=aa> -1?1:0;a.glyphOffsetArray.length>=EU.MAX_GLYPHS&&la("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==u.sortKey&&a.addToSortKeyRanges(a.symbolInstances.length,u.sortKey),a.symbolInstances.emplaceBack(c.x,c.y,c.z,b.x,b.y,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,L,M,O,void 0!==A?A:a.collisionBoxArray.length,void 0!==A?A+1:a.collisionBoxArray.length,void 0!==C?C:a.collisionBoxArray.length,void 0!==C?C+1:a.collisionBoxArray.length,void 0!==B?B:a.collisionBoxArray.length,void 0!==B?B+1:a.collisionBoxArray.length,D||a.collisionBoxArray.length,D?D+1:a.collisionBoxArray.length,k,J,K,H,I,ca,0,P,Q,aa)}(a,h,s,g,c,d,e,C,a.layers[0],a.collisionBoxArray,b.index,b.sourceLayerIndex,a.index,u,x,i,0,v,y,p,b,f,j,k,l)};if("line"===z)for(const E of YS(b.geometry,0,0,8192,8192)){const F=WS(E,t,w,c.vertical||q,d,24,s,a.overscaling,8192);for(const G of F){const H=q;H&&nU(a,H.text,A,G)||D(E,G,l)}}else if("line-center"===z){for(const I of b.geometry)if(I.length>1){const J=VS(I,w,c.vertical||q,d,24,s);J&&D(I,J,l)}}else if("Polygon"===b.type)for(const K of QK(b.geometry,0)){const L=_T(K,16);D(K[0],new LS(L.x,L.y,0,0,void 0),l)}else if("LineString"===b.type)for(const M of b.geometry)D(M,new LS(M[0].x,M[0].y,0,0,void 0),l);else if("Point"===b.type)for(const N of b.geometry)for(const O of N)D([O],new LS(O.x,O.y,0,0,void 0),l)}const iU=32640;function jU(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){const s=function(a,b,c,d,e,f,h,i){const j=[];if(0===b.positionedLines.length)return j;const k=d.layout.get("text-rotate").evaluate(f,{})*Math.PI/180,l=function(a){const b=a[0],c=a[1],d=b*c;return d>0?[b,-c]:d<0?[-b,c]:0===b?[c,b]:[c,-b]}(c);let m=Math.abs(b.top-b.bottom);for(const n of b.positionedLines)m-=n.lineOffset;const o=b.positionedLines.length,p=m/o;let q=b.top-c[1];for(let r=0;riU&&la(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===t.kind&&((u=[128*p.compositeTextSizes[0].evaluate(i,{},r),128*p.compositeTextSizes[1].evaluate(i,{},r)])[0]>iU||u[1]>iU)&&la(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),a.addSymbols(a.text,s,u,j,h,i,l,b,c,k.lineStartIndex,k.lineLength,o,q,r),m))n[v]=a.text.placedSymbolArray.length-1;return 4*s.length}function kU(a){for(const b in a)return a[b];return null}function lU(a,b,c,d,e,f,h,i,j,k){let l=h.top,m=h.bottom,n=h.left,o=h.right;const p=h.collisionPadding;if(p&&(n-=p[0],l-=p[1],o+=p[2],m+=p[3]),j){const q=new g(n,l),r=new g(o,l),s=new g(n,m),t=new g(o,m),u=Q(j);let v=new g(0,0);k&&(v=new g(k[0],k[1])),q._rotateAround(u,v),r._rotateAround(u,v),s._rotateAround(u,v),t._rotateAround(u,v),n=Math.min(q.x,r.x,s.x,t.x),o=Math.max(q.x,r.x,s.x,t.x),l=Math.min(q.y,r.y,s.y,t.y),m=Math.max(q.y,r.y,s.y,t.y)}return a.emplaceBack(b.x,b.y,b.z,c.x,c.y,n,l,o,m,i,d,e,f),a.length-1}function mU(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const b=a.bottom-a.top;return b>0?Math.max(10,b):null}function nU(a,b,c,d){const e=a.compareText;if(b in e){const f=e[b];for(let g=f.length-1;g>=0;g--)if(d.dist(f[g])a.id),this.index=FU.index,this.pixelRatio=FU.pixelRatio,this.sourceLayerIndex=FU.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=l([]),this.placementViewportMatrix=l([]);const GU=this.layers[0]._unevaluatedLayout._values;this.textSizeData=DQ(this.zoom,GU["text-size"]),this.iconSizeData=DQ(this.zoom,GU["icon-size"]);const HU=this.layers[0].layout,IU=HU.get("symbol-sort-key"),JU=HU.get("symbol-z-order");this.canOverlap=HU.get("text-allow-overlap")||HU.get("icon-allow-overlap")||HU.get("text-ignore-placement")||HU.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==JU&& void 0!==IU.constantOr(1),this.sortFeaturesByY=("viewport-y"===JU||"auto"===JU&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=HU.get("text-writing-mode").map(a=>VR[a]),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.sourceID=FU.sourceID}createArrays(){this.text=new tU(new DF(this.layers,this.zoom,a=>/^text/.test(a))),this.icon=new tU(new DF(this.layers,this.zoom,a=>/^icon/.test(a))),this.glyphOffsetArray=new QA,this.lineVertexArray=new SA,this.symbolInstances=new OA}calculateGlyphDependencies(KU,LU,MU,NU,OU){for(let PU=0;PU0)&&("constant"!==XU.value.kind||XU.value.value.length>0),_U="constant"!==ZU.value.kind||!!ZU.value.value||Object.keys(ZU.parameters).length>0,aV=WU.get("symbol-sort-key");if(this.features=[],!$U&&!_U)return;const bV=SU.iconDependencies,cV=SU.glyphDependencies,dV=SU.availableImages,eV=new aq(this.zoom);for(const{feature:fV,id:gV,index:hV,sourceLayerIndex:iV}of RU){const jV=VU._featureFilter.needGeometry,kV=UH(fV,jV);if(!VU._featureFilter.filter(eV,kV,TU))continue;let lV,mV;if(jV||(kV.geometry=TH(fV,TU,UU)),$U){const nV=VU.getValueAndResolveTokens("text-field",kV,TU,dV),oV=Ad.factory(nV);sU(oV)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Zp()||this.hasRTLText&&_p.isParsed())&&(lV=HQ(oV,VU,kV))}if(_U){const pV=VU.getValueAndResolveTokens("icon-image",kV,TU,dV);mV=pV instanceof Hd?pV:Hd.fromString(pV)}if(!lV&&!mV)continue;const qV=this.sortFeaturesByKey?aV.evaluate(kV,{},TU):void 0;if(this.features.push({id:gV,text:lV,icon:mV,index:hV,sourceLayerIndex:iV,geometry:kV.geometry,properties:fV.properties,type:oU[fV.type],sortKey:qV}),mV&&(bV[mV.name]=!0),lV){const rV=XU.evaluate(kV,{},TU).join(","),sV="map"===WU.get("text-rotation-alignment")&&"point"!==WU.get("symbol-placement");for(const tV of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(VR.vertical)>=0,lV.sections))if(tV.image)bV[tV.image.name]=!0;else{const uV=Ip(lV.toString()),vV=tV.fontStack||rV,wV=cV[vV]=cV[vV]||{};this.calculateGlyphDependencies(tV.text,wV,sV,this.allowVerticalPlacement,uV)}}}"line"===WU.get("symbol-placement")&&(this.features=(function(a){const b={},c={},d=[];let e=0;function f(b){d.push(a[b]),e++}function g(a,b,e){const f=c[a];return delete c[a],c[b]=f,d[f].geometry[0].pop(),d[f].geometry[0]=d[f].geometry[0].concat(e[0]),f}function h(a,c,e){const f=b[c];return delete b[c],b[a]=f,d[f].geometry[0].shift(),d[f].geometry[0]=e[0].concat(d[f].geometry[0]),f}function i(a,b,c){const d=c?b[0][b[0].length-1]:b[0][0];return`${a}:${d.x}:${d.y}`}for(let j=0;ja.geometry)})(this.features)),this.sortFeaturesByKey&&this.features.sort((a,b)=>a.sortKey-b.sortKey)}update(xV,yV,zV,AV){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(xV,yV,this.layers,zV,AV),this.icon.programConfigurations.updatePaintArrays(xV,yV,this.layers,zV,AV))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(BV){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(BV),this.iconCollisionBox.upload(BV)),this.text.upload(BV,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(BV,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(CV,DV){const EV=this.lineVertexArray.length;if(void 0!==CV.segment){let FV=CV.dist(DV[CV.segment+1]),GV=CV.dist(DV[CV.segment]);const HV={};for(let IV=CV.segment+1;IV=0;JV--)HV[JV]={x:DV[JV].x,y:DV[JV].y,tileUnitDistanceFromAnchor:GV},JV>0&&(GV+=DV[JV-1].dist(DV[JV]));for(let KV=0;KV=0?lX.rightJustifiedTextSymbolIndex:lX.centerJustifiedTextSymbolIndex>=0?lX.centerJustifiedTextSymbolIndex:lX.leftJustifiedTextSymbolIndex>=0?lX.leftJustifiedTextSymbolIndex:lX.verticalPlacedTextSymbolIndex>=0?lX.verticalPlacedTextSymbolIndex:nX),pX=EQ(this.textSizeData,kX,oX)/24;return this.tilePixelRatio*pX}getSymbolInstanceIconSize(qX,rX,sX){const tX=this.icon.placedSymbolArray.get(sX),uX=EQ(this.iconSizeData,qX,tX);return this.tilePixelRatio*uX}_commitDebugCollisionVertexUpdate(vX,wX,xX){vX.emplaceBack(wX,-xX,-xX),vX.emplaceBack(wX,xX,-xX),vX.emplaceBack(wX,xX,xX),vX.emplaceBack(wX,-xX,xX)}_updateTextDebugCollisionBoxes(yX,zX,AX,BX,CX,DX){for(let EX=BX;EX0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(oY,pY){const qY=oY.placedSymbolArray.get(pY),rY=qY.vertexStartIndex+4*qY.numGlyphs;for(let sY=qY.vertexStartIndex;sYwY[a]-wY[b]||xY[b]-xY[a]),yY}addToSortKeyRanges(BY,CY){const DY=this.sortKeyRanges[this.sortKeyRanges.length-1];DY&&DY.sortKey===CY?DY.symbolInstanceEnd=BY+1:this.sortKeyRanges.push({sortKey:CY,symbolInstanceStart:BY,symbolInstanceEnd:BY+1})}sortFeatures(EY){if(this.sortFeaturesByY&&this.sortedAngle!==EY&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const FY of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(EY),this.sortedAngle=EY,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const GY=this.symbolInstances.get(FY);this.featureSortOrder.push(GY.featureIndex),[GY.rightJustifiedTextSymbolIndex,GY.centerJustifiedTextSymbolIndex,GY.leftJustifiedTextSymbolIndex].forEach((a,b,c)=>{a>=0&&c.indexOf(a)===b&&this.addIndicesForPlacedSymbol(this.text,a)}),GY.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,GY.verticalPlacedTextSymbolIndex),GY.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,GY.placedIconSymbolIndex),GY.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,GY.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Zo("SymbolBucket",EU,{omit:["layers","collisionBoxArray","features","compareText"]}),EU.MAX_GLYPHS=65535,EU.addDynamicAttributes=rU;const HY=new As({"symbol-placement":new qr(oc.layout_symbol["symbol-placement"]),"symbol-spacing":new qr(oc.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new qr(oc.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new yr(oc.layout_symbol["symbol-sort-key"]),"symbol-z-order":new qr(oc.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new qr(oc.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new qr(oc.layout_symbol["icon-ignore-placement"]),"icon-optional":new qr(oc.layout_symbol["icon-optional"]),"icon-rotation-alignment":new qr(oc.layout_symbol["icon-rotation-alignment"]),"icon-size":new yr(oc.layout_symbol["icon-size"]),"icon-text-fit":new qr(oc.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new qr(oc.layout_symbol["icon-text-fit-padding"]),"icon-image":new yr(oc.layout_symbol["icon-image"]),"icon-rotate":new yr(oc.layout_symbol["icon-rotate"]),"icon-padding":new qr(oc.layout_symbol["icon-padding"]),"icon-keep-upright":new qr(oc.layout_symbol["icon-keep-upright"]),"icon-offset":new yr(oc.layout_symbol["icon-offset"]),"icon-anchor":new yr(oc.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new qr(oc.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new qr(oc.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new qr(oc.layout_symbol["text-rotation-alignment"]),"text-field":new yr(oc.layout_symbol["text-field"]),"text-font":new yr(oc.layout_symbol["text-font"]),"text-size":new yr(oc.layout_symbol["text-size"]),"text-max-width":new yr(oc.layout_symbol["text-max-width"]),"text-line-height":new yr(oc.layout_symbol["text-line-height"]),"text-letter-spacing":new yr(oc.layout_symbol["text-letter-spacing"]),"text-justify":new yr(oc.layout_symbol["text-justify"]),"text-radial-offset":new yr(oc.layout_symbol["text-radial-offset"]),"text-variable-anchor":new qr(oc.layout_symbol["text-variable-anchor"]),"text-anchor":new yr(oc.layout_symbol["text-anchor"]),"text-max-angle":new qr(oc.layout_symbol["text-max-angle"]),"text-writing-mode":new qr(oc.layout_symbol["text-writing-mode"]),"text-rotate":new yr(oc.layout_symbol["text-rotate"]),"text-padding":new qr(oc.layout_symbol["text-padding"]),"text-keep-upright":new qr(oc.layout_symbol["text-keep-upright"]),"text-transform":new yr(oc.layout_symbol["text-transform"]),"text-offset":new yr(oc.layout_symbol["text-offset"]),"text-allow-overlap":new qr(oc.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new qr(oc.layout_symbol["text-ignore-placement"]),"text-optional":new qr(oc.layout_symbol["text-optional"])});var IY={paint:new As({"icon-opacity":new yr(oc.paint_symbol["icon-opacity"]),"icon-color":new yr(oc.paint_symbol["icon-color"]),"icon-halo-color":new yr(oc.paint_symbol["icon-halo-color"]),"icon-halo-width":new yr(oc.paint_symbol["icon-halo-width"]),"icon-halo-blur":new yr(oc.paint_symbol["icon-halo-blur"]),"icon-translate":new qr(oc.paint_symbol["icon-translate"]),"icon-translate-anchor":new qr(oc.paint_symbol["icon-translate-anchor"]),"text-opacity":new yr(oc.paint_symbol["text-opacity"]),"text-color":new yr(oc.paint_symbol["text-color"],{runtimeType:Nc,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new yr(oc.paint_symbol["text-halo-color"]),"text-halo-width":new yr(oc.paint_symbol["text-halo-width"]),"text-halo-blur":new yr(oc.paint_symbol["text-halo-blur"]),"text-translate":new qr(oc.paint_symbol["text-translate"]),"text-translate-anchor":new qr(oc.paint_symbol["text-translate-anchor"])}),layout:HY};class JY{constructor(KY){this.type=KY.property.overrides?KY.property.overrides.runtimeType:Jc,this.defaultValue=KY}evaluate(LY){if(LY.formattedSection){const MY=this.defaultValue.property.overrides;if(MY&&MY.hasOverride(LY.formattedSection))return MY.getOverride(LY.formattedSection)}return LY.feature&&LY.featureState?this.defaultValue.evaluate(LY.feature,LY.featureState):this.defaultValue.property.specification.default}eachChild(NY){this.defaultValue.isConstant()||NY(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Zo("FormatSectionOverride",JY,{omit:["defaultValue"]});class OY extends eG{constructor(PY){super(PY,IY)}recalculate(QY,RY){super.recalculate(QY,RY),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const SY=this.layout.get("text-writing-mode");if(SY){const TY=[];for(const UY of SY)0>TY.indexOf(UY)&&TY.push(UY);this.layout._values["text-writing-mode"]=TY}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(VY,WY,XY,YY){var ZY;const $Y=this.layout.get(VY).evaluate(WY,{},XY,YY),_Y=this._unevaluatedLayout._values[VY];return _Y.isDataDriven()||ln(_Y.value)||!$Y?$Y:(ZY=WY.properties,$Y.replace(/{([^{}]+)}/g,(a,b)=>b in ZY?String(ZY[b]):""))}createBucket(aZ){return new EU(aZ)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const bZ of IY.paint.overridableProperties){if(!OY.hasPaintOverride(this.layout,bZ))continue;const cZ=this.paint.get(bZ),dZ=new JY(cZ),eZ=new Qm(dZ,cZ.property.specification);let fZ=null;fZ="constant"===cZ.value.kind||"source"===cZ.value.kind?new nn("source",eZ):new Cn("composite",eZ,cZ.value.zoomStops,cZ.value._interpolationType),this.paint._values[bZ]=new er(cZ.property,fZ,cZ.parameters)}}_handleOverridablePaintPropertyUpdate(gZ,hZ,iZ){return!(!this.layout||hZ.isDataDriven()||iZ.isDataDriven())&&OY.hasPaintOverride(this.layout,gZ)}static hasPaintOverride(jZ,kZ){const lZ=jZ.get("text-field"),mZ=IY.paint.properties[kZ];let nZ=!1;const oZ=a=>{for(const b of a)if(mZ.overrides&&mZ.overrides.hasOverride(b))return void(nZ=!0)};if("constant"===lZ.value.kind&&lZ.value.value instanceof Ad)oZ(lZ.value.value.sections);else if("source"===lZ.value.kind){const pZ=a=>{nZ||(a instanceof Od&&Md(a.value)===Rc?oZ(a.value.sections):a instanceof se?oZ(a.sections):a.eachChild(pZ))},qZ=lZ.value;qZ._styleExpression&&pZ(qZ._styleExpression.expression)}return nZ}getProgramConfiguration(rZ){return new fE(this,rZ)}}var sZ={paint:new As({"background-color":new qr(oc.paint_background["background-color"]),"background-pattern":new is(oc.paint_background["background-pattern"]),"background-opacity":new qr(oc.paint_background["background-opacity"])})},tZ={paint:new As({"raster-opacity":new qr(oc.paint_raster["raster-opacity"]),"raster-hue-rotate":new qr(oc.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new qr(oc.paint_raster["raster-brightness-min"]),"raster-brightness-max":new qr(oc.paint_raster["raster-brightness-max"]),"raster-saturation":new qr(oc.paint_raster["raster-saturation"]),"raster-contrast":new qr(oc.paint_raster["raster-contrast"]),"raster-resampling":new qr(oc.paint_raster["raster-resampling"]),"raster-fade-duration":new qr(oc.paint_raster["raster-fade-duration"])})};class uZ extends eG{constructor(vZ){super(vZ,{}),this.implementation=vZ}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(wZ){this.implementation.onAdd&&this.implementation.onAdd(wZ,wZ.painter.context.gl)}onRemove(xZ){this.implementation.onRemove&&this.implementation.onRemove(xZ,xZ.painter.context.gl)}}var yZ={paint:new As({"sky-type":new qr(oc.paint_sky["sky-type"]),"sky-atmosphere-sun":new qr(oc.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new qr(oc.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new qr(oc.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new qr(oc.paint_sky["sky-gradient-radius"]),"sky-gradient":new us(oc.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new qr(oc.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new qr(oc.paint_sky["sky-atmosphere-color"]),"sky-opacity":new qr(oc.paint_sky["sky-opacity"])})};function zZ(a,b,c){var d,e,f,g,h,i,j,k,l;const m=v(0,0,1),n=L(K());return d=n,e=n,f=c?-Q(a)+Math.PI:Q(a),f*=.5,g=e[0],h=e[1],i=e[2],j=e[3],k=Math.sin(f),l=Math.cos(f),d[0]=g*l-i*k,d[1]=h*l+j*k,d[2]=i*l+g*k,d[3]=j*l-h*k,M(n,n,-Q(b)),G(m,m,n),C(m,m)}const AZ={circle:class extends eG{constructor(a){super(a,XI)}createBucket(b){return new WH(b)}queryRadius(c){const d=c;return SI("circle-radius",this,d)+SI("circle-stroke-width",this,d)+TI(this.paint.get("circle-translate"))}queryIntersectsFeature(e,f,g,h,i,j,k,l){const m=VI(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),j.angle,e.pixelToTileUnitsFactor),n=this.paint.get("circle-radius").evaluate(f,g)+this.paint.get("circle-stroke-width").evaluate(f,g);return FJ(e,h,j,k,l,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),m,n)}getProgramIds(){return["circle"]}getProgramConfiguration(o){return new fE(this,o)}},heatmap:class extends eG{createBucket(a){return new KJ(a)}constructor(b){super(b,gK),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(c){"heatmap-color"===c&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=hK({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(d){return SI("heatmap-radius",this,d)}queryIntersectsFeature(e,f,h,i,j,k,l,m){const n=this.paint.get("heatmap-radius").evaluate(f,h);return FJ(e,i,k,l,m,!0,!0,new g(0,0),n)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(o){return new fE(this,o)}},hillshade:class extends eG{constructor(a){super(a,iK)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(b){return new fE(this,b)}},fill:class extends eG{constructor(a){super(a,RL)}getProgramIds(){const b=this.paint.get("fill-pattern"),c=b&&b.constantOr(1),d=[c?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&d.push(c&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),d}getProgramConfiguration(e){return new fE(this,e)}recalculate(f,g){super.recalculate(f,g);const h=this.paint._values["fill-outline-color"];"constant"===h.value.kind&& void 0===h.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new UK(i)}queryRadius(){return TI(this.paint.get("fill-translate"))}queryIntersectsFeature(j,k,l,m,n,o){return!j.queryGeometry.isAboveHorizon&&II(UI(j.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,j.pixelToTileUnitsFactor),m)}isTileClipped(){return!0}},"fill-extrusion":class extends eG{constructor(a){super(a,NN)}createBucket(b){return new vM(b)}queryRadius(){return TI(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(c){return new fE(this,c)}queryIntersectsFeature(d,e,f,h,i,j,k,l,m){var n,o,p,q,r,s,t,u,v;const w=VI(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),j.angle,d.pixelToTileUnitsFactor),x=this.paint.get("fill-extrusion-height").evaluate(e,f),y=this.paint.get("fill-extrusion-base").evaluate(e,f),z=[0,0],A=l&&j.elevation,B=j.elevation?j.elevation.exaggeration():1;if(A){const C=d.tile.getBucket(this).centroidVertexArray,D=m+1;if(D=3){for(let f=0;f1&&(y$=r$[++x$]);const A$=Math.abs(z$-y$.left),B$=Math.abs(z$-y$.right),C$=Math.min(A$,B$);let D$;const E$=v$/t$*(u$+1);if(y$.isDash){const F$=u$-Math.abs(E$);D$=Math.sqrt(C$*C$+F$*F$)}else D$=u$-Math.sqrt(C$*C$+E$*E$);this.image.data[w$+z$]=Math.max(0,Math.min(255,D$+128))}}}addRegularDash(G$,H$){for(let I$=G$.length-1;I$>=0;--I$){const J$=G$[I$],K$=G$[I$+1];J$.zeroLength?G$.splice(I$,1):K$&&K$.isDash===J$.isDash&&(K$.left=J$.left,G$.splice(I$,1))}const L$=G$[0],M$=G$[G$.length-1];L$.isDash===M$.isDash&&(L$.left=M$.left-this.width,M$.right=L$.right+this.width);const N$=this.width*this.nextRow;let O$=0,P$=G$[O$];for(let Q$=0;Q$1&&(P$=G$[++O$]);const R$=Math.abs(Q$-P$.left),S$=Math.abs(Q$-P$.right),T$=Math.min(R$,S$);this.image.data[N$+Q$]=Math.max(0,Math.min(255,(P$.isDash?T$:-T$)+H$+128))}}addDash(U$,V$){const W$=this.getKey(U$,V$);if(this.positions[W$])return this.positions[W$];const X$="round"===V$,Y$=X$?7:0,Z$=2*Y$+1;if(this.nextRow+Z$>this.height)return la("LineAtlas out of space"),null;0===U$.length&&U$.push(1);let $$=0;for(let _$=0;_$0;f--)e+=(b&(d=1<this.canonical.z?new y_(F_,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new y_(F_,this.wrap,F_,this.canonical.x>>G_,this.canonical.y>>G_)}calculateScaledKey(H_,I_=!0){if(this.overscaledZ===H_&&I_)return this.key;if(H_>this.canonical.z)return S_(this.wrap*+I_,H_,this.canonical.z,this.canonical.x,this.canonical.y);{const J_=this.canonical.z-H_;return S_(this.wrap*+I_,H_,H_,this.canonical.x>>J_,this.canonical.y>>J_)}}isChildOf(K_){if(K_.wrap!==this.wrap)return!1;const L_=this.canonical.z-K_.canonical.z;return 0===K_.overscaledZ||K_.overscaledZ>L_&&K_.canonical.y===this.canonical.y>>L_}children(M_){if(this.overscaledZ>=M_)return[new y_(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const N_=this.canonical.z+1,O_=2*this.canonical.x,P_=2*this.canonical.y;return[new y_(N_,this.wrap,N_,O_,P_),new y_(N_,this.wrap,N_,O_+1,P_),new y_(N_,this.wrap,N_,O_,P_+1),new y_(N_,this.wrap,N_,O_+1,P_+1)]}isLessThan(Q_){return this.wrapQ_.wrap)&&(this.overscaledZQ_.overscaledZ)&&(this.canonical.xQ_.canonical.x)&&this.canonical.yMath.abs(d[g])){if(c[g]b[g])return null}else{const h=1/d[g];let i=(a[g]-c[g])*h,j=(b[g]-c[g])*h;if(i>j){const k=i;i=j,j=k}if(i>e&&(e=i),jf)return null}return e}function J0(a,b,c,d,e,f,g,h,i,j,k){const l=d-a,m=e-b,n=f-c,o=g-a,p=h-b,q=i-c,r=k[1]*q-k[2]*p,s=k[2]*o-k[0]*q,t=k[0]*p-k[1]*o,u=l*r+m*s+n*t;if(1e-15>Math.abs(u))return null;const v=1/u,w=j[0]-a,x=j[1]-b,y=j[2]-c,z=(w*r+x*s+y*t)*v;if(z<0||z>1)return null;const A=x*n-y*m,B=y*l-w*n,C=w*m-x*l,D=(k[0]*A+k[1]*B+k[2]*C)*v;return D<0||z+D>1?null:(o*A+p*B+q*C)*v}function K0(a,b,c){return(a-b)/(c-b)}function L0(a,b,c,d,e,f,g,h,i){const j=1<{const f=d?1:0,g=(a+1)*c-f,h=b*c,i=(b+1)*c-f;e[0]=a*c,e[1]=h,e[2]=g,e[3]=i};let g=new z0(d);const h=[];for(let i=0;i=1;d/=2){const n=c[c.length-1];g=new z0(d);for(let o=0;o0;){const{idx:j1,t:k1,nodex:l1,nodey:m1,depth:n1}=i1.pop();if(this.leaves[j1]){L0(l1,m1,n1,Y0,Z0,$0,_0,g1,h1);const o1=1<=A1[2])return k1}continue}let B1=0;for(let C1=0;C1=e1[f1[G1]]&&(f1.splice(G1,0,C1),F1=!0);F1||(f1[B1]=C1),B1++}}for(let H1=0;H1=this.dim+1||s2< -1||s2>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(s2+1)*this.stride+(r2+1)}_unpackMapbox(t2,u2,v2){return(256*t2*256+256*u2+v2)/10-1e4}_unpackTerrarium(w2,x2,y2){return 256*w2+x2+y2/256-32768}static pack(z2,A2){const B2=[0,0,0,0],C2=d2.getUnpackVector(A2);let D2=Math.floor((z2+C2[3])/C2[2]);return B2[2]=D2%256,D2=Math.floor(D2/256),B2[1]=D2%256,D2=Math.floor(D2/256),B2[0]=D2,B2}getPixels(){return new XJ({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(E2,F2,G2){if(this.dim!==E2.dim)throw new Error("dem dimension mismatch");let H2=F2*this.dim,I2=F2*this.dim+this.dim,J2=G2*this.dim,K2=G2*this.dim+this.dim;switch(F2){case -1:H2=I2-1;break;case 1:I2=H2+1}switch(G2){case -1:J2=K2-1;break;case 1:K2=J2+1}const L2=-F2*this.dim,M2=-G2*this.dim;for(let N2=J2;N2{"source"===a.dataType&&"metadata"===a.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===a.dataType&&"content"===a.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),R2.on("error",()=>{this._sourceErrored=!0}),this._source=R2,this._tiles={},this._cache=new class{constructor(a,b){this.max=a,this.onRemove=b,this.reset()}reset(){for(const c in this.data)for(const d of this.data[c])d.timeout&&clearTimeout(d.timeout),this.onRemove(d.value);return this.data={},this.order=[],this}add(e,f,g){const h=e.wrapped().key;void 0===this.data[h]&&(this.data[h]=[]);const i={value:f,timeout:void 0};if(void 0!==g&&(i.timeout=setTimeout(()=>{this.remove(e,i)},g)),this.data[h].push(i),this.order.push(h),this.order.length>this.max){const j=this._getAndRemoveByKey(this.order[0]);j&&this.onRemove(j)}return this}has(k){return k.wrapped().key in this.data}getAndRemove(l){return this.has(l)?this._getAndRemoveByKey(l.wrapped().key):null}_getAndRemoveByKey(m){const n=this.data[m].shift();return n.timeout&&clearTimeout(n.timeout),0===this.data[m].length&&delete this.data[m],this.order.splice(this.order.indexOf(m),1),n.value}getByKey(o){const p=this.data[o];return p?p[0].value:null}get(q){return this.has(q)?this.data[q.wrapped().key][0].value:null}remove(r,s){if(!this.has(r))return this;const t=r.wrapped().key,u=void 0===s?0:this.data[t].indexOf(s),v=this.data[t][u];return this.data[t].splice(u,1),v.timeout&&clearTimeout(v.timeout),0===this.data[t].length&&delete this.data[t],this.onRemove(v.value),this.order.splice(this.order.indexOf(t),1),this}setMaxSize(w){for(this.max=w;this.order.length>this.max;){const x=this._getAndRemoveByKey(this.order[0]);x&&this.onRemove(x)}return this}filter(y){const z=[];for(const A in this.data)for(const B of this.data[A])y(B.value)||z.push(B);for(const C of z)this.remove(C.value.tileID,C)}}(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new class{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(a,b,c){const d=String(b);if(this.stateChanges[a]=this.stateChanges[a]||{},this.stateChanges[a][d]=this.stateChanges[a][d]||{},_(this.stateChanges[a][d],c),null===this.deletedStates[a])for(const e in this.deletedStates[a]={},this.state[a])e!==d&&(this.deletedStates[a][e]=null);else if(this.deletedStates[a]&&null===this.deletedStates[a][d])for(const f in this.deletedStates[a][d]={},this.state[a][d])c[f]||(this.deletedStates[a][d][f]=null);else for(const g in c)this.deletedStates[a]&&this.deletedStates[a][d]&&null===this.deletedStates[a][d][g]&&delete this.deletedStates[a][d][g]}removeFeatureState(h,i,j){if(null===this.deletedStates[h])return;const k=String(i);if(this.deletedStates[h]=this.deletedStates[h]||{},j&& void 0!==i)null!==this.deletedStates[h][k]&&(this.deletedStates[h][k]=this.deletedStates[h][k]||{},this.deletedStates[h][k][j]=null);else if(void 0!==i)if(this.stateChanges[h]&&this.stateChanges[h][k])for(j in this.deletedStates[h][k]={},this.stateChanges[h][k])this.deletedStates[h][k][j]=null;else this.deletedStates[h][k]=null;else this.deletedStates[h]=null}getState(l,m){const n=String(m),o=_({},(this.state[l]||{})[n],(this.stateChanges[l]||{})[n]);if(null===this.deletedStates[l])return{};if(this.deletedStates[l]){const p=this.deletedStates[l][m];if(null===p)return{};for(const q in p)delete o[q]}return o}initializeTileState(r,s){r.setFeatureState(this.state,s)}coalesceChanges(t,u){const v={};for(const w in this.stateChanges){this.state[w]=this.state[w]||{};const x={};for(const y in this.stateChanges[w])this.state[w][y]||(this.state[w][y]={}),_(this.state[w][y],this.stateChanges[w][y]),x[y]=this.state[w][y];v[w]=x}for(const z in this.deletedStates){this.state[z]=this.state[z]||{};const A={};if(null===this.deletedStates[z])for(const B in this.state[z])A[B]={},this.state[z][B]={};else for(const C in this.deletedStates[z]){if(null===this.deletedStates[z][C])this.state[z][C]={};else for(const D of Object.keys(this.deletedStates[z][C]))delete this.state[z][C][D];A[C]=this.state[z][C]}v[z]=v[z]||{},_(v[z],A)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(v).length)for(const E in t)t[E].setFeatureState(v,u)}}}onAdd(T2){this.map=T2,this._minTileCacheSize=T2?T2._minTileCacheSize:null,this._maxTileCacheSize=T2?T2._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const U2 in this._tiles){const V2=this._tiles[U2];if("loaded"!==V2.state&&"errored"!==V2.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const W2=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,W2&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(X2,Y2){return X2.isSymbolTile=this._onlySymbols,this._source.loadTile(X2,Y2)}_unloadTile(Z2){if(this._source.unloadTile)return this._source.unloadTile(Z2,()=>{})}_abortTile($2){if(this._source.abortTile)return this._source.abortTile($2,()=>{})}serialize(){return this._source.serialize()}prepare(_2){for(const a3 in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const b3=this._tiles[a3];b3.upload(_2),b3.prepare(this.map.style.imageManager)}}getIds(){return $(this._tiles).map(a=>a.tileID).sort(U5).map(a=>a.key)}getRenderableIds(c3){const d3=[];for(const e3 in this._tiles)this._isIdRenderable(+e3,c3)&&d3.push(this._tiles[e3]);return c3?d3.sort((a,b)=>{const c=a.tileID,d=b.tileID,e=new g(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),f=new g(d.canonical.x,d.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-d.overscaledZ||f.y-e.y||f.x-e.x}).map(a=>a.tileID.key):d3.map(a=>a.tileID).sort(U5).map(a=>a.key)}hasRenderableParent(f3){const g3=this.findLoadedParent(f3,0);return!!g3&&this._isIdRenderable(g3.tileID.key)}_isIdRenderable(h3,i3){return this._tiles[h3]&&this._tiles[h3].hasData()&&!this._coveredTiles[h3]&&(i3||!this._tiles[h3].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const j3 in this._cache.reset(),this._tiles)"errored"!==this._tiles[j3].state&&this._reloadTile(+j3,"reloading")}_reloadTile(k3,l3){const m3=this._tiles[k3];m3&&("loading"!==m3.state&&(m3.state=l3),this._loadTile(m3,this._tileLoaded.bind(this,m3,k3,l3)))}_tileLoaded(n3,o3,p3,q3){if(q3)if(n3.state="errored",404!==q3.status)this._source.fire(new Vb(q3,{tile:n3}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const r3=this.map.painter.terrain;this.update(this.transform,r3.getScaledDemTileSize(),!0),r3.resetTileLookupCache(this.id)}else this.update(this.transform);else n3.timeAdded=wa.now(),"expired"===p3&&(n3.refreshedUponExpiration=!0),this._setTileReloadTimer(o3,n3),"raster-dem"===this._source.type&&n3.dem&&this._backfillDEM(n3),this._state.initializeTileState(n3,this.map?this.map.painter:null),this._source.fire(new Sb("data",{dataType:"source",tile:n3,coord:n3.tileID,sourceCacheId:this.id}))}_backfillDEM(s3){const t3=this.getRenderableIds();for(let u3=0;u31||(Math.abs(c)>1&&(1===Math.abs(c+e)?c+=e:1===Math.abs(c-e)&&(c-=e)),b.dem&&a.dem&&(a.dem.backfillBorder(b.dem,c,d),a.neighboringTiles&&a.neighboringTiles[f]&&(a.neighboringTiles[f].backfilled=!0)))}}getTile(y3){return this.getTileByID(y3.key)}getTileByID(z3){return this._tiles[z3]}_retainLoadedChildren(A3,B3,C3,D3){for(const E3 in this._tiles){let F3=this._tiles[E3];if(D3[E3]||!F3.hasData()||F3.tileID.overscaledZ<=B3||F3.tileID.overscaledZ>C3)continue;let G3=F3.tileID;for(;F3&&F3.tileID.overscaledZ>B3+1;){const H3=F3.tileID.scaledTo(F3.tileID.overscaledZ-1);(F3=this._tiles[H3.key])&&F3.hasData()&&(G3=H3)}let I3=G3;for(;I3.overscaledZ>B3;)if(A3[(I3=I3.scaledTo(I3.overscaledZ-1)).key]){D3[G3.key]=G3;break}}}findLoadedParent(J3,K3){if(J3.key in this._loadedParentTiles){const L3=this._loadedParentTiles[J3.key];return L3&&L3.tileID.overscaledZ>=K3?L3:null}for(let M3=J3.overscaledZ-1;M3>=K3;M3--){const N3=J3.scaledTo(M3),O3=this._getLoadedTile(N3);if(O3)return O3}}_getLoadedTile(P3){const Q3=this._tiles[P3.key];return Q3&&Q3.hasData()?Q3:this._cache.getByKey(this._source.reparseOverscaled?P3.wrapped().key:P3.canonical.key)}updateCacheSize(R3,S3){S3=S3||this._source.tileSize;const T3=Math.ceil(R3.width/S3)+1,U3=Math.ceil(R3.height/S3)+1,V3=Math.floor(T3*U3*5),W3="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,V3):V3,X3="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,W3):W3;this._cache.setMaxSize(X3)}handleWrapJump(Y3){const Z3=Math.round((Y3-(void 0===this._prevLng?Y3:this._prevLng))/360);if(this._prevLng=Y3,Z3){const $3={};for(const _3 in this._tiles){const a4=this._tiles[_3];a4.tileID=a4.tileID.unwrapTo(a4.tileID.wrap+Z3),$3[a4.tileID.key]=a4}for(const b4 in this._tiles=$3,this._timers)clearTimeout(this._timers[b4]),delete this._timers[b4];for(const c4 in this._tiles)this._setTileReloadTimer(+c4,this._tiles[c4])}}update(d4,e4,f4){if(this.transform=d4,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!f4)return;let g4;this.updateCacheSize(d4,e4),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?g4=d4.getVisibleUnwrappedCoordinates(this._source.tileID).map(a=>new y_(a.canonical.z,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y)):(g4=d4.coveringTiles({tileSize:e4||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!f4,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(g4=g4.filter(a=>this._source.hasTile(a)))):g4=[];const h4=this._updateRetainedTiles(g4);if(V5(this._source.type)&&0!==g4.length){const i4={},j4={},k4=Object.keys(h4);for(const l4 of k4){const m4=h4[l4],n4=this._tiles[l4];if(!n4||n4.fadeEndTime&&n4.fadeEndTime<=wa.now())continue;const o4=this.findLoadedParent(m4,Math.max(m4.overscaledZ-P2.maxOverzooming,this._source.minzoom));o4&&(this._addTile(o4.tileID),i4[o4.tileID.key]=o4.tileID),j4[l4]=m4}const p4=g4[g4.length-1].overscaledZ;for(const q4 in this._tiles){const r4=this._tiles[q4];if(h4[q4]||!r4.hasData())continue;let s4=r4.tileID;for(;s4.overscaledZ>p4;){s4=s4.scaledTo(s4.overscaledZ-1);const t4=this._tiles[s4.key];if(t4&&t4.hasData()&&j4[s4.key]){h4[q4]=r4.tileID;break}}}for(const u4 in i4)h4[u4]||(this._coveredTiles[u4]=!0,h4[u4]=i4[u4])}for(const v4 in h4)this._tiles[v4].clearFadeHold();const w4=function(a,b){const c=[];for(const d in a)d in b||c.push(d);return c}(this._tiles,h4);for(const x4 of w4){const y4=this._tiles[x4];y4.hasSymbolBuckets&&!y4.holdingForFade()?y4.setHoldDuration(this.map._fadeDuration):y4.hasSymbolBuckets&&!y4.symbolFadeFinished()||this._removeTile(+x4)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const z4 in this._tiles)this._tiles[z4].holdingForFade()&&this._removeTile(+z4)}_updateRetainedTiles(A4){const B4={};if(0===A4.length)return B4;const C4={},D4=A4.reduce((a,b)=>Math.min(a,b.overscaledZ),1/0),E4=A4[0].overscaledZ,F4=Math.max(E4-P2.maxOverzooming,this._source.minzoom),G4=Math.max(E4+P2.maxUnderzooming,this._source.minzoom),H4={};for(const I4 of A4){const J4=this._addTile(I4);B4[I4.key]=I4,J4.hasData()||D4=this._source.maxzoom){const M4=K4.children(this._source.maxzoom)[0],N4=this.getTile(M4);if(N4&&N4.hasData()){B4[M4.key]=M4;continue}}else{const O4=K4.children(this._source.maxzoom);if(B4[O4[0].key]&&B4[O4[1].key]&&B4[O4[2].key]&&B4[O4[3].key])continue}let P4=L4.wasRequested();for(let Q4=K4.overscaledZ-1;Q4>=F4;--Q4){const R4=K4.scaledTo(Q4);if(C4[R4.key])break;if(C4[R4.key]=!0,(L4=this.getTile(R4))||!P4||(L4=this._addTile(R4)),L4&&(B4[R4.key]=R4,P4=L4.wasRequested(),L4.hasData()))break}}return B4}_updateLoadedParentTileCache(){for(const S4 in this._loadedParentTiles={},this._tiles){const T4=[];let U4,V4=this._tiles[S4].tileID;for(;V4.overscaledZ>0;){if(V4.key in this._loadedParentTiles){U4=this._loadedParentTiles[V4.key];break}T4.push(V4.key);const W4=V4.scaledTo(V4.overscaledZ-1);if(U4=this._getLoadedTile(W4))break;V4=W4}for(const X4 of T4)this._loadedParentTiles[X4]=U4}}_addTile(Y4){let Z4=this._tiles[Y4.key];if(Z4)return Z4;(Z4=this._cache.getAndRemove(Y4))&&(this._setTileReloadTimer(Y4.key,Z4),Z4.tileID=Y4,this._state.initializeTileState(Z4,this.map?this.map.painter:null),this._cacheTimers[Y4.key]&&(clearTimeout(this._cacheTimers[Y4.key]),delete this._cacheTimers[Y4.key],this._setTileReloadTimer(Y4.key,Z4)));const $4=Boolean(Z4);if(!$4){const _4=this.map?this.map.painter:null,a5="raster"===this._source.type||"raster-dem"===this._source.type;Z4=new s8(Y4,this._source.tileSize*Y4.overscaleFactor(),this.transform.tileZoom,_4,a5),this._loadTile(Z4,this._tileLoaded.bind(this,Z4,Y4.key,Z4.state))}return Z4?(Z4.uses++,this._tiles[Y4.key]=Z4,$4||this._source.fire(new Sb("dataloading",{tile:Z4,coord:Z4.tileID,dataType:"source"})),Z4):null}_setTileReloadTimer(b5,c5){b5 in this._timers&&(clearTimeout(this._timers[b5]),delete this._timers[b5]);const d5=c5.getExpiryTimeout();d5&&(this._timers[b5]=setTimeout(()=>{this._reloadTile(b5,"expired"),delete this._timers[b5]},d5))}_removeTile(e5){const f5=this._tiles[e5];f5&&(f5.uses--,delete this._tiles[e5],this._timers[e5]&&(clearTimeout(this._timers[e5]),delete this._timers[e5]),f5.uses>0||(f5.hasData()&&"reloading"!==f5.state?this._cache.add(f5.tileID,f5,f5.getExpiryTimeout()):(f5.aborted=!0,this._abortTile(f5),this._unloadTile(f5))))}clearTiles(){for(const g5 in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+g5);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(h5,i5,j5){const k5=[],l5=this.transform;if(!l5)return k5;for(const m5 in this._tiles){const n5=this._tiles[m5];if(j5&&n5.clearQueryDebugViz(),n5.holdingForFade())continue;const o5=h5.containsTile(n5,l5,i5);o5&&k5.push(o5)}return k5}getVisibleCoordinates(p5){const q5=this.getRenderableIds(p5).map(a=>this._tiles[a].tileID);for(const r5 of q5)r5.projMatrix=this.transform.calculateProjMatrix(r5.toUnwrapped());return q5}hasTransition(){if(this._source.hasTransition())return!0;if(V5(this._source.type))for(const s5 in this._tiles){const t5=this._tiles[s5];if(void 0!==t5.fadeEndTime&&t5.fadeEndTime>=wa.now())return!0}return!1}setFeatureState(u5,v5,w5){this._state.updateState(u5=u5||"_geojsonTileLayer",v5,w5)}removeFeatureState(x5,y5,z5){this._state.removeFeatureState(x5=x5||"_geojsonTileLayer",y5,z5)}getFeatureState(A5,B5){return this._state.getState(A5=A5||"_geojsonTileLayer",B5)}setDependencies(C5,D5,E5){const F5=this._tiles[C5];F5&&F5.setDependencies(D5,E5)}reloadTilesForDependencies(G5,H5){for(const I5 in this._tiles)this._tiles[I5].hasDependency(G5,H5)&&this._reloadTile(+I5,"reloading");this._cache.filter(a=>!a.hasDependency(G5,H5))}_preloadTiles(J5,K5){const L5=new Map,M5=Array.isArray(J5)?J5:[J5],N5=this.map.painter.terrain,O5=this.usedForTerrain&&N5?N5.getScaledDemTileSize():this._source.tileSize;for(const P5 of M5){const Q5=P5.coveringTiles({tileSize:O5,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const R5 of Q5)L5.set(R5.key,R5);this.usedForTerrain&&P5.updateElevation(!1)}const S5=Array.from(L5.values()),T5="raster"===this._source.type||"raster-dem"===this._source.type;Z(S5,(a,b)=>{const c=new s8(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,this.map.painter,T5);this._loadTile(c,a=>{"raster-dem"===this._source.type&&c.dem&&this._backfillDEM(c),b(a,c)})},K5)}}function U5(a,b){const c=Math.abs(2*a.wrap)- +(a.wrap<0),d=Math.abs(2*b.wrap)- +(b.wrap<0);return a.overscaledZ-b.overscaledZ||d-c||b.canonical.y-a.canonical.y||b.canonical.x-a.canonical.x}function V5(a){return"raster"===a||"image"===a||"video"===a}P2.maxOverzooming=10,P2.maxUnderzooming=3;class W5{constructor(X5,Y5,Z5){this._demTile=X5,this._dem=this._demTile.dem,this._scale=Y5,this._offset=Z5}static create($5,_5,a6){const b6=a6||$5.findDEMTileFor(_5);if(!b6||!b6.dem)return;const c6=b6.dem,d6=b6.tileID,e6=1<<_5.canonical.z-d6.canonical.z;return new W5(b6,b6.tileSize/8192/e6,[(_5.canonical.x/e6-d6.canonical.x)*c6.dim,(_5.canonical.y/e6-d6.canonical.y)*c6.dim])}tileCoordToPixel(f6,g6){const h6=g6*this._scale+this._offset[1],i6=Math.floor(f6*this._scale+this._offset[0]);return new g(i6,Math.floor(h6))}getElevationAt(j6,k6,l6,m6){const n6=j6*this._scale+this._offset[0],o6=k6*this._scale+this._offset[1],p6=Math.floor(n6),q6=Math.floor(o6),r6=this._dem;return m6=!!m6,l6?di(di(r6.get(p6,q6,m6),r6.get(p6,q6+1,m6),o6-q6),di(r6.get(p6+1,q6,m6),r6.get(p6+1,q6+1,m6),o6-q6),n6-p6):r6.get(p6,q6,m6)}getElevationAtPixel(s6,t6,u6){return this._dem.get(s6,t6,!!u6)}getMeterToDEM(v6){return(1<=0&&J6[3]>=0&&G6.insert(F6,J6[0],J6[1],J6[2],J6[3])}}loadVTLayers(){if(!this.vtLayers)for(const M6 in this.vtLayers=new bM.VectorTile(new NQ(this.rawTileData)).layers,this.sourceLayerCoder=new k0(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[M6]=[];return this.vtLayers}query(N6,O6,P6,Q6){this.loadVTLayers();const R6=N6.params||{},S6=ko(R6.filter),T6=N6.tileResult,U6=N6.transform,V6=T6.bufferedTilespaceBounds,W6=this.grid.query(V6.min.x,V6.min.y,V6.max.x,V6.max.y,(a,b,c,d)=>QI(T6.bufferedTilespaceGeometry,a,b,c,d));W6.sort($7);let X6=null;U6.elevation&&W6.length>0&&(X6=W5.create(U6.elevation,this.tileID));const Y6={};let Z6;for(let $6=0;$6(b7||(b7=TH(a,this.tileID.canonical,N6.tileTransform)),b.queryIntersectsFeature(T6,a,c,b7,this.z,N6.transform,N6.pixelPosMatrix,X6,d)))}return Y6}loadMatchingFeature(c7,d7,e7,f7,g7,h7,i7,j7,k7){const{featureIndex:l7,bucketIndex:m7,sourceLayerIndex:n7,layoutVertexArrayOffset:o7}=d7,p7=this.bucketLayerIDs[m7];if(f7&&!function(a,b){for(let c=0;c=0)return!0;return!1}(f7,p7))return;const q7=this.sourceLayerCoder.decode(n7),r7=this.vtLayers[q7].feature(l7);if(e7.needGeometry){const s7=UH(r7,!0);if(!e7.filter(new aq(this.tileID.overscaledZ),s7,this.tileID.canonical))return}else if(!e7.filter(new aq(this.tileID.overscaledZ),r7))return;const t7=this.getId(r7,q7);for(let u7=0;u7f7.indexOf(v7))continue;const w7=h7[v7];if(!w7)continue;let x7={};void 0!==t7&&j7&&(x7=j7.getState(w7.sourceLayer||"_geojsonTileLayer",t7));const y7=_({},i7[v7]);y7.paint=Z7(y7.paint,w7.paint,r7,x7,g7),y7.layout=Z7(y7.layout,w7.layout,r7,x7,g7);const z7=!k7||k7(r7,w7,x7,o7);if(!z7)continue;const A7=new q0(r7,this.z,this.x,this.y,t7);A7.layer=y7;let B7=c7[v7];void 0===B7&&(B7=c7[v7]=[]),B7.push({featureIndex:l7,feature:A7,intersectionZ:z7})}}lookupSymbolFeatures(C7,D7,E7,F7,G7,H7,I7,J7){const K7={};this.loadVTLayers();const L7=ko(G7);for(const M7 of C7)this.loadMatchingFeature(K7,{bucketIndex:E7,sourceLayerIndex:F7,featureIndex:M7,layoutVertexArrayOffset:0},L7,H7,I7,J7,D7);return K7}loadFeature(N7){const{featureIndex:O7,sourceLayerIndex:P7}=N7;this.loadVTLayers();const Q7=this.sourceLayerCoder.decode(P7),R7=this.vtFeatures[Q7];if(R7[O7])return R7[O7];const S7=this.vtLayers[Q7].feature(O7);return R7[O7]=S7,S7}hasLayer(T7){for(const U7 of this.bucketLayerIDs)for(const V7 of U7)if(T7===V7)return!0;return!1}getId(W7,X7){let Y7=W7.id;return this.promoteId&&"boolean"==typeof(Y7=W7.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[X7]])&&(Y7=Number(Y7)),Y7}}function Z7(a,b,c,d,e){return ha(a,(a,f)=>{const g=b instanceof nr?b.get(f):null;return g&&g.evaluate?g.evaluate(c,d,e):g})}function $7(a,b){return b-a}Zo("FeatureIndex",w6,{omit:["rawTileData","sourceLayerCoder"]});var _7=Ts([{name:"a_pos",type:"Int16",components:2}]);const a8=new Uint16Array(8184);for(let b8=0;b8<2046;b8++){let c8=b8+2,d8=0,e8=0,f8=0,g8=0,h8=0,i8=0;for(1&c8?f8=g8=h8=32:d8=e8=i8=32;(c8>>=1)>1;){const j8=d8+f8>>1,k8=e8+g8>>1;1&c8?(f8=d8,g8=e8,d8=h8,e8=i8):(d8=f8,e8=g8,f8=h8,g8=i8),h8=j8,i8=k8}const l8=4*b8;a8[l8+0]=d8,a8[l8+1]=e8,a8[l8+2]=f8,a8[l8+3]=g8}const m8=new Uint16Array(2178),n8=new Uint8Array(1089),o8=new Uint16Array(1089);function p8(a){return 0===a?-0.03125:32===a?.03125:0}var q8=Ts([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const r8={type:2,extent:8192,loadGeometry:()=>[[new g(0,0),new g(8193,0),new g(8193,8193),new g(0,8193),new g(0,0)]]};class s8{constructor(t8,u8,v8,w8,x8){this.tileID=t8,this.uid=ba(),this.uses=0,this.tileSize=u8,this.tileZoom=v8,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=x8,this.expiredRequestCount=0,this.state="loading",w8&&w8.transform&&(this.projection=w8.transform.projection)}registerFadeDuration(y8){const z8=y8+this.timeAdded;z8b.getLayer(a)).filter(Boolean);if(0!==e.length)for(const f of(d.layers=e,d.stateDependentLayerIds&&(d.stateDependentLayers=d.stateDependentLayerIds.map(a=>e.filter(b=>b.id===a)[0])),e))c[f.id]=d}return c})(A8.buckets,B8.style),this.hasSymbolBuckets=!1,this.buckets){const E8=this.buckets[D8];if(E8 instanceof EU){if(this.hasSymbolBuckets=!0,!C8)break;E8.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const F8 in this.buckets){const G8=this.buckets[F8];if(G8 instanceof EU&&G8.hasRTLText){this.hasRTLText=!0,_p.isLoading()||_p.isLoaded()||"deferred"!==Zp()||$p();break}}for(const H8 in this.queryPadding=0,this.buckets){const I8=this.buckets[H8];this.queryPadding=Math.max(this.queryPadding,B8.style.getLayer(H8).queryRadius(I8))}A8.imageAtlas&&(this.imageAtlas=A8.imageAtlas),A8.glyphAtlasImage&&(this.glyphAtlasImage=A8.glyphAtlasImage),A8.lineAtlas&&(this.lineAtlas=A8.lineAtlas)}else this.collisionBoxArray=new DA}unloadVectorData(){if(this.hasData()){for(const J8 in this.buckets)this.buckets[J8].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(K8){return this.buckets[K8.id]}upload(L8){for(const M8 in this.buckets){const N8=this.buckets[M8];N8.uploadPending()&&N8.upload(L8)}const O8=L8.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new GZ(L8,this.imageAtlas.image,O8.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new GZ(L8,this.glyphAtlasImage,O8.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new GZ(L8,this.lineAtlas.image,O8.ALPHA),this.lineAtlas.uploaded=!0)}prepare(P8){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(P8,this.imageAtlasTexture)}queryRenderedFeatures(Q8,R8,S8,T8,U8,V8,W8,X8){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:T8,pixelPosMatrix:W8,transform:V8,params:U8,tileTransform:this.tileTransform},Q8,R8,S8):{}}querySourceFeatures(Y8,Z8){const $8=this.latestFeatureIndex;if(!$8||!$8.rawTileData)return;const _8=$8.loadVTLayers(),a9=Z8?Z8.sourceLayer:"",b9=_8._geojsonTileLayer||_8[a9];if(!b9)return;const c9=ko(Z8&&Z8.filter),{z:d9,x:e9,y:f9}=this.tileID.canonical,g9={z:d9,x:e9,y:f9};for(let h9=0;h9p9)q9=!1;else if(n9)if(this.expirationTime=0;k--){const l=4*k,m=a8[l+0],n=a8[l+1],o=a8[l+2],p=a8[l+3],q=m+o>>1,r=n+p>>1,s=q+r-n,t=r+m-q,u=33*n+m,v=33*p+o,w=33*r+q,x=Math.hypot((m8[2*u+0]+m8[2*v+0])/2-m8[2*w+0],(m8[2*u+1]+m8[2*v+1])/2-m8[2*w+1])>=16;if(n8[w]=n8[w]||(x?1:0),k<1022){const y=(n+t>>1)*33+(m+s>>1),z=(p+t>>1)*33+(o+s>>1);n8[w]=n8[w]||n8[y]||n8[z]}}const A=new bt,B=new Rw;let C=0;function D(a,b){const c=33*b+a;return 0===o8[c]&&(A.emplaceBack(m8[2*c+0],m8[2*c+1],8192*a/32,8192*b/32),o8[c]=++C),o8[c]-1}function E(a,b,c,d,e,f){const g=a+c>>1,h=b+d>>1;if(Math.abs(a-e)+Math.abs(b-f)>1&&n8[33*h+g])E(e,f,a,b,g,h),E(c,d,e,f,g,h);else{const i=D(a,b),j=D(c,d),k=D(e,f);B.emplaceBack(i,j,k)}}return E(0,0,32,32,32,0),E(32,32,0,0,0,32),{vertices:A,indices:B}}(this.tileID.canonical,W9);Y9=$9.vertices,Z9=$9.indices}else{for(const{x:_9,y:aaa}of(Y9=new bt,Z9=new Rw,X9))Y9.emplaceBack(_9,aaa,0,0);const baa=lK(Y9.int16,void 0,4);for(let caa=0;caa{const c=65*b+a;eba.emplaceBack(c+1,c,c+65),eba.emplaceBack(c+65,c+65+1,c+1)};for(let gba=0;gba<64;gba++)for(let hba=0;hba<64;hba++)fba(hba,gba);return eba}getWirefameBuffer(iba){if(!this.wireframeSegments){const jba=this._createWireframeGrid();this.wireframeIndexBuffer=iba.createIndexBuffer(jba),this.wireframeSegments=PG.simpleSegment(0,0,4096,jba.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const kba=new Xz,lba=(a,b)=>{const c=65*b+a;kba.emplaceBack(c,c+1),kba.emplaceBack(c,c+65),kba.emplaceBack(c,c+65+1)};for(let mba=0;mba<64;mba++)for(let nba=0;nba<64;nba++)lba(nba,mba);return kba}}function oba(a,b){if(!b.isReprojectedInTileSpace)return{scale:1<t&&(u(a,j,d,e,h,i),u(j,c,h,i,f,g))}u(l,m,d,f,e,f),u(m,n,e,f,e,g),u(n,o,e,g,d,g),u(o,l,d,g,d,f),p-=t,q-=t,r+=t,s+=t;const v=1/Math.max(r-p,s-q);return{scale:v,x:p*v,y:q*v,x2:r*v,y2:s*v,projection:b}}class pba{constructor(qba){const rba={},sba=[];for(const tba in qba){const uba=qba[tba],vba=rba[tba]={};for(const wba in uba.glyphs){const xba=uba.glyphs[+wba];if(!xba||0===xba.bitmap.width||0===xba.bitmap.height)continue;const yba=xba.metrics.localGlyph?2:1,zba={x:0,y:0,w:xba.bitmap.width+2*yba,h:xba.bitmap.height+2*yba};sba.push(zba),vba[wba]=zba}}const{w:Aba,h:Bba}=gR(sba),Cba=new OJ({width:Aba||1,height:Bba||1});for(const Dba in qba){const Eba=qba[Dba];for(const Fba in Eba.glyphs){const Gba=Eba.glyphs[+Fba];if(!Gba||0===Gba.bitmap.width||0===Gba.bitmap.height)continue;const Hba=rba[Dba][Fba],Iba=Gba.metrics.localGlyph?2:1;OJ.copy(Gba.bitmap,Cba,{x:0,y:0},{x:Hba.x+Iba,y:Hba.y+Iba},Gba.bitmap)}}this.image=Cba,this.positions=rba}}Zo("GlyphAtlas",pba);class Jba{constructor(Kba){this.tileID=new y_(Kba.tileID.overscaledZ,Kba.tileID.wrap,Kba.tileID.canonical.z,Kba.tileID.canonical.x,Kba.tileID.canonical.y),this.tileZoom=Kba.tileZoom,this.uid=Kba.uid,this.zoom=Kba.zoom,this.canonical=Kba.tileID.canonical,this.pixelRatio=Kba.pixelRatio,this.tileSize=Kba.tileSize,this.source=Kba.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=Kba.showCollisionBoxes,this.collectResourceTiming=!!Kba.collectResourceTiming,this.returnDependencies=!!Kba.returnDependencies,this.promoteId=Kba.promoteId,this.enableTerrain=!!Kba.enableTerrain,this.isSymbolTile=Kba.isSymbolTile,this.tileTransform=oba(Kba.tileID.canonical,Kba.projection),this.projection=Kba.projection}parse(Lba,Mba,Nba,Oba,Pba){this.status="parsing",this.data=Lba,this.collisionBoxArray=new DA;const Qba=new k0(Object.keys(Lba.layers).sort()),Rba=new w6(this.tileID,this.promoteId);Rba.bucketLayerIDs=[];const Sba={},Tba=new ZZ(256,256),Uba={featureIndex:Rba,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:Tba,availableImages:Nba},Vba=Mba.familiesBySource[this.source];for(const Wba in Vba){const Xba=Lba.layers[Wba];if(!Xba)continue;let Yba=!1,Zba=!1;for(const $ba of Vba[Wba])"symbol"===$ba[0].type?Yba=!0:Zba=!0;if(!0===this.isSymbolTile&&!Yba)continue;if(!1===this.isSymbolTile&&!Zba)continue;1===Xba.version&&la(`Vector tile source "${this.source}" layer "${Wba}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const _ba=Qba.encode(Wba),aca=[];for(let bca=0;bca=fca.maxzoom||"none"!==fca.visibility&&(pca(eca,this.zoom,Nba),(Sba[fca.id]=fca.createBucket({index:Rba.bucketLayerIDs.length,layers:eca,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:_ba,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:Nba})).populate(aca,Uba,this.tileID.canonical,this.tileTransform),Rba.bucketLayerIDs.push(eca.map(a=>a.id)))}}let gca,hca,ica,jca;Tba.trim();const kca={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},lca=ha(Uba.glyphDependencies,a=>Object.keys(a).map(Number));Object.keys(lca).length?Oba.send("getGlyphs",{uid:this.uid,stacks:lca},(a,b)=>{gca||(gca=a,hca=b,oca.call(this))},void 0,!1,kca):hca={};const mca=Object.keys(Uba.iconDependencies);mca.length?Oba.send("getImages",{icons:mca,source:this.source,tileID:this.tileID,type:"icons"},(a,b)=>{gca||(gca=a,ica=b,oca.call(this))},void 0,!1,kca):ica={};const nca=Object.keys(Uba.patternDependencies);function oca(){if(gca)return Pba(gca);if(hca&&ica&&jca){const a=new pba(hca),b=new oR(ica,jca);for(const c in Sba){const d=Sba[c];d instanceof EU?(pca(d.layers,this.zoom,Nba),fU(d,hca,a.positions,ica,b.iconPositions,this.showCollisionBoxes,Nba,this.tileID.canonical,this.tileZoom,this.projection),d.projection=this.projection.name):d.hasPattern&&(d instanceof YN||d instanceof UK||d instanceof vM)&&(pca(d.layers,this.zoom,Nba),d.addFeatures(Uba,this.tileID.canonical,b.patternPositions,Nba))}this.status="done",Pba(null,{buckets:$(Sba).filter(a=>!a.isEmpty()),featureIndex:Rba,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:a.image,lineAtlas:Tba,imageAtlas:b,glyphMap:this.returnDependencies?hca:null,iconMap:this.returnDependencies?ica:null,glyphPositions:this.returnDependencies?a.positions:null})}}nca.length?Oba.send("getImages",{icons:nca,source:this.source,tileID:this.tileID,type:"patterns"},(a,b)=>{gca||(gca=a,jca=b,oca.call(this))},void 0,!1,kca):jca={},oca.call(this)}}function pca(a,b,c){const d=new aq(b);for(const e of a)e.recalculate(d,c)}class qca{constructor(rca){this.entries={},this.scheduler=rca}request(sca,tca,uca,vca){const wca=this.entries[sca]=this.entries[sca]||{callbacks:[]};if(wca.result){const[xca,yca]=wca.result;return this.scheduler?this.scheduler.add(()=>{vca(xca,yca)},tca):vca(xca,yca),()=>{}}return wca.callbacks.push(vca),wca.cancel||(wca.cancel=uca((a,b)=>{for(const c of(wca.result=[a,b],wca.callbacks))this.scheduler?this.scheduler.add(()=>{c(a,b)},tca):c(a,b);setTimeout(()=>delete this.entries[sca],3e3)})),()=>{wca.result||(wca.callbacks=wca.callbacks.filter(a=>a!==vca),wca.callbacks.length||(wca.cancel(),delete this.entries[sca]))}}}function zca(a,b,c){const d=JSON.stringify(a.request);return a.data&&(this.deduped.entries[d]={result:[null,a.data]}),this.deduped.request(d,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},b=>{const d=Ib(a.request,(a,d,e,f)=>{a?b(a):d&&b(null,{vectorTile:c?void 0:new bM.VectorTile(new NQ(d)),rawData:d,cacheControl:e,expires:f})});return()=>{d.cancel(),b()}},b)}const Aca=l(new Float64Array(16));class Bca{constructor(Cca,Dca){this._tr=Cca,this._worldSize=Dca}createInversionMatrix(){return Aca}createTileMatrix(Eca){let Fca,Gca,Hca;const Ica=Eca.canonical,Jca=l(new Float64Array(16)),Kca=this._tr.projection;if(Kca.isReprojectedInTileSpace){const Lca=oba(Ica,Kca);Fca=1,Gca=Lca.x+Eca.wrap*Lca.scale,Hca=Lca.y,o(Jca,Jca,[Fca/Lca.scale,Fca/Lca.scale,this._tr.pixelsPerMeter/this._worldSize])}else Fca=this._worldSize/this._tr.zoomScale(Ica.z),Gca=(Ica.x+Math.pow(2,Ica.z)*Eca.wrap)*Fca,Hca=Ica.y*Fca;return n(Jca,Jca,[Gca,Hca,0]),o(Jca,Jca,[Fca/8192,Fca/8192,1]),Jca}pointCoordinate(Mca,Nca,Oca){const Pca=this._tr.horizonLineFromTop(!1),Qca=new g(Mca,Math.max(Pca,Nca));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(Qca,Oca))}upVector(){return[0,0,1]}upVectorScale(){return 1}}var Rca={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&N(this.parallels,this.constants.parallels))return;const a=Math.sin(Q(this.parallels[0])),b=(a+Math.sin(Q(this.parallels[1])))/2,c=1+a*(2*b-a),d=Math.sqrt(c)/b;this.constants={n:b,c:c,r0:d,parallels:this.parallels}},project(a,b){this.initializeConstants();const c=Q(a-this.center[0]),d=Q(b),{n:e,c:f,r0:g}=this.constants,h=Math.sqrt(f-2*e*Math.sin(d))/e;return{x:h*Math.sin(c*e),y:h*Math.cos(c*e)-g,z:0}},unproject(a,b){this.initializeConstants();const{n:c,c:d,r0:e}=this.constants,f=e+b;let g=Math.atan2(a,Math.abs(f))*Math.sign(f);f*c<0&&(g-=Math.PI*Math.sign(a)*Math.sign(f));const h=Q(this.center[0])*c;g=Y(g,-Math.PI-h,Math.PI-h);const i=R(g/c)+this.center[0],j=Math.asin(W((d-(a*a+f*f)*c*c)/(2*c),-1,1)),k=W(R(j),-85.051129,85.051129);return new pH(i,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>FH(1,a)*b,farthestPixelDistance(a){return gaa(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new Bca(a,b)};const Sca=Math.sqrt(3)/2;var Tca={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(a,b){b=b/180*Math.PI,a=a/180*Math.PI;const c=Math.asin(Sca*Math.sin(b)),d=c*c,e=d*d*d;return{x:.5*(a*Math.cos(c)/(Sca*(1.340264+ -0.24331799999999998*d+e*(.0062510000000000005+.034164*d)))/Math.PI+.5),y:1-.5*(c*(1.340264+ -0.081106*d+e*(893e-6+.003796*d))/Math.PI+1),z:0}},unproject(a,b){a=(2*a-.5)*Math.PI;let c=b=(2*(1-b)-1)*Math.PI,d=c*c,e=d*d*d;for(let f,g,h,i=0;i<12&&(g=c*(1.340264+ -0.081106*d+e*(893e-6+.003796*d))-b,h=1.340264+ -0.24331799999999998*d+e*(.0062510000000000005+.034164*d),f=g/h,c=W(c-f,-Math.PI/3,Math.PI/3),d=c*c,e=d*d*d,!(1e-12>Math.abs(f)));++i);const j=W(180*(Sca*a*(1.340264+ -0.24331799999999998*d+e*(.0062510000000000005+.034164*d))/Math.cos(c))/Math.PI,-180,180),k=W(180*Math.asin(Math.sin(c)/Sca)/Math.PI,-85.051129,85.051129);return new pH(j,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>FH(1,a)*b,farthestPixelDistance(a){return gaa(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new Bca(a,b)},Uca={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(a,b)=>({x:.5+a/360,y:.5-b/360,z:0}),unproject(a,b){const c=W(360*(.5-b),-85.051129,85.051129);return new pH(360*(a-.5),c)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>FH(1,a)*b,farthestPixelDistance(a){return gaa(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new Bca(a,b)};const Vca=Math.PI/2;function Wca(a){return Math.tan((Vca+a)/2)}var Xca={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&N(this.parallels,this.constants.parallels))return;const a=Q(this.parallels[0]),b=Q(this.parallels[1]),c=Math.cos(a),d=a===b?Math.sin(a):Math.log(c/Math.cos(b))/Math.log(Wca(b)/Wca(a)),e=c*Math.pow(Wca(a),d)/d;this.constants={n:d,f:e,parallels:this.parallels}},project(a,b){this.initializeConstants(),b=Q(b),a=Q(a-this.center[0]);const{n:c,f:d}=this.constants;d>0?b< -Vca+1e-6&&(b=-Vca+1e-6):b>Vca-1e-6&&(b=Vca-1e-6);const e=d/Math.pow(Wca(b),c);return{x:.5*(e*Math.sin(c*a)/Math.PI+.5),y:1-.5*((d-e*Math.cos(c*a))/Math.PI+.5),z:0}},unproject(a,b){this.initializeConstants(),a=(2*a-.5)*Math.PI,b=(2*(1-b)-.5)*Math.PI;const{n:c,f:d}=this.constants,e=d-b,f=Math.sign(e),g=Math.sign(c)*Math.sqrt(a*a+e*e);let h=Math.atan2(a,Math.abs(e))*f;e*c<0&&(h-=Math.PI*Math.sign(a)*f);const i=W(R(h/c)+this.center[0],-180,180),j=W(R(2*Math.atan(Math.pow(d/g,1/c))-Vca),-85.051129,85.051129);return new pH(i,j)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>FH(1,a)*b,farthestPixelDistance(a){return gaa(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new Bca(a,b)},Yca={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(a,b)=>({x:DH(a),y:EH(b),z:0}),unproject(a,b){const c=GH(a),d=HH(b);return new pH(c,d)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>FH(1,a)*b,farthestPixelDistance(a){return gaa(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new Bca(a,b)};const Zca=Q(85.051129);var $ca={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(a,b){const c=(b=Q(b))*b,d=c*c;return{x:.5*((a=Q(a))*(.8707-.131979*c+d*(d*(.003971*c-.001529*d)-.013791))/Math.PI+.5),y:1-.5*(b*(1.007226+c*(.015085+d*(.028874*c-.044475-.005916*d)))/Math.PI+1),z:0}},unproject(a,b){a=(2*a-.5)*Math.PI;let c=b=(2*(1-b)-1)*Math.PI,d=25,e=0,f=c*c;do{f=c*c;const g=f*f;e=(c*(1.007226+f*(.015085+g*(.028874*f-.044475-.005916*g)))-b)/(1.007226+f*(.045255+g*(.259866*f-.311325-.005916*11*g))),c=W(c-e,-Zca,Zca)}while(Math.abs(e)>1e-6&& --d>0)f=c*c;const h=W(R(a/(.8707+f*(f*(f*f*f*(.003971-.001529*f)-.013791)-.131979))),-180,180),i=R(c);return new pH(h,i)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>FH(1,a)*b,farthestPixelDistance(a){return gaa(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new Bca(a,b)};const _ca=Q(85.051129),ada={albers:Rca,equalEarth:Tca,equirectangular:Uca,lambertConformalConic:Xca,mercator:Yca,naturalEarth:$ca,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(a,b){b=Q(b),a=Q(a);const c=Math.cos(b),d=Math.acos(c*Math.cos(a/2)),e=Math.sin(d)/d;return{x:.5*((.5*(a*(2/Math.PI)+2*c*Math.sin(a/2)/e)||0)/Math.PI+.5),y:1-.5*((.5*(b+Math.sin(b)/e)||0)/Math.PI+1),z:0}},unproject(a,b){let c=a=(2*a-.5)*Math.PI,d=b=(2*(1-b)-1)*Math.PI,e=25,f=0,g=0;do{const h=Math.cos(d),i=Math.sin(d),j=2*i*h,k=i*i,l=h*h,m=Math.cos(c/2),n=Math.sin(c/2),o=2*m*n,p=n*n,q=1-l*m*m,r=q?1/q:0,s=q?Math.acos(h*m)*Math.sqrt(1/q):0,t=.5*(2*s*h*n+2*c/Math.PI)-a,u=.5*(s*i+d)-b,v=.5*r*(l*p+s*h*m*k)+1/Math.PI,w=r*(o*j/4-s*i*n),x=.125*r*(j*n-s*i*l*o),y=.5*r*(k*m+s*p*h)+.5,z=w*x-y*v;f=(u*w-t*y)/z,g=(t*x-u*v)/z,c=W(c-f,-Math.PI,Math.PI),d=W(d-g,-_ca,_ca)}while((Math.abs(f)>1e-6||Math.abs(g)>1e-6)&& --e>0)return new pH(R(c),R(d))},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>FH(1,a)*b,farthestPixelDistance(a){return gaa(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new Bca(a,b)}};a.ARRAY_TYPE=j,a.AUTH_ERR_MSG=Ha,a.Aabb=gJ,a.Actor=class{constructor(a,b,c){this.target=a,this.parent=b,this.mapId=c,this.callbacks={},this.cancelCallbacks={},fa(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=oa()?a:i,this.scheduler=new class{constructor(){this.tasks={},this.taskQueue=[],fa(["process"],this),this.invoker=new class{constructor(a){this._callback=a,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}(this.process),this.nextId=0}add(a,b){const c=this.nextId++,d=function({type:a,isSymbolTile:b,zoom:c}){return c=c||0,"message"===a?0:"maybePrepare"!==a||b?"parseTile"!==a||b?"parseTile"===a&&b?300-c:"maybePrepare"===a&&b?400-c:500:200-c:100-c}(b);if(0===d){oa();try{a()}finally{}return{cancel:()=>{}}}return this.tasks[c]={fn:a,metadata:b,priority:d,id:c},this.taskQueue.push(c),this.invoker.trigger(),{cancel:()=>{delete this.tasks[c]}}}process(){oa();try{if(this.taskQueue=this.taskQueue.filter(a=>!!this.tasks[a]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const f=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!f)return;f.fn()}finally{}}pick(){let g=null,h=1/0;for(let i=0;i{f&&delete this.callbacks[k],this.target.postMessage({id:k,type:"",targetMapId:g,sourceMapId:this.mapId})}}}receive(m){const n=m.data,o=n.id;if(o&&(!n.targetMapId||this.mapId===n.targetMapId))if(""===n.type){const p=this.cancelCallbacks[o];delete this.cancelCallbacks[o],p&&p.cancel()}else if(n.mustQueue||oa()){const q=this.callbacks[o];this.cancelCallbacks[o]=this.scheduler.add(()=>this.processTask(o,n),q&&q.metadata||{type:"message"})}else this.processTask(o,n)}processTask(r,s){if(""===s.type){const t=this.callbacks[r];delete this.callbacks[r],t&&(s.error?t(cp(s.error)):t(null,cp(s.data)))}else{const u=ua(this.globalScope)?void 0:[],v=s.hasCallback?(a,b)=>{delete this.cancelCallbacks[r],this.target.postMessage({id:r,type:"",sourceMapId:this.mapId,error:a?bp(a):null,data:bp(b,u)},u)}:a=>{},w=cp(s.data);if(this.parent[s.type])this.parent[s.type](s.sourceMapId,w,v);else if(this.parent.getWorkerSource){const x=s.type.split(".");this.parent.getWorkerSource(s.sourceMapId,x[0],w.source)[x[1]](w,v)}else v(new Error(`Could not find function ${s.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=h_,a.Color=_c,a.ColorMode=c0,a.CullFaceMode=g0,a.DEMData=d2,a.DataConstantProperty=qr,a.DedupedRequest=qca,a.DepthMode=T_,a.EXTENT=8192,a.Elevation=class{getAtPointOrZero(a,b=0){return this.getAtPoint(a,b)||0}getAtPoint(c,d,e=!0){null==d&&(d=null);const f=this._source();if(!f)return d;if(c.y<0||c.y>1)return d;const g=f.getSource().maxzoom,h=1<{const b=this.getAtTileOffset(w,a.x,a.y),c=x.upVector(w.canonical,a.x,a.y);return A(c,c,b*x.upVectorScale(w.canonical)),c}}getForTilePoints(y,z,B,C){const D=W5.create(this,y,C);return!!D&&(z.forEach(a=>{a[2]=this.exaggeration()*D.getElevationAt(a[0],a[1],B)}),!0)}getMinMaxForTile(E){const F=this.findDEMTileFor(E);if(!F||!F.dem)return null;const G=F.dem.tree,H=F.tileID,I=1<Math.abs(f))return!1;const g=((c[0]-this.pos[0])*d[0]+(c[1]-this.pos[1])*d[1]+(c[2]-this.pos[2])*d[2])/f;return e[0]=this.pos[0]+this.dir[0]*g,e[1]=this.pos[1]+this.dir[1]*g,e[2]=this.pos[2]+this.dir[2]*g,!0}closestPointOnSphere(h,i,j){var k,l,m,n,o,p,q,r;if(k=this.pos,l=h,m=k[0],n=k[1],o=k[2],p=l[0],q=l[1],r=l[2],Math.abs(m-p)<=1e-6*Math.max(1,Math.abs(m),Math.abs(p))&&Math.abs(n-q)<=1e-6*Math.max(1,Math.abs(n),Math.abs(q))&&Math.abs(o-r)<=1e-6*Math.max(1,Math.abs(o),Math.abs(r))||0===i)return j[0]=j[1]=j[2]=0,!1;const[s,t,u]=this.dir,v=this.pos[0]-h[0],w=this.pos[1]-h[1],x=this.pos[2]-h[2],y=s*s+t*t+u*u,z=2*(v*s+w*t+x*u),A=z*z-4*y*(v*v+w*w+x*x-i*i);if(A<0){const B=Math.max(-z/2,0),C=v+s*B,E=w+t*B,F=x+u*B,G=Math.hypot(C,E,F);return j[0]=C*i/G,j[1]=E*i/G,j[2]=F*i/G,!1}{const H=(-z-Math.sqrt(A))/(2*y);if(H<0){const I=Math.hypot(v,w,x);return j[0]=v*i/I,j[1]=w*i/I,j[2]=x*i/I,!1}return j[0]=v+s*H,j[1]=w+t*H,j[2]=x+u*H,!0}}},a.RequestManager=class{constructor(a,b,c){this._transformRequestFn=a,this._customAccessToken=b,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){const d=function(){let a="";for(let b=0;b<10;b++)a+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",a].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=d.token,this._skuTokenExpiresAt=d.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,f){return this._transformRequestFn&&this._transformRequestFn(e,f)||{url:e}}normalizeStyleURL(g,h){if(!Ia(g))return g;const i=La(g);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||h)}normalizeGlyphsURL(j,k){if(!Ia(j))return j;const l=La(j);return l.path=`/fonts/v1${l.path}`,this._makeAPIURL(l,this._customAccessToken||k)}normalizeSourceURL(m,n){if(!Ia(m))return m;const o=La(m);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),this._makeAPIURL(o,this._customAccessToken||n)}normalizeSpriteURL(p,q,r,s){const t=La(p);return Ia(p)?(t.path=`/styles/v1${t.path}/sprite${q}${r}`,this._makeAPIURL(t,this._customAccessToken||s)):(t.path+=`${q}${r}`,Ma(t))}normalizeTileURL(u,v,w){if(this._isSkuTokenExpired()&&this._createSkuToken(),u&&!Ia(u))return u;const x=La(u);x.path=x.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${v||w&&"raster"!==x.authority&&512===w?"@2x":""}${Ba.supported?".webp":"$1"}`),"raster"===x.authority?x.path=`/${ya.RASTER_URL_PREFIX}${x.path}`:(x.path=x.path.replace(/^.+\/v4\//,"/"),x.path=`/${ya.TILE_URL_VERSION}${x.path}`);const y=this._customAccessToken||function(a){for(const b of a){const c=b.match(/^access_token=(.*)$/);if(c)return c[1]}return null}(x.params)||ya.ACCESS_TOKEN;return ya.REQUIRE_ACCESS_TOKEN&&y&&this._skuToken&&x.params.push(`sku=${this._skuToken}`),this._makeAPIURL(x,y)}canonicalizeTileURL(z,A){const B=La(z);if(!B.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!B.path.match(/\.[\w]+$/))return z;let C="mapbox://";B.path.match(/^\/raster\/v1\//)?C+=`raster/${B.path.replace(`/${ya.RASTER_URL_PREFIX}/`,"")}`:C+=`tiles/${B.path.replace(`/${ya.TILE_URL_VERSION}/`,"")}`;let D=B.params;return A&&(D=D.filter(a=>!a.match(/^access_token=/))),D.length&&(C+=`?${D.join("&")}`),C}canonicalizeTileset(E,F){const G=!!F&&Ia(F),H=[];for(const I of E.tiles||[])Ja(I)?H.push(this.canonicalizeTileURL(I,G)):H.push(I);return H}_makeAPIURL(J,K){const L="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",M=La(ya.API_URL);if(J.protocol=M.protocol,J.authority=M.authority,"http"===J.protocol){const N=J.params.indexOf("secure");N>=0&&J.params.splice(N,1)}if("/"!==M.path&&(J.path=`${M.path}${J.path}`),!ya.REQUIRE_ACCESS_TOKEN)return Ma(J);if(K=K||ya.ACCESS_TOKEN,!this._silenceAuthErrors){if(!K)throw new Error(`An API access token is required to use Mapbox GL. ${L}`);if("s"===K[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${L}`)}return J.params=J.params.filter(a=>-1===a.indexOf("access_token")),J.params.push(`access_token=${K||""}`),Ma(J)}},a.ResourceType=Bb,a.SegmentVector=PG,a.SourceCache=P2,a.StencilMode=X_,a.StructArrayLayout1ui2=dA,a.StructArrayLayout2f1f2i16=pw,a.StructArrayLayout2i4=Vs,a.StructArrayLayout2ui4=Xz,a.StructArrayLayout3f12=Ht,a.StructArrayLayout3ui6=Rw,a.StructArrayLayout4i8=bt,a.Texture=GZ,a.Tile=s8,a.Transitionable=rq,a.Uniform1f=CB,a.Uniform1i=class extends zB{constructor(a,b){super(a,b),this.current=0}set(c){this.current!==c&&(this.current=c,this.gl.uniform1i(this.location,c))}},a.Uniform2f=class extends zB{constructor(a,b){super(a,b),this.current=[0,0]}set(c){c[0]===this.current[0]&&c[1]===this.current[1]||(this.current=c,this.gl.uniform2f(this.location,c[0],c[1]))}},a.Uniform3f=class extends zB{constructor(a,b){super(a,b),this.current=[0,0,0]}set(c){c[0]===this.current[0]&&c[1]===this.current[1]&&c[2]===this.current[2]||(this.current=c,this.gl.uniform3f(this.location,c[0],c[1],c[2]))}},a.Uniform4f=GB,a.UniformColor=KB,a.UniformMatrix2f=class extends zB{constructor(a,b){super(a,b),this.current=QB}set(c){for(let d=0;d<4;d++)if(c[d]!==this.current[d]){this.current=c,this.gl.uniformMatrix2fv(this.location,!1,c);break}}},a.UniformMatrix3f=class extends zB{constructor(a,b){super(a,b),this.current=PB}set(c){for(let d=0;d<9;d++)if(c[d]!==this.current[d]){this.current=c,this.gl.uniformMatrix3fv(this.location,!1,c);break}}},a.UniformMatrix4f=class extends zB{constructor(a,b){super(a,b),this.current=OB}set(c){if(c[12]!==this.current[12]||c[0]!==this.current[0])return this.current=c,void this.gl.uniformMatrix4fv(this.location,!1,c);for(let d=1;d<16;d++)if(c[d]!==this.current[d]){this.current=c,this.gl.uniformMatrix4fv(this.location,!1,c);break}}},a.UnwrappedTileID=v_,a.ValidationError=pc,a.VectorTileWorkerSource=class extends Yb{constructor(a,b,c,d,e){super(),this.actor=a,this.layerIndex=b,this.availableImages=c,this.loadVectorData=e||zca,this.loading={},this.loaded={},this.deduped=new qca(a.scheduler),this.isSpriteLoaded=d,this.scheduler=a.scheduler}loadTile(f,g){const h=f.uid,i=f&&f.request,j=i&&i.collectResourceTiming,k=this.loading[h]=new Jba(f);k.abort=this.loadVectorData(f,(a,b)=>{const c=!this.loading[h];if(delete this.loading[h],c||a||!b)return k.status="done",c||(this.loaded[h]=k),g(a);const d=b.rawData,e={};b.expires&&(e.expires=b.expires),b.cacheControl&&(e.cacheControl=b.cacheControl),k.vectorTile=b.vectorTile||new bM.VectorTile(new NQ(d));const l=()=>{k.parse(k.vectorTile,this.layerIndex,this.availableImages,this.actor,(a,b)=>{if(a||!b)return g(a);const c={};if(j){const f=f_(i);f.length>0&&(c.resourceTiming=JSON.parse(JSON.stringify(f)))}g(null,_({rawTileData:d.slice(0)},b,e,c))})};this.isSpriteLoaded?l():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(l,{type:"parseTile",isSymbolTile:f.isSymbolTile,zoom:f.tileZoom}):l()}),this.loaded=this.loaded||{},this.loaded[h]=k})}reloadTile(l,m){const n=this.loaded,o=l.uid,p=this;if(n&&n[o]){const q=n[o];q.showCollisionBoxes=l.showCollisionBoxes,q.enableTerrain=!!l.enableTerrain,q.projection=l.projection;const r=(a,b)=>{const c=q.reloadCallback;c&&(delete q.reloadCallback,q.parse(q.vectorTile,p.layerIndex,this.availableImages,p.actor,c)),m(a,b)};"parsing"===q.status?q.reloadCallback=r:"done"===q.status&&(q.vectorTile?q.parse(q.vectorTile,this.layerIndex,this.availableImages,this.actor,r):r())}}abortTile(s,t){const u=s.uid,v=this.loading[u];v&&(v.abort&&v.abort(),delete this.loading[u]),t()}removeTile(w,x){const y=this.loaded,z=w.uid;y&&y[z]&&delete y[z],x()}},a.WritingMode=VR,a.ZoomHistory=dp,a.add=w,a.addDynamicAttributes=rU,a.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},a.asyncAll=Z,a.bezier=U,a.bindAll=fa,a.boundsAttributes=q8,a.bufferConvexPolygon=function(a,b){const c=[];for(let d=0;dxb&&(a.getActor().send("enforceCacheSizeLimit",wb),Ab=0)},a.calculateGlobeMatrix=raa,a.calculateGlobeMercatorMatrix=function(a){const b=a.worldSize,c=W(a.center.lat,-85.051129,85.051129),d=new g(DH(a.center.lng)*b,EH(c)*b),e=FH(1,a.center.lat)*b,f=a.pixelsPerMeter,h=b/(e/a.pixelsPerMeter),i=l(new Float64Array(16));return n(i,i,[d.x,d.y,0]),o(i,i,[h,h,f]),i},a.clamp=W,a.clearTileCache=function(a){const b=i.caches.delete(tb);a&&b.catch(a).then(()=>a())},a.clipLine=YS,a.clone=function(a){var b=new j(16);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15],b},a.clone$1=ja,a.collisionCircleLayout=CQ,a.config=ya,a.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},a.create=function(){var a=new j(16);return j!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},a.create$1=k,a.createExpression=mn,a.createLayout=Ts,a.createStyleLayer=function(a){return"custom"===a.type?new uZ(a):new AZ[a.type](a)},a.cross=E,a.degToRad=Q,a.div=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},a.dot=D,a.ease=V,a.easeCubicInOut=T,a.emitValidationErrors=To,a.endsWith=ga,a.enforceCacheSizeLimit=function(a){yb(),ub&&ub.then(b=>{b.keys().then(c=>{for(let d=0;df&&(d+=(a[e]-f)*(a[e]-f)),b[e]Math.abs(b.parallels[0]+b.parallels[1])){let c=function(a){const b=Math.max(.01,Math.cos(Q(a))),c=1/(2*Math.max(Math.PI*b,1/b));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(a,d){const e=Q(a)*b,f=Math.sin(Q(d))/b;return{x:e*c+.5,y:-f*c+.5,z:0}},unproject(a,d){const e=-(d-.5)/c,f=W(R((a-.5)/c)/b,-180,180),g=Math.asin(W(e*b,-1,1)),h=W(R(g),-85.051129,85.051129);return new pH(f,h)}}}(b.parallels[0]);if("lambertConformalConic"===b.name){const{project:d,unproject:e}=ada.mercator;c={wrap:!0,supportsWorldCopies:!0,project:d,unproject:e}}return _({},a,b,c)}return _({},a,b)})(b,a):b},a.getRTLTextPluginStatus=Zp,a.getReferrer=Gb,a.getTilePoint=function(a,{x:b,y:c},d=0){return new g(((b-d)*a.scale-a.x)*8192,(c*a.scale-a.y)*8192)},a.getTileVec3=function(a,b,c=0){return v(((b.x-c)*a.scale-a.x)*8192,(b.y*a.scale-a.y)*8192,IH(b.z,b.y))},a.getVideo=function(a,b){const c=i.document.createElement("video");c.muted=!0,c.onloadstart=function(){b(null,c)};for(let d=0;d{}}},a.globeBuffersForTileMesh=function(a,b,c,d){const e=a.context,f=a.transform;let g=b.globeGridBuffer,h=b.globePoleBuffer;if(!g){const i=saa.createGridVertices(c.canonical);g=b.globeGridBuffer=e.createVertexBuffer(i,faa,!1)}if(!h){const j=saa.createPoleTriangleVertices(d,f.tileSize*d,0===c.canonical.y);h=b.globePoleBuffer=e.createVertexBuffer(j,faa,!1)}return[g,h]},a.globeDenormalizeECEF=qaa,a.globeMatrixForTile=function(a,b){var c,d;const e=qaa(laa(a)),f=((c=new Float64Array(16))[0]=(d=b)[0],c[1]=d[1],c[2]=d[2],c[3]=d[3],c[4]=d[4],c[5]=d[5],c[6]=d[6],c[7]=d[7],c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15],c);return r(f,f,e),f},a.globePoleMatrixForTile=function(a,b,c){const d=l(new Float64Array(16)),e=Math.pow(2,a.z),f=(a.x-e/2)/e*Math.PI*2,g=c.point,h=c.worldSize/(c.tileSize*e);return n(d,d,[g.x,g.y,-c.worldSize/Math.PI/2]),o(d,d,[h,h,h]),p(d,d,Q(-c._center.lat)),q(d,d,Q(-c._center.lng)),q(d,d,f),b&&o(d,d,[1,-1,1]),d},a.globeTileBounds=laa,a.globeToMercatorTransition=function(a){return X(5,6,a)},a.identity=l,a.identity$1=L,a.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(a[0]=(h*D-i*C+j*B)*(E=1/E),a[1]=(e*C-d*D-f*B)*E,a[2]=(p*x-q*w+r*v)*E,a[3]=(m*w-l*x-n*v)*E,a[4]=(i*A-g*D-j*z)*E,a[5]=(c*D-e*A+f*z)*E,a[6]=(q*u-o*x-r*t)*E,a[7]=(k*x-m*u+n*t)*E,a[8]=(g*C-h*A+j*y)*E,a[9]=(d*A-c*C-f*y)*E,a[10]=(o*w-p*u+r*s)*E,a[11]=(l*u-k*w-n*s)*E,a[12]=(h*z-g*B-i*y)*E,a[13]=(c*B-d*z+e*y)*E,a[14]=(p*t-o*v-q*s)*E,a[15]=(k*v-l*t+m*s)*E,a):null},a.isMapAuthenticated=function(a){return sb.has(a)},a.isMapboxURL=Ia,a.latFromMercatorY=HH,a.len=u,a.length=u,a.length$1=function(a){return Math.hypot(a[0],a[1],a[2],a[3])},a.loadVectorTile=zca,a.makeRequest=Hb,a.mercatorXfromLng=DH,a.mercatorYfromLat=EH,a.mercatorZfromAltitude=FH,a.mul=r,a.mul$1=y,a.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1],o=c[2],p=c[3],q=c[4],r=c[5],s=c[6],t=c[7],u=c[8];return a[0]=m*d+n*g+o*j,a[1]=m*e+n*h+o*k,a[2]=m*f+n*i+o*l,a[3]=p*d+q*g+r*j,a[4]=p*e+q*h+r*k,a[5]=p*f+q*i+r*l,a[6]=s*d+t*g+u*j,a[7]=s*e+t*h+u*k,a[8]=s*f+t*i+u*l,a},a.multiply$1=m,a.multiply$2=y,a.nextPowerOfTwo=da,a.normalize=C,a.normalize$1=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f;return g>0&&(g=1/Math.sqrt(g)),a[0]=c*g,a[1]=d*g,a[2]=e*g,a[3]=f*g,a},a.number=di,a.ortho=function(a,b,c,d,e,f,g){var h=1/(b-c),i=1/(d-e),j=1/(f-g);return a[0]=-2*h,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*i,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*j,a[11]=0,a[12]=(b+c)*h,a[13]=(e+d)*i,a[14]=(g+f)*j,a[15]=1,a},a.pbf=NQ,a.perspective=function(a,b,c,d,e){var f,g=1/Math.tan(b/2);return a[0]=g/c,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=g,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=e&&e!==1/0?(a[10]=(e+d)*(f=1/(d-e)),a[14]=2*e*d*f):(a[10]=-1,a[14]=-2*d),a},a.pick=function(a,b){const c={};for(let d=0;dthis._layers[a.id]),n=m[0];if("none"===n.visibility)continue;const o=n.source||"";let p=this.familiesBySource[o];p||(p=this.familiesBySource[o]={});const q=n.sourceLayer||"_geojsonTileLayer";let r=p[q];r||(r=p[q]=[]),r.push(m)}}}const{ImageBitmap:s}=a.window;class t{loadTile(u,v){const{uid:w,encoding:x,rawImageData:y,padding:z,buildQuadTree:A}=u,B=s&&y instanceof s?this.getImageData(y,z):y;v(null,new a.DEMData(w,B,x,z<1,A))}getImageData(C,D){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(C.width,C.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=C.width,this.offscreenCanvas.height=C.height,this.offscreenCanvasContext.drawImage(C,0,0,C.width,C.height);const E=this.offscreenCanvasContext.getImageData(-D,-D,C.width+2*D,C.height+2*D);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new a.RGBAImage({width:E.width,height:E.height},E.data)}}var F,G=function a(b,c){var d,e=b&&b.type;if("FeatureCollection"===e)for(d=0;d=Math.abs(h)?c-i+h:h-i+c,c=i}c+d>=0!= !!b&&a.reverse()}const J=a.vectorTile.VectorTileFeature.prototype.toGeoJSON;class K{constructor(L){this._feature=L,this.extent=a.EXTENT,this.type=L.type,this.properties=L.tags,"id"in L&&!isNaN(L.id)&&(this.id=parseInt(L.id,10))}loadGeometry(){if(1===this._feature.type){const M=[];for(const N of this._feature.geometry)M.push([new a.pointGeometry(N[0],N[1])]);return M}{const O=[];for(const P of this._feature.geometry){const Q=[];for(const R of P)Q.push(new a.pointGeometry(R[0],R[1]));O.push(Q)}return O}}toGeoJSON(S,T,U){return J.call(this,S,T,U)}}class V{constructor(W){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=W.length,this._features=W}feature(X){return new K(this._features[X])}}var Y=a.vectorTile.VectorTileFeature,Z=$;function $(a,b){this.options=b||{},this.features=a,this.length=a.length}function _(a,b){this.id="number"==typeof a.id?a.id:void 0,this.type=a.type,this.rawGeometry=1===a.type?[a.geometry]:a.geometry,this.properties=a.tags,this.extent=b||4096}$.prototype.feature=function(a){return new _(this.features[a],this.options.extent)},_.prototype.loadGeometry=function(){var b=this.rawGeometry;this.geometry=[];for(var c=0;c>31}function ha(a,b){for(var c=a.loadGeometry(),d=a.type,e=0,f=0,g=c.length,h=0;h>1;ka(a,b,g,d,e,f%2),ja(a,b,c,d,g-1,f+1),ja(a,b,c,g+1,e,f+1)}function ka(a,b,c,d,e,f){for(;e>d;){if(e-d>600){const g=e-d+1,h=c-d+1,i=Math.log(g),j=.5*Math.exp(2*i/3),k=.5*Math.sqrt(i*j*(g-j)/g)*(h-g/2<0?-1:1);ka(a,b,c,Math.max(d,Math.floor(c-h*j/g+k)),Math.min(e,Math.floor(c+(g-h)*j/g+k)),f)}const l=b[2*c+f];let m=d,n=e;for(la(a,b,d,c),b[2*e+f]>l&&la(a,b,d,e);ml;)n--}b[2*d+f]===l?la(a,b,d,n):(n++,la(a,b,n,e)),n<=c&&(d=n+1),c<=n&&(e=n-1)}}function la(a,b,c,d){ma(a,c,d),ma(b,2*c,2*d),ma(b,2*c+1,2*d+1)}function ma(a,b,c){const d=a[b];a[b]=a[c],a[c]=d}function na(a,b,c,d){const e=a-c,f=b-d;return e*e+f*f}aa.fromVectorTileJs=ba,aa.fromGeojsonVt=function(a,b){b=b||{};var c={};for(var d in a)c[d]=new Z(a[d].features,b),c[d].name=d,c[d].version=b.version,c[d].extent=b.extent;return ba({layers:c})},aa.GeoJSONWrapper=Z;class oa{constructor(pa,qa=a=>a[0],ra=a=>a[1],sa=64,ta=Float64Array){this.nodeSize=sa,this.points=pa;const ua=pa.length<65536?Uint16Array:Uint32Array,va=this.ids=new ua(pa.length),wa=this.coords=new ta(2*pa.length);for(let xa=0;xa=c&&j<=e&&k>=d&&k<=f&&i.push(a[o]);continue}const p=Math.floor((n+m)/2);j=b[2*p],k=b[2*p+1],j>=c&&j<=e&&k>=d&&k<=f&&i.push(a[p]);const q=(l+1)%2;(0===l?c<=j:d<=k)&&(h.push(n),h.push(p-1),h.push(q)),(0===l?e>=j:f>=k)&&(h.push(p+1),h.push(m),h.push(q))}return i})(this.ids,this.coords,ya,za,Aa,Ba,this.nodeSize)}within(Ca,Da,Ea){return(function(a,b,c,d,e,f){const g=[0,a.length-1,0],h=[],i=e*e;for(;g.length;){const j=g.pop(),k=g.pop(),l=g.pop();if(k-l<=f){for(let m=l;m<=k;m++)na(b[2*m],b[2*m+1],c,d)<=i&&h.push(a[m]);continue}const n=Math.floor((l+k)/2),o=b[2*n],p=b[2*n+1];na(o,p,c,d)<=i&&h.push(a[n]);const q=(j+1)%2;(0===j?c-e<=o:d-e<=p)&&(g.push(l),g.push(n-1),g.push(q)),(0===j?c+e>=o:d+e>=p)&&(g.push(n+1),g.push(k),g.push(q))}return h})(this.ids,this.coords,Ca,Da,Ea,this.nodeSize)}}const Fa=Math.fround||(F=new Float32Array(1),a=>(F[0]=+a,F[0]));class Ga{constructor(Ha){this.options=Oc(Object.create({minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:a=>a}),Ha),this.trees=new Array(this.options.maxZoom+1)}load(Ia){const{log:Ja,minZoom:Ka,maxZoom:La,nodeSize:Ma}=this.options;Ja&&console.time("total time");const Na=`prepare ${Ia.length} points`;Ja&&console.time(Na),this.points=Ia;let Oa=[];for(let Pa=0;Pa=Ka;Qa--){const Ra=+Date.now();Oa=this._cluster(Oa,Qa),this.trees[Qa]=new oa(Oa,Pc,Qc,Ma,Float32Array),Ja&&console.log("z%d: %d clusters in %dms",Qa,Oa.length,+Date.now()-Ra)}return Ja&&console.timeEnd("total time"),this}getClusters(Sa,Ta){let Ua=((Sa[0]+180)%360+360)%360-180;const Va=Math.max(-90,Math.min(90,Sa[1]));let Wa=180===Sa[2]?180:((Sa[2]+180)%360+360)%360-180;const Xa=Math.max(-90,Math.min(90,Sa[3]));if(Sa[2]-Sa[0]>=360)Ua=-180,Wa=180;else if(Ua>Wa){const Ya=this.getClusters([Ua,Va,180,Xa],Ta),Za=this.getClusters([-180,Va,Wa,Xa],Ta);return Ya.concat(Za)}const $a=this.trees[this._limitZoom(Ta)],_a=$a.range(Lc(Ua),Mc(Xa),Lc(Wa),Mc(Va)),ab=[];for(const bb of _a){const cb=$a.points[bb];ab.push(cb.numPoints?Jc(cb):this.points[cb.index])}return ab}getChildren(db){const eb=this._getOriginId(db),fb=this._getOriginZoom(db),gb="No cluster with the specified id.",hb=this.trees[fb];if(!hb)throw new Error(gb);const ib=hb.points[eb];if(!ib)throw new Error(gb);const jb=this.options.radius/(this.options.extent*Math.pow(2,fb-1)),kb=hb.within(ib.x,ib.y,jb),lb=[];for(const mb of kb){const nb=hb.points[mb];nb.parentId===db&&lb.push(nb.numPoints?Jc(nb):this.points[nb.index])}if(0===lb.length)throw new Error(gb);return lb}getLeaves(ob,pb,qb){const rb=[];return this._appendLeaves(rb,ob,pb=pb||10,qb=qb||0,0),rb}getTile(sb,tb,ub){const vb=this.trees[this._limitZoom(sb)],wb=Math.pow(2,sb),{extent:xb,radius:yb}=this.options,zb=yb/xb,Ab=(ub-zb)/wb,Bb=(ub+1+zb)/wb,Cb={features:[]};return this._addTileFeatures(vb.range((tb-zb)/wb,Ab,(tb+1+zb)/wb,Bb),vb.points,tb,ub,wb,Cb),0===tb&&this._addTileFeatures(vb.range(1-zb/wb,Ab,1,Bb),vb.points,wb,ub,wb,Cb),tb===wb-1&&this._addTileFeatures(vb.range(0,Ab,zb/wb,Bb),vb.points,-1,ub,wb,Cb),Cb.features.length?Cb:null}getClusterExpansionZoom(Db){let Eb=this._getOriginZoom(Db)-1;for(;Eb<=this.options.maxZoom;){const Fb=this.getChildren(Db);if(Eb++,1!==Fb.length)break;Db=Fb[0].properties.cluster_id}return Eb}_appendLeaves(Gb,Hb,Ib,Jb,Kb){const Lb=this.getChildren(Hb);for(const Mb of Lb){const Nb=Mb.properties;if(Nb&&Nb.cluster?Kb+Nb.point_count<=Jb?Kb+=Nb.point_count:Kb=this._appendLeaves(Gb,Nb.cluster_id,Ib,Jb,Kb):Kbdc&&(pc+=rc.numPoints||1)}if(pc>oc&&pc>=ic){let sc=lc.x*oc,tc=lc.y*oc,uc=hc&&oc>1?this._map(lc,!0):null;const vc=(kc<<5)+(dc+1)+this.points.length;for(const wc of nc){const xc=mc.points[wc];if(xc.zoom<=dc)continue;xc.zoom=dc;const yc=xc.numPoints||1;sc+=xc.x*yc,tc+=xc.y*yc,xc.parentId=vc,hc&&(uc||(uc=this._map(lc,!0)),hc(uc,this._map(xc)))}lc.parentId=vc,ec.push(Hc(sc/pc,tc/pc,vc,pc,uc))}else if(ec.push(lc),pc>1)for(const zc of nc){const Ac=mc.points[zc];Ac.zoom<=dc||(Ac.zoom=dc,ec.push(Ac))}}return ec}_getOriginId(Bc){return Bc-this.points.length>>5}_getOriginZoom(Cc){return(Cc-this.points.length)%32}_map(Dc,Ec){if(Dc.numPoints)return Ec?Oc({},Dc.properties):Dc.properties;const Fc=this.points[Dc.index].properties,Gc=this.options.map(Fc);return Ec&&Gc===Fc?Oc({},Gc):Gc}}function Hc(a,b,c,d,e){return{x:Fa(a),y:Fa(b),zoom:1/0,id:c,parentId:-1,numPoints:d,properties:e}}function Ic(a,b){const[c,d]=a.geometry.coordinates;return{x:Fa(Lc(c)),y:Fa(Mc(d)),zoom:1/0,index:b,parentId:-1}}function Jc(a){return{type:"Feature",id:a.id,properties:Kc(a),geometry:{type:"Point",coordinates:[360*(a.x-.5),Nc(a.y)]}}}function Kc(a){const b=a.numPoints,c=b>=1e4?`${Math.round(b/1e3)}k`:b>=1e3?Math.round(b/100)/10+"k":b;return Oc(Oc({},a.properties),{cluster:!0,cluster_id:a.id,point_count:b,point_count_abbreviated:c})}function Lc(a){return a/360+.5}function Mc(a){const b=Math.sin(a*Math.PI/180),c=.5-.25*Math.log((1+b)/(1-b))/Math.PI;return c<0?0:c>1?1:c}function Nc(a){return 360*Math.atan(Math.exp((180-360*a)*Math.PI/180))/Math.PI-90}function Oc(a,b){for(const c in b)a[c]=b[c];return a}function Pc(a){return a.x}function Qc(a){return a.y}function Rc(a,b,c,d){for(var e,f=d,g=c-b>>1,h=c-b,i=a[b],j=a[b+1],k=a[c],l=a[c+1],m=b+3;mf)e=m,f=n;else if(n===f){var o=Math.abs(m-g);od&&(e-b>3&&Rc(a,b,e,d),a[e+2]=f,c-e>3&&Rc(a,e,c,d))}function Sc(a,b,c,d,e,f){var g=e-c,h=f-d;if(0!==g||0!==h){var i=((a-c)*g+(b-d)*h)/(g*g+h*h);i>1?(c=e,d=f):i>0&&(c+=g*i,d+=h*i)}return(g=a-c)*g+(h=b-d)*h}function Tc(a,b,c,d){var e={id:void 0===a?null:a,type:b,geometry:c,tags:d,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return(function(a){var b=a.geometry,c=a.type;if("Point"===c||"MultiPoint"===c||"LineString"===c)Uc(a,b);else if("Polygon"===c||"MultiLineString"===c)for(var d=0;d0&&(g+=d?(e*j-i*f)/2:Math.sqrt(Math.pow(i-e,2)+Math.pow(j-f,2))),e=i,f=j}var k=b.length-3;b[2]=1,Rc(b,0,k,c),b[k+2]=1,b.size=Math.abs(g),b.start=0,b.end=b.size}function Yc(a,b,c,d){for(var e=0;e1?1:c}function _c(a,b,c,d,e,f,g,h){if(d/=b,f>=(c/=b)&&g=d)return null;for(var i=[],j=0;j=c&&o=d)){var p=[];if("Point"===m||"MultiPoint"===m)ad(l,p,c,d,e);else if("LineString"===m)bd(l,p,c,d,e,!1,h.lineMetrics);else if("MultiLineString"===m)dd(l,p,c,d,e,!1);else if("Polygon"===m)dd(l,p,c,d,e,!0);else if("MultiPolygon"===m)for(var q=0;q=c&&g<=d&&(b.push(a[f]),b.push(a[f+1]),b.push(a[f+2]))}}function bd(a,b,c,d,e,f,g){for(var h,i,j=cd(a),k=0===e?fd:gd,l=a.start,m=0;mc&&(i=k(j,n,o,q,r,c),g&&(j.start=l+h*i)):s>d?t=c&&(i=k(j,n,o,q,r,c),u=!0),t>d&&s<=d&&(i=k(j,n,o,q,r,d),u=!0),!f&&u&&(g&&(j.end=l+h*i),b.push(j),j=cd(a)),g&&(l+=h)}var v=a.length-3;n=a[v],o=a[v+1],p=a[v+2],(s=0===e?n:o)>=c&&s<=d&&ed(j,n,o,p),v=j.length-3,f&&v>=3&&(j[v]!==j[0]||j[v+1]!==j[1])&&ed(j,j[0],j[1],j[2]),j.length&&b.push(j)}function cd(a){var b=[];return b.size=a.size,b.start=a.start,b.end=a.end,b}function dd(a,b,c,d,e,f){for(var g=0;gg.maxX&&(g.maxX=k),l>g.maxY&&(g.maxY=l)}return g}function md(a,b,c,d){var e=b.geometry,f=b.type,g=[];if("Point"===f||"MultiPoint"===f)for(var h=0;h0&&b.size<(e?g:d))c.numPoints+=b.length/3;else{for(var h=[],i=0;ig)&&(c.numSimplified++,h.push(b[i]),h.push(b[i+1])),c.numPoints++;e&&(function(a,b){for(var c=0,d=0,e=a.length,f=e-2;d0===b)for(d=0,e=a.length;d24)throw new Error("maxZoom should be in the 0-24 range");if(b.promoteId&&b.generateId)throw new Error("promoteId and generateId cannot be used together.");var d,e,f,g,h,i,j=function(a,b){var c=[];if("FeatureCollection"===a.type)for(var d=0;d1&&console.time("creation"),m=this.tiles[l]=ld(a,b,c,d,i),this.tileCoords.push({z:b,x:c,y:d}),j)){j>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",b,c,d,m.numFeatures,m.numPoints,m.numSimplified),console.timeEnd("creation"));var n="z"+b;this.stats[n]=(this.stats[n]||0)+1,this.total++}if(m.source=a,e){if(b===i.maxZoom||b===e)continue;var o=1<1&&console.time("clipping");var p,q,r,s,t,u,v=.5*i.buffer/i.extent,w=.5-v,x=.5+v,y=1+v;p=q=r=s=null,t=_c(a,k,c-v,c+x,0,m.minX,m.maxX,i),u=_c(a,k,c+w,c+y,0,m.minX,m.maxX,i),a=null,t&&(p=_c(t,k,d-v,d+x,1,m.minY,m.maxY,i),q=_c(t,k,d+w,d+y,1,m.minY,m.maxY,i),t=null),u&&(r=_c(u,k,d-v,d+x,1,m.minY,m.maxY,i),s=_c(u,k,d+w,d+y,1,m.minY,m.maxY,i),u=null),j>1&&console.timeEnd("clipping"),h.push(p||[],b+1,2*c,2*d),h.push(q||[],b+1,2*c,2*d+1),h.push(r||[],b+1,2*c+1,2*d),h.push(s||[],b+1,2*c+1,2*d+1)}}},od.prototype.getTile=function(a,b,c){var d=this.options,e=d.extent,f=d.debug;if(a<0||a>24)return null;var g=1<1&&console.log("drilling down to z%d-%d-%d",a,b,c);for(var i,j=a,k=b,l=c;!i&&j>0;)j--,k=Math.floor(k/2),l=Math.floor(l/2),i=this.tiles[pd(j,k,l)];return i&&i.source?(f>1&&console.log("found parent tile z%d-%d-%d",j,k,l),f>1&&console.time("drilling down"),this.splitTile(i.source,j,k,l,a,b,c),f>1&&console.timeEnd("drilling down"),this.tiles[h]?jd(this.tiles[h],e):null):null};class qd extends a.VectorTileWorkerSource{constructor(rd,sd,td,ud,vd){super(rd,sd,td,ud,function(a,b){const c=a.tileID.canonical;if(!this._geoJSONIndex)return b(null,null);const d=this._geoJSONIndex.getTile(c.z,c.x,c.y);if(!d)return b(null,null);const e=new V(d.features);let f=aa(e);0===f.byteOffset&&f.byteLength===f.buffer.byteLength||(f=new Uint8Array(f)),b(null,{vectorTile:e,rawData:f.buffer})}),vd&&(this.loadGeoJSON=vd)}loadData(wd,xd){const yd=wd&&wd.request,zd=yd&&yd.collectResourceTiming;this.loadGeoJSON(wd,(b,c)=>{if(b||!c)return xd(b);if("object"!=typeof c)return xd(new Error(`Input data given to '${wd.source}' is not a valid GeoJSON object.`));{G(c,!0);try{var d,e;if(wd.filter){const f=a.createExpression(wd.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===f.result)throw new Error(f.value.map(a=>`${a.key}: ${a.message}`).join(", "));const g=c.features.filter(a=>f.value.evaluate({zoom:0},a));c={type:"FeatureCollection",features:g}}this._geoJSONIndex=wd.cluster?new Ga(function({superclusterOptions:b,clusterProperties:c}){if(!c||!b)return b;const d={},e={},f={accumulated:null,zoom:0},g={properties:null},h=Object.keys(c);for(const i of h){const[j,k]=c[i],l=a.createExpression(k),m=a.createExpression("string"==typeof j?[j,["accumulated"],["get",i]]:j);d[i]=l.value,e[i]=m.value}return b.map=a=>{g.properties=a;const b={};for(const c of h)b[c]=d[c].evaluate(f,g);return b},b.reduce=(a,b)=>{for(const c of(g.properties=b,h))f.accumulated=a[c],a[c]=e[c].evaluate(f,g)},b}(wd)).load(c.features):(d=c,e=wd.geojsonVtOptions,new od(d,e))}catch(h){return xd(h)}this.loaded={};const i={};if(zd){const j=a.getPerformanceMeasurement(yd);j&&(i.resourceTiming={},i.resourceTiming[wd.source]=JSON.parse(JSON.stringify(j)))}xd(null,i)}})}reloadTile(Ad,Bd){const Cd=this.loaded;return Cd&&Cd[Ad.uid]?super.reloadTile(Ad,Bd):this.loadTile(Ad,Bd)}loadGeoJSON(Dd,Ed){if(Dd.request)a.getJSON(Dd.request,Ed);else{if("string"!=typeof Dd.data)return Ed(new Error(`Input data given to '${Dd.source}' is not a valid GeoJSON object.`));try{return Ed(null,JSON.parse(Dd.data))}catch(Fd){return Ed(new Error(`Input data given to '${Dd.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(Gd,Hd){try{Hd(null,this._geoJSONIndex.getClusterExpansionZoom(Gd.clusterId))}catch(Id){Hd(Id)}}getClusterChildren(Jd,Kd){try{Kd(null,this._geoJSONIndex.getChildren(Jd.clusterId))}catch(Ld){Kd(Ld)}}getClusterLeaves(Md,Nd){try{Nd(null,this._geoJSONIndex.getLeaves(Md.clusterId,Md.limit,Md.offset))}catch(Od){Nd(Od)}}}class Pd{constructor(Qd){this.self=Qd,this.actor=new a.Actor(Qd,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:qd},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(a,b)=>{if(this.workerSourceTypes[a])throw new Error(`Worker source with name "${a}" already registered.`);this.workerSourceTypes[a]=b},this.self.registerRTLTextPlugin=b=>{if(a.plugin.isParsed())throw new Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=b.applyArabicShaping,a.plugin.processBidirectionalText=b.processBidirectionalText,a.plugin.processStyledBidirectionalText=b.processStyledBidirectionalText}}clearCaches(Rd,Sd,Td){delete this.layerIndexes[Rd],delete this.availableImages[Rd],delete this.workerSources[Rd],delete this.demWorkerSources[Rd],Td()}checkIfReady(Ud,Vd,Wd){Wd()}setReferrer(Xd,Yd){this.referrer=Yd}spriteLoaded(Zd,$d){for(const _d in this.isSpriteLoaded[Zd]=$d,this.workerSources[Zd]){const ae=this.workerSources[Zd][_d];for(const be in ae)ae[be]instanceof a.VectorTileWorkerSource&&(ae[be].isSpriteLoaded=$d,ae[be].fire(new a.Event("isSpriteLoaded")))}}setImages(ce,de,ee){for(const fe in this.availableImages[ce]=de,this.workerSources[ce]){const ge=this.workerSources[ce][fe];for(const he in ge)ge[he].availableImages=de}ee()}enableTerrain(ie,je,ke){this.terrain=je,ke()}setProjection(le,me){this.projections[le]=a.getProjection(me)}setLayers(ne,oe,pe){this.getLayerIndex(ne).replace(oe),pe()}updateLayers(qe,re,se){this.getLayerIndex(qe).update(re.layers,re.removedIds),se()}loadTile(te,ue,ve){const we=this.enableTerrain?a.extend({enableTerrain:this.terrain},ue):ue;we.projection=this.projections[te]||this.defaultProjection,this.getWorkerSource(te,ue.type,ue.source).loadTile(we,ve)}loadDEMTile(xe,ye,ze){const Ae=this.enableTerrain?a.extend({buildQuadTree:this.terrain},ye):ye;this.getDEMWorkerSource(xe,ye.source).loadTile(Ae,ze)}reloadTile(Be,Ce,De){const Ee=this.enableTerrain?a.extend({enableTerrain:this.terrain},Ce):Ce;Ee.projection=this.projections[Be]||this.defaultProjection,this.getWorkerSource(Be,Ce.type,Ce.source).reloadTile(Ee,De)}abortTile(Fe,Ge,He){this.getWorkerSource(Fe,Ge.type,Ge.source).abortTile(Ge,He)}removeTile(Ie,Je,Ke){this.getWorkerSource(Ie,Je.type,Je.source).removeTile(Je,Ke)}removeSource(Le,Me,Ne){if(!this.workerSources[Le]||!this.workerSources[Le][Me.type]||!this.workerSources[Le][Me.type][Me.source])return;const Oe=this.workerSources[Le][Me.type][Me.source];delete this.workerSources[Le][Me.type][Me.source],void 0!==Oe.removeSource?Oe.removeSource(Me,Ne):Ne()}loadWorkerSource(Pe,Qe,Re){try{this.self.importScripts(Qe.url),Re()}catch(Se){Re(Se.toString())}}syncRTLPluginState(Te,Ue,Ve){try{a.plugin.setState(Ue);const We=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&null!=We){this.self.importScripts(We);const Xe=a.plugin.isParsed();Ve(Xe?void 0:new Error(`RTL Text Plugin failed to import scripts from ${We}`),Xe)}}catch(Ye){Ve(Ye.toString())}}getAvailableImages(Ze){let $e=this.availableImages[Ze];return $e||($e=[]),$e}getLayerIndex(_e){let af=this.layerIndexes[_e];return af||(af=this.layerIndexes[_e]=new d),af}getWorkerSource(bf,cf,df){return this.workerSources[bf]||(this.workerSources[bf]={}),this.workerSources[bf][cf]||(this.workerSources[bf][cf]={}),this.workerSources[bf][cf][df]||(this.workerSources[bf][cf][df]=new this.workerSourceTypes[cf]({send:(a,b,c,d,e,f)=>{this.actor.send(a,b,c,bf,e,f)},scheduler:this.actor.scheduler},this.getLayerIndex(bf),this.getAvailableImages(bf),this.isSpriteLoaded[bf])),this.workerSources[bf][cf][df]}getDEMWorkerSource(ef,ff){return this.demWorkerSources[ef]||(this.demWorkerSources[ef]={}),this.demWorkerSources[ef][ff]||(this.demWorkerSources[ef][ff]=new t),this.demWorkerSources[ef][ff]}enforceCacheSizeLimit(gf,hf){a.enforceCacheSizeLimit(hf)}getWorkerPerformanceMetrics(jf,kf,lf){lf(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new Pd(self)),Pd}),e(["./shared"],function(a){"use strict";var b=c;function c(a){var b,e;return b=a,"undefined"!=typeof window&&"undefined"!=typeof document&& !!Array.prototype&&!!Array.prototype.every&&!!Array.prototype.filter&&!!Array.prototype.forEach&&!!Array.prototype.indexOf&&!!Array.prototype.lastIndexOf&&!!Array.prototype.map&&!!Array.prototype.some&&!!Array.prototype.reduce&&!!Array.prototype.reduceRight&&!!Array.isArray&& !!Function.prototype&&!!Function.prototype.bind&& !!Object.keys&&!!Object.create&&!!Object.getPrototypeOf&&!!Object.getOwnPropertyNames&&!!Object.isSealed&&!!Object.isFrozen&&!!Object.isExtensible&&!!Object.getOwnPropertyDescriptor&&!!Object.defineProperty&&!!Object.defineProperties&&!!Object.seal&&!!Object.freeze&&!!Object.preventExtensions&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&& !!function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var a,b,c=new Blob([""],{type:"text/javascript"}),d=URL.createObjectURL(c);try{b=new Worker(d),a=!0}catch(e){a=!1}return b&&b.terminate(),URL.revokeObjectURL(d),a}()&&"Uint8ClampedArray"in window&& !!ArrayBuffer.isView&& !!function(){var a=document.createElement("canvas");a.width=a.height=1;var b=a.getContext("2d");if(!b)return!1;var c=b.getImageData(0,0,1,1);return c&&c.width===a.width}()&&(void 0===d[e=b&&b.failIfMajorPerformanceCaveat]&&(d[e]=(function(a){var b,d,e,f,g=(b=a,d=document.createElement("canvas"),(e=Object.create(c.webGLContextAttributes)).failIfMajorPerformanceCaveat=b,d.getContext("webgl",e)||d.getContext("experimental-webgl",e));if(!g)return!1;try{f=g.createShader(g.VERTEX_SHADER)}catch(h){return!1}return!(!f||g.isContextLost())&&(g.shaderSource(f,"void main() {}"),g.compileShader(f),!0===g.getShaderParameter(f,g.COMPILE_STATUS))})(e)),!!d[e]&&!document.documentMode)}var d={};function e(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*f-e*d;return g?(a[0]=f*(g=1/g),a[1]=-d*g,a[2]=-e*g,a[3]=c*g,a):null}function f(a,b){if(Array.isArray(a)){if(!Array.isArray(b)||a.length!==b.length)return!1;for(let c=0;c{a.window.removeEventListener("click",k,!0)},0)},g.mousePos=function(a,b){const c=a.getBoundingClientRect();return l(a,c,b)},g.touchPos=function(a,b){const c=a.getBoundingClientRect(),d=[];for(let e=0;e=0?0:b.button};class n extends a.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(o){if(this.loaded!==o&&(this.loaded=o,o)){for(const{ids:p,callback:q}of this.requestors)this._notify(p,q);this.requestors=[]}}getImage(r){return this.images[r]}addImage(s,t){this._validate(s,t)&&(this.images[s]=t)}_validate(u,v){let w=!0;return this._validateStretch(v.stretchX,v.data&&v.data.width)||(this.fire(new a.ErrorEvent(new Error(`Image "${u}" has invalid "stretchX" value`))),w=!1),this._validateStretch(v.stretchY,v.data&&v.data.height)||(this.fire(new a.ErrorEvent(new Error(`Image "${u}" has invalid "stretchY" value`))),w=!1),this._validateContent(v.content,v)||(this.fire(new a.ErrorEvent(new Error(`Image "${u}" has invalid "content" value`))),w=!1),w}_validateStretch(x,y){if(!x)return!0;let z=0;for(const A of x){if(A[0]{this.ready=!0})}broadcast(ib,jb,kb){a.asyncAll(this.actors,(a,b)=>{a.send(ib,jb,b)},kb=kb||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(a=>{a.remove()}),this.actors=[],this.workerPool.release(this.id)}}function lb(b,c,d){return c*(a.EXTENT/(b.tileSize*Math.pow(2,d-b.tileID.overscaledZ)))}cb.Actor=a.Actor;class mb{constructor(nb,ob,pb){this.context=nb;const qb=nb.gl;this.buffer=qb.createBuffer(),this.dynamicDraw=Boolean(pb),this.context.unbindVAO(),nb.bindElementBuffer.set(this.buffer),qb.bufferData(qb.ELEMENT_ARRAY_BUFFER,ob.arrayBuffer,this.dynamicDraw?qb.DYNAMIC_DRAW:qb.STATIC_DRAW),this.dynamicDraw||delete ob.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(rb){const sb=this.context.gl;this.context.unbindVAO(),this.bind(),sb.bufferSubData(sb.ELEMENT_ARRAY_BUFFER,0,rb.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const tb={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ub{constructor(vb,wb,xb,yb){this.length=wb.length,this.attributes=xb,this.itemSize=wb.bytesPerElement,this.dynamicDraw=yb,this.context=vb;const zb=vb.gl;this.buffer=zb.createBuffer(),vb.bindVertexBuffer.set(this.buffer),zb.bufferData(zb.ARRAY_BUFFER,wb.arrayBuffer,this.dynamicDraw?zb.DYNAMIC_DRAW:zb.STATIC_DRAW),this.dynamicDraw||delete wb.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(Ab){const Bb=this.context.gl;this.bind(),Bb.bufferSubData(Bb.ARRAY_BUFFER,0,Ab.arrayBuffer)}enableAttributes(Cb,Db){for(let Eb=0;Ebhc.pointCoordinate3D(a)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(ic,jc){let kc,lc;if(ic instanceof a.pointGeometry||"number"==typeof ic[0]){const mc=a.pointGeometry.convert(ic);kc=[a.pointGeometry.convert(ic)],lc=jc.isPointAboveHorizon(mc)}else{const nc=a.pointGeometry.convert(ic[0]),oc=a.pointGeometry.convert(ic[1]);kc=[nc,oc],lc=a.polygonizeBounds(nc,oc).every(a=>jc.isPointAboveHorizon(a))}return new dc(kc,jc.getCameraPoint(),lc,jc)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(pc){return a.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],pc)}bufferedCameraGeometry(qc){const rc=this.screenBounds[0],sc=1===this.screenBounds.length?this.screenBounds[0].add(new a.pointGeometry(1,1)):this.screenBounds[1],tc=a.polygonizeBounds(rc,sc,0,!1);return this.cameraPoint.y>sc.y&&(this.cameraPoint.x>rc.x&&this.cameraPoint.x=sc.x?tc[2]=this.cameraPoint:this.cameraPoint.x<=rc.x&&(tc[3]=this.cameraPoint)),a.bufferConvexPolygon(tc,qc)}containsTile(uc,vc,wc){var xc;const yc=uc.queryPadding+1,zc=uc.tileID.wrap,Ac=wc?this._bufferedCameraMercator(yc,vc).map(b=>a.getTilePoint(uc.tileTransform,b,zc)):this._bufferedScreenMercator(yc,vc).map(b=>a.getTilePoint(uc.tileTransform,b,zc)),Bc=this.screenGeometryMercator.map(b=>a.getTileVec3(uc.tileTransform,b,zc)),Cc=Bc.map(b=>new a.pointGeometry(b[0],b[1])),Dc=vc.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),Ec=a.getTileVec3(uc.tileTransform,Dc,zc),Fc=Bc.map(b=>{const c=a.sub(b,b,Ec);return a.normalize(c,c),new a.Ray(Ec,c)}),Gc=lb(uc,1,vc.zoom);if(a.polygonIntersectsBox(Ac,0,0,a.EXTENT,a.EXTENT))return{queryGeometry:this,tilespaceGeometry:Cc,tilespaceRays:Fc,bufferedTilespaceGeometry:Ac,bufferedTilespaceBounds:((xc=a.getBounds(Ac)).min.x=a.clamp(xc.min.x,0,a.EXTENT),xc.min.y=a.clamp(xc.min.y,0,a.EXTENT),xc.max.x=a.clamp(xc.max.x,0,a.EXTENT),xc.max.y=a.clamp(xc.max.y,0,a.EXTENT),xc),tile:uc,tileID:uc.tileID,pixelToTileUnitsFactor:Gc}}_bufferedScreenMercator(Hc,Ic){const Jc=Pc(Hc);if(this._screenRaycastCache[Jc])return this._screenRaycastCache[Jc];{const Kc=this.bufferedScreenGeometry(Hc).map(a=>Ic.pointCoordinate3D(a));return this._screenRaycastCache[Jc]=Kc,Kc}}_bufferedCameraMercator(Lc,Mc){const Nc=Pc(Lc);if(this._cameraRaycastCache[Nc])return this._cameraRaycastCache[Nc];{const Oc=this.bufferedCameraGeometry(Lc).map(a=>Mc.pointCoordinate3D(a));return this._cameraRaycastCache[Nc]=Oc,Oc}}}function Pc(a){return 100*a|0}function Qc(b,c,d){const e=function(e,f){if(e)return d(e);if(f){const g=a.pick(a.extend(f,b),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);f.vector_layers&&(g.vectorLayers=f.vector_layers,g.vectorLayerIds=g.vectorLayers.map(a=>a.id)),g.tiles=c.canonicalizeTileset(g,b.url),d(null,g)}};return b.url?a.getJSON(c.transformRequest(c.normalizeSourceURL(b.url),a.ResourceType.Source),e):a.exported.frame(()=>e(null,b))}class Rc{constructor(Sc,Tc,Uc){this.bounds=a.LngLatBounds.convert(this.validateBounds(Sc)),this.minzoom=Tc||0,this.maxzoom=Uc||24}validateBounds(Vc){return Array.isArray(Vc)&&4===Vc.length?[Math.max(-180,Vc[0]),Math.max(-90,Vc[1]),Math.min(180,Vc[2]),Math.min(90,Vc[3])]:[-180,-90,180,90]}contains(Wc){const Xc=Math.pow(2,Wc.z),Yc=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*Xc),Zc=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*Xc),$c=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*Xc),_c=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*Xc);return Wc.x>=Yc&&Wc.x<$c&&Wc.y>=Zc&&Wc.y<_c}}class ad extends a.Evented{constructor(bd,cd,dd,ed){super(),this.id=bd,this.dispatcher=dd,this.setEventedParent(ed),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=a.extend({type:"raster"},cd),a.extend(this,a.pick(cd,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=Qc(this._options,this.map._requestManager,(b,c)=>{this._tileJSONRequest=null,this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(a.extend(this,c),c.bounds&&(this.tileBounds=new Rc(c.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(c.tiles),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(fd){this.map=fd,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}hasTile(gd){return!this.tileBounds||this.tileBounds.contains(gd.canonical)}loadTile(hd,id){const jd=a.exported.devicePixelRatio>=2,kd=this.map._requestManager.normalizeTileURL(hd.tileID.canonical.url(this.tiles,this.scheme),jd,this.tileSize);hd.request=a.getImage(this.map._requestManager.transformRequest(kd,a.ResourceType.Tile),(b,c,d,e)=>{if(delete hd.request,hd.aborted)hd.state="unloaded",id(null);else if(b)hd.state="errored",id(b);else if(c){this.map._refreshExpiredTiles&&hd.setExpiryData({cacheControl:d,expires:e});const f=this.map.painter.context,g=f.gl;hd.texture=this.map.painter.getTileTexture(c.width),hd.texture?hd.texture.update(c,{useMipmap:!0}):(hd.texture=new a.Texture(f,c,g.RGBA,{useMipmap:!0}),hd.texture.bind(g.LINEAR,g.CLAMP_TO_EDGE),f.extTextureFilterAnisotropic&&g.texParameterf(g.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax)),hd.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),id(null)}})}abortTile(ld,md){ld.request&&(ld.request.cancel(),delete ld.request),md()}unloadTile(nd,od){nd.texture&&this.map.painter.saveTileTexture(nd.texture),od()}hasTransition(){return!1}}let pd;function qd(b,c,d,e,f,g,h,i){const j=[b,d,f,c,e,g,1,1,1],k=[h,i,1],l=a.adjoint([],j),[m,n,o]=a.transformMat3(k,k,a.transpose(l,l));return a.multiply(j,[m,0,0,0,n,0,0,0,o],j)}class rd extends a.Evented{constructor(sd,td,ud,vd){super(),this.id=sd,this.dispatcher=ud,this.coordinates=td.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(vd),this.options=td}load(wd,xd){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this.url=this.options.url,a.getImage(this.map._requestManager.transformRequest(this.url,a.ResourceType.Image),(b,c)=>{this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(this.image=a.exported.getImageData(c),this.width=this.image.width,this.height=this.image.height,wd&&(this.coordinates=wd),xd&&xd(),this._finishLoading())})}loaded(){return this._loaded}updateImage(yd){return this.image&&yd.url&&(this.options.url=yd.url,this.load(yd.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(zd){this.map=zd,this.load()}setCoordinates(Ad){this.coordinates=Ad,delete this._boundsArray;const Bd=Ad.map(a.MercatorCoordinate.fromLngLat);return this.tileID=(function(b){let c=1/0,d=1/0,e=-1/0,f=-1/0;for(const g of b)c=Math.min(c,g.x),d=Math.min(d,g.y),e=Math.max(e,g.x),f=Math.max(f,g.y);const h=Math.max(0,Math.floor(-Math.log(Math.max(e-c,f-d))/Math.LN2)),i=Math.pow(2,h);return new a.CanonicalTileID(h,Math.floor((c+e)/2*i),Math.floor((d+f)/2*i))})(Bd),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const Cd=a.tileTransform(this.tileID,this.map.transform.projection),[Dd,Ed,Fd,Gd]=this.coordinates.map(b=>{const c=Cd.projection.project(b[0],b[1]);return a.getTilePoint(Cd,c)._round()});return this.perspectiveTransform=(function(b,c,d,e,f,g,h,i,j,k){const l=qd(0,0,b,0,0,c,b,c),m=qd(d,e,f,g,h,i,j,k);return a.multiply(m,a.adjoint(l,l),m),[m[6]/m[8]*b/a.EXTENT,m[7]/m[8]*c/a.EXTENT]})(this.width,this.height,Dd.x,Dd.y,Ed.x,Ed.y,Gd.x,Gd.y,Fd.x,Fd.y),this._boundsArray=new a.StructArrayLayout4i8,this._boundsArray.emplaceBack(Dd.x,Dd.y,0,0),this._boundsArray.emplaceBack(Ed.x,Ed.y,a.EXTENT,0),this._boundsArray.emplaceBack(Gd.x,Gd.y,0,a.EXTENT),this._boundsArray.emplaceBack(Fd.x,Fd.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const Hd=this.map.painter.context,Id=Hd.gl;for(const Jd in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=Hd.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new a.Texture(Hd,this.image,Id.RGBA),this.texture.bind(Id.LINEAR,Id.CLAMP_TO_EDGE)),this.tiles){const Kd=this.tiles[Jd];"loaded"!==Kd.state&&(Kd.state="loaded",Kd.texture=this.texture)}}loadTile(Ld,Md){this.tileID&&this.tileID.equals(Ld.tileID.canonical)?(this.tiles[String(Ld.tileID.wrap)]=Ld,Ld.buckets={},Md(null)):(Ld.state="errored",Md(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Nd={vector:class extends a.Evented{constructor(b,c,d,e){if(super(),this.id=b,this.dispatcher=d,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.extend(this,a.pick(c,["url","scheme","tileSize","promoteId"])),this._options=a.extend({type:"vector"},c),this._collectResourceTiming=c.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(e),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=Qc(this._options,this.map._requestManager,(b,c)=>{this._tileJSONRequest=null,this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(a.extend(this,c),c.bounds&&(this.tileBounds=new Rc(c.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(c.tiles,this.map._requestManager._customAccessToken),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(f){return!this.tileBounds||this.tileBounds.contains(f.canonical)}onAdd(g){this.map=g,this.load()}setSourceProperty(h){this._tileJSONRequest&&this._tileJSONRequest.cancel(),h();const i=this.map.style._getSourceCaches(this.id);for(const j of i)j.clearTiles();this.load()}setTiles(k){return this.setSourceProperty(()=>{this._options.tiles=k}),this}setUrl(l){return this.setSourceProperty(()=>{this.url=l,this._options.url=l}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}loadTile(m,n){const o=this.map._requestManager.normalizeTileURL(m.tileID.canonical.url(this.tiles,this.scheme)),p={request:this.map._requestManager.transformRequest(o,a.ResourceType.Tile),data:void 0,uid:m.uid,tileID:m.tileID,tileZoom:m.tileZoom,zoom:m.tileID.overscaledZ,tileSize:this.tileSize*m.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:m.isSymbolTile};if(p.request.collectResourceTiming=this._collectResourceTiming,m.actor&&"expired"!==m.state)"loading"===m.state?m.reloadCallback=n:m.request=m.actor.send("reloadTile",p,r.bind(this));else if(m.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)m.request=m.actor.send("loadTile",p,r.bind(this),void 0,!0);else{const q=a.loadVectorTile.call({deduped:this._deduped},p,(a,b)=>{a||!b?r.call(this,a):(p.data={cacheControl:b.cacheControl,expires:b.expires,rawData:b.rawData.slice(0)},m.actor&&m.actor.send("loadTile",p,r.bind(this),void 0,!0))},!0);m.request={cancel:q}}function r(b,c){return delete m.request,m.aborted?n(null):b&&404!==b.status?n(b):(c&&c.resourceTiming&&(m.resourceTiming=c.resourceTiming),this.map._refreshExpiredTiles&&c&&m.setExpiryData(c),m.loadVectorData(c,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(m.reloadCallback&&(this.loadTile(m,m.reloadCallback),m.reloadCallback=null)))}}abortTile(s){s.request&&(s.request.cancel(),delete s.request),s.actor&&s.actor.send("abortTile",{uid:s.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:ad,"raster-dem":class extends ad{constructor(b,c,d,e){super(b,c,d,e),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},c),this.encoding=c.encoding||"mapbox"}loadTile(f,g){const h=this.map._requestManager.normalizeTileURL(f.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(a,b){a&&(f.state="errored",g(a)),b&&(f.dem=b,f.dem.onDeserialize(),f.needsHillshadePrepare=!0,f.needsDEMTextureUpload=!0,f.state="loaded",g(null))}f.request=a.getImage(this.map._requestManager.transformRequest(h,a.ResourceType.Tile),(function(b,c,d,e){if(delete f.request,f.aborted)f.state="unloaded",g(null);else if(b)f.state="errored",g(b);else if(c){this.map._refreshExpiredTiles&&f.setExpiryData({cacheControl:d,expires:e});const h=a.window.ImageBitmap&&c instanceof a.window.ImageBitmap&&(null==pd&&(pd=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.window.createImageBitmap),pd),j=1-(c.width-a.prevPowerOfTwo(c.width))/2;j<1||f.neighboringTiles||(f.neighboringTiles=this._getNeighboringTiles(f.tileID));const k=h?c:a.exported.getImageData(c,j),l={uid:f.uid,coord:f.tileID,source:this.id,rawImageData:k,encoding:this.encoding,padding:j};f.actor&&"expired"!==f.state||(f.actor=this.dispatcher.getActor(),f.actor.send("loadDEMTile",l,i.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(j){const k=j.canonical,l=Math.pow(2,k.z),m=(k.x-1+l)%l,n=0===k.x?j.wrap-1:j.wrap,o=(k.x+1+l)%l,p=k.x+1===l?j.wrap+1:j.wrap,q={};return q[new a.OverscaledTileID(j.overscaledZ,n,k.z,m,k.y).key]={backfilled:!1},q[new a.OverscaledTileID(j.overscaledZ,p,k.z,o,k.y).key]={backfilled:!1},k.y>0&&(q[new a.OverscaledTileID(j.overscaledZ,n,k.z,m,k.y-1).key]={backfilled:!1},q[new a.OverscaledTileID(j.overscaledZ,j.wrap,k.z,k.x,k.y-1).key]={backfilled:!1},q[new a.OverscaledTileID(j.overscaledZ,p,k.z,o,k.y-1).key]={backfilled:!1}),k.y+1{if(this._loaded=!0,this._pendingLoad=null,b)this.fire(new a.ErrorEvent(b));else{const d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&c&&c.resourceTiming&&c.resourceTiming[this.id]&&(d.resourceTiming=c.resourceTiming[this.id]),this.fire(new a.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(s,t){const u=s.actor?"reloadTile":"loadTile";s.actor=this.actor,s.request=this.actor.send(u,{type:this.type,uid:s.uid,tileID:s.tileID,tileZoom:s.tileZoom,zoom:s.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(a,b)=>(delete s.request,s.unloadVectorData(),s.aborted?t(null):a?t(a):(s.loadVectorData(b,this.map.painter,"reloadTile"===u),t(null))),void 0,"loadTile"===u)}abortTile(v){v.request&&(v.request.cancel(),delete v.request),v.aborted=!0}unloadTile(w){w.unloadVectorData(),this.actor.send("removeTile",{uid:w.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return a.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends rd{constructor(b,c,d,e){super(b,c,d,e),this.roundZoom=!0,this.type="video",this.options=c}load(){this._loaded=!1;const f=this.options;for(const g of(this.urls=[],f.urls))this.urls.push(this.map._requestManager.transformRequest(g,a.ResourceType.Source).url);a.getVideo(this.urls,(b,c)=>{this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(this.video=c,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(h){if(this.video){const i=this.video.seekable;hi.end(0)?this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=h}}getVideo(){return this.video}onAdd(j){this.map||(this.map=j,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const k=this.map.painter.context,l=k.gl;for(const m in this.texture?this.video.paused||(this.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE),l.texSubImage2D(l.TEXTURE_2D,0,0,0,l.RGBA,l.UNSIGNED_BYTE,this.video)):(this.texture=new a.Texture(k,this.video,l.RGBA),this.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=k.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const n=this.tiles[m];"loaded"!==n.state&&(n.state="loaded",n.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:rd,canvas:class extends rd{constructor(b,c,d,e){super(b,c,d,e),c.coordinates?Array.isArray(c.coordinates)&&4===c.coordinates.length&&!c.coordinates.some(a=>!Array.isArray(a)||2!==a.length||a.some(a=>"number"!=typeof a))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,null,"\"coordinates\" property must be an array of 4 longitude/latitude array pairs"))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,null,"missing required property \"coordinates\""))),c.animate&&"boolean"!=typeof c.animate&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,null,"optional \"animate\" property must be a boolean value"))),c.canvas?"string"==typeof c.canvas||c.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,null,"\"canvas\" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance"))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${b}`,null,"missing required property \"canvas\""))),this.options=c,this.animate=void 0===c.animate||c.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof a.window.HTMLCanvasElement?this.options.canvas:a.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(f){this.map=f,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let g=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,g=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,g=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const h=this.map.painter.context,i=h.gl;for(const j in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=h.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(g||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(h,this.canvas,i.RGBA,{premultiply:!0}),this.tiles){const k=this.tiles[j];"loaded"!==k.state&&(k.state="loaded",k.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const l of[this.canvas.width,this.canvas.height])if(isNaN(l)||l<=0)return!0;return!1}}},Od=function(b,c,d,e){const f=new Nd[c.type](b,c,d,e);if(f.id!==b)throw new Error(`Expected Source id to be ${b} instead of ${f.id}`);return a.bindAll(["load","abort","unload","serialize","prepare"],f),f};function Pd(b,c){const d=a.identity([]);return a.scale(d,d,[.5*b.width,-(.5*b.height),1]),a.translate(d,d,[1,-1,0]),a.multiply$1(d,d,b.calculateProjMatrix(c.toUnwrapped()))}function Qd(a,b,c,d,e,f,g,h=!1){const i=a.tilesIn(d,g,h);i.sort(Sd);const j=[];for(const k of i)j.push({wrappedTileID:k.tile.tileID.wrapped().key,queryResults:k.tile.queryRenderedFeatures(b,c,a._state,k,e,f,Pd(a.transform,k.tile.tileID),h)});const l=function(a){const b={},c={};for(const d of a){const e=d.queryResults,f=d.wrappedTileID,g=c[f]=c[f]||{};for(const h in e){const i=e[h],j=g[h]=g[h]||{},k=b[h]=b[h]||[];for(const l of i)j[l.featureIndex]||(j[l.featureIndex]=!0,k.push(l))}}return b}(j);for(const m in l)l[m].forEach(b=>{const c=b.feature,d=a.getFeatureState(c.layer["source-layer"],c.id);c.source=c.layer.source,c.layer["source-layer"]&&(c.sourceLayer=c.layer["source-layer"]),c.state=d});return l}function Rd(a,b){const c=a.getRenderableIds().map(b=>a.getTileByID(b)),d=[],e={};for(let f=0;f{a.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ud]}numActive(){return Object.keys(this.active).length}}let Yd;function Zd(){return Yd||(Yd=new Vd),Yd}function $d(b,c){const d={};for(const e in b)"ref"!==e&&(d[e]=b[e]);return a.refProperties.forEach(a=>{a in c&&(d[a]=c[a])}),d}function _d(a){a=a.slice();const b=Object.create(null);for(let c=0;c0?(re-te)/ue:0;return this.points[se].mult(1-ve).add(this.points[pe].mult(ve))}}class we{constructor(xe,ye,ze){const Ae=this.boxCells=[],Be=this.circleCells=[];this.xCellCount=Math.ceil(xe/ze),this.yCellCount=Math.ceil(ye/ze);for(let Ce=0;Cethis.width||_e<0||Ze>this.height)return!af&&[];const cf=[];if(Ye<=0&&Ze<=0&&this.width<=$e&&this.height<=_e){if(af)return!0;for(let df=0;df0:cf}_queryCircle(jf,kf,lf,mf,nf){const of=jf-lf,pf=jf+lf,qf=kf-lf,rf=kf+lf;if(pf<0||of>this.width||rf<0||qf>this.height)return!mf&&[];const sf=[];return this._forEachCell(of,qf,pf,rf,this._queryCellCircle,sf,{hitTest:mf,circle:{x:jf,y:kf,radius:lf},seenUids:{box:{},circle:{}}},nf),mf?sf.length>0:sf}query(tf,uf,vf,wf,xf){return this._query(tf,uf,vf,wf,!1,xf)}hitTest(yf,zf,Af,Bf,Cf){return this._query(yf,zf,Af,Bf,!0,Cf)}hitTestCircle(Df,Ef,Ff,Gf){return this._queryCircle(Df,Ef,Ff,!0,Gf)}_queryCell(Hf,If,Jf,Kf,Lf,Mf,Nf,Of){const Pf=Nf.seenUids,Qf=this.boxCells[Lf];if(null!==Qf){const Rf=this.bboxes;for(const Sf of Qf)if(!Pf.box[Sf]){Pf.box[Sf]=!0;const Tf=4*Sf;if(Hf<=Rf[Tf+2]&&If<=Rf[Tf+3]&&Jf>=Rf[Tf+0]&&Kf>=Rf[Tf+1]&&(!Of||Of(this.boxKeys[Sf]))){if(Nf.hitTest)return Mf.push(!0),!0;Mf.push({key:this.boxKeys[Sf],x1:Rf[Tf],y1:Rf[Tf+1],x2:Rf[Tf+2],y2:Rf[Tf+3]})}}}const Uf=this.circleCells[Lf];if(null!==Uf){const Vf=this.circles;for(const Wf of Uf)if(!Pf.circle[Wf]){Pf.circle[Wf]=!0;const Xf=3*Wf;if(this._circleAndRectCollide(Vf[Xf],Vf[Xf+1],Vf[Xf+2],Hf,If,Jf,Kf)&&(!Of||Of(this.circleKeys[Wf]))){if(Nf.hitTest)return Mf.push(!0),!0;{const Yf=Vf[Xf],Zf=Vf[Xf+1],$f=Vf[Xf+2];Mf.push({key:this.circleKeys[Wf],x1:Yf-$f,y1:Zf-$f,x2:Yf+$f,y2:Zf+$f})}}}}}_queryCellCircle(_f,ag,bg,cg,dg,eg,fg,gg){const hg=fg.circle,ig=fg.seenUids,jg=this.boxCells[dg];if(null!==jg){const kg=this.bboxes;for(const lg of jg)if(!ig.box[lg]){ig.box[lg]=!0;const mg=4*lg;if(this._circleAndRectCollide(hg.x,hg.y,hg.radius,kg[mg+0],kg[mg+1],kg[mg+2],kg[mg+3])&&(!gg||gg(this.boxKeys[lg])))return eg.push(!0),!0}}const ng=this.circleCells[dg];if(null!==ng){const og=this.circles;for(const pg of ng)if(!ig.circle[pg]){ig.circle[pg]=!0;const qg=3*pg;if(this._circlesCollide(og[qg],og[qg+1],og[qg+2],hg.x,hg.y,hg.radius)&&(!gg||gg(this.circleKeys[pg])))return eg.push(!0),!0}}}_forEachCell(rg,sg,tg,ug,vg,wg,xg,yg){const zg=this._convertToXCellCoord(rg),Ag=this._convertToYCellCoord(sg),Bg=this._convertToXCellCoord(tg),Cg=this._convertToYCellCoord(ug);for(let Dg=zg;Dg<=Bg;Dg++)for(let Eg=Ag;Eg<=Cg;Eg++)if(vg.call(this,rg,sg,tg,ug,this.xCellCount*Eg+Dg,wg,xg,yg))return}_convertToXCellCoord(Fg){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(Fg*this.xScale)))}_convertToYCellCoord(Gg){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(Gg*this.yScale)))}_circlesCollide(Hg,Ig,Jg,Kg,Lg,Mg){const Ng=Kg-Hg,Og=Lg-Ig,Pg=Jg+Mg;return Pg*Pg>Ng*Ng+Og*Og}_circleAndRectCollide(Qg,Rg,Sg,Tg,Ug,Vg,Wg){const Xg=(Vg-Tg)/2,Yg=Math.abs(Qg-(Tg+Xg));if(Yg>Xg+Sg)return!1;const Zg=(Wg-Ug)/2,$g=Math.abs(Rg-(Ug+Zg));if($g>Zg+Sg)return!1;if(Yg<=Xg||$g<=Zg)return!0;const _g=Yg-Xg,ah=$g-Zg;return _g*_g+ah*ah<=Sg*Sg}}const bh=Math.tan(85*Math.PI/180);function ch(b,c,d,f,g,h){let i=a.create();if(d){if("globe"===g.projection.name)i=a.calculateGlobeMatrix(g,g.worldSize/g._projectionScaler,[0,0]),a.multiply$1(i,i,a.globeDenormalizeECEF(a.globeTileBounds(c)));else{const j=e([],h);i[0]=j[0],i[1]=j[1],i[4]=j[2],i[5]=j[3]}f||a.rotateZ(i,i,g.angle)}else a.multiply$1(i,g.labelPlaneMatrix,b);return i}function dh(b,c,d,e,f,g){if(d){if("globe"===f.projection.name){const h=ch(b,c,d,e,f,g);return a.invert(h,h),a.multiply$1(h,b,h),h}{const i=a.clone(b),j=a.identity([]);return j[0]=g[0],j[1]=g[1],j[4]=g[2],j[5]=g[3],a.multiply$1(i,i,j),e||a.rotateZ(i,i,-f.angle),i}}return f.glCoordMatrix}function eh(b,c,d=0){const e=[b.x,b.y,d,1];d?a.transformMat4$1(e,e,c):qh(e,e,c);const f=e[3];return{point:new a.pointGeometry(e[0]/f,e[1]/f),signedDistanceFromCamera:f}}function fh(a,b){return Math.min(.5+a/b*.5,1.5)}function gh(a,b){const c=a[0]/a[3],d=a[1]/a[3];return c>= -b[0]&&c<=b[0]&&d>= -b[1]&&d<=b[1]}function hh(b,c,d,e,f,g,h,i,j,k){const l=d.transform,m=e?b.textSizeData:b.iconSizeData,n=a.evaluateSizeForZoom(m,d.transform.zoom),o=[256/d.width*2+1,256/d.height*2+1],p=e?b.text.dynamicLayoutVertexArray:b.icon.dynamicLayoutVertexArray;p.clear();const q=b.lineVertexArray,r=e?b.text.placedSymbolArray:b.icon.placedSymbolArray,s=d.transform.width/d.transform.height;let t=!1;for(let u=0;uMath.abs(d.x-c.x)*e?{useVertical:!0}:b.writingMode===a.WritingMode.vertical?c.ybh})(c,d,e)?1===b.flipState?{needsFlipping:!0}:null:c.x>d.x?{needsFlipping:!0}:null}function kh(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){const s=c/24,t=b.lineOffsetX*s,u=b.lineOffsetY*s;let v;if(b.numGlyphs>1){const w=b.glyphStartIndex+b.numGlyphs,x=b.lineStartIndex,y=b.lineStartIndex+b.lineLength,z=ih(s,i,t,u,d,l,m,b,j,g,n,p,!1,q,r);if(!z)return{notEnoughRoom:!0};const A=eh(z.first.point,h).point,B=eh(z.last.point,h).point;if(e&&!d){const C=jh(b,A,B,o);if(b.flipState=C&&C.needsFlipping?1:2,C)return C}v=[z.first];for(let D=b.glyphStartIndex+1;D0?H.point:mh(m,G,E,1,f,void 0,q,r.canonical),o);if(b.flipState=I&&I.needsFlipping?1:2,I)return I}const J=nh(s*i.getoffsetX(b.glyphStartIndex),t,u,d,l,m,b.segment,b.lineStartIndex,b.lineStartIndex+b.lineLength,j,g,n,p,!1,!1,q,r);if(!J)return{notEnoughRoom:!0};v=[J]}for(const K of v)a.addDynamicAttributes(k,K.point,K.angle);return{}}function lh(b,c,d,e,f){const g=e.projectTilePoint(b.x,b.y,c);if(!f)return eh(g,d,g.z);const h=f(b);return eh(new a.pointGeometry(g.x+h[0],g.y+h[1]),d,g.z+h[2])}function mh(a,b,c,d,e,f,g,h){const i=lh(a.add(a.sub(b)._unit()),h,e,g,f).point,j=c.sub(i);return c.add(j._mult(d/j.mag()))}function nh(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){const s=e?b-c:b+c;let t=s>0?1:-1,u=0;e&&(t*=-1,u=Math.PI),t<0&&(u+=Math.PI);let v=t>0?i+h:i+h+1,w=f,x=f,y=0,z=0;const A=Math.abs(s),B=[],C=[];let D=g;const E=()=>{const b=v-t;return 0===y?g:new a.pointGeometry(k.getx(b),k.gety(b))},F=()=>mh(E(),D,x,A-y+1,l,n,q,r.canonical);for(;y+z<=A;){if((v+=t)=j)return null;if(x=w,B.push(w),o&&C.push(D||E()),void 0===(w=m[v])){D=new a.pointGeometry(k.getx(v),k.gety(v));const G=lh(D,r.canonical,l,q,n);w=G.signedDistanceFromCamera>0?m[v]=G.point:F()}else D=null;y+=z,z=x.dist(w)}p&&n&&(D=D||new a.pointGeometry(k.getx(v),k.gety(v)),m[v]=w=void 0===m[v]?w:F(),z=x.dist(w));const H=(A-y)/z,I=w.sub(x),J=I.mult(H)._add(x);d&&J._add(I._unit()._perp()._mult(d*t));const K=u+Math.atan2(w.y-x.y,w.x-x.x);return B.push(J),o&&(D=D||new a.pointGeometry(k.getx(v),k.gety(v)),C.push(function(b,c,d){const e=1-d;return new a.pointGeometry(b.x*e+c.x*d,b.y*e+c.y*d)}(C.length>0?C[C.length-1]:D,D,H))),{point:J,angle:K,path:B,tilePath:C}}const oh=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ph(a,b){for(let c=0;ca.sortKey-b.sortKey));this._currentPartIndex<$h.length;){const _h=$h[this._currentPartIndex];if(Wh.placeLayerBucketPart(_h,this._seenCrossTileIDs,Xh,0===_h.symbolInstanceStart),this._currentPartIndex++,Zh())return!0}return!1}}class ai{constructor(bi,ci,di,ei,fi,gi,hi,ii){this.placement=new class{constructor(b,c,d,e,f){this.transform=b.clone(),this.collisionIndex=new class{constructor(b,c,d=new we(b.width+200,b.height+200,25),e=new we(b.width+200,b.height+200,25)){this.transform=b,this.grid=d,this.ignoredGrid=e,this.pitchfactor=Math.cos(b._pitch)*b.cameraToCenterDistance,this.screenRightBoundary=b.width+100,this.screenBottomBoundary=b.height+100,this.gridRightBoundary=b.width+200,this.gridBottomBoundary=b.height+200,this.fogState=c}placeCollisionBox(f,g,h,i,j,k,l){let m=g.projectedAnchorX,n=g.projectedAnchorY,o=g.projectedAnchorZ;const p=g.elevation,q=g.tileID;if(p&&q){const r=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),s=r.upVector(q.canonical,g.tileAnchorX,g.tileAnchorY),t=r.upVectorScale(q.canonical);m+=s[0]*p*t,n+=s[1]*p*t,o+=s[2]*p*t}const u=this.projectAndGetPerspectiveRatio(k,m,n,o,g.tileID),v=j*u.perspectiveRatio,w=(g.x1*f+h.x-g.padding)*v+u.point.x,x=(g.y1*f+h.y-g.padding)*v+u.point.y,y=(g.x2*f+h.x+g.padding)*v+u.point.x,z=(g.y2*f+h.y+g.padding)*v+u.point.y,A=u.perspectiveRatio<=.55||u.aboveHorizon;return!this.isInsideGrid(w,x,y,z)|| !i&&this.grid.hitTest(w,x,y,z,l)||A?{box:[],offscreen:!1}:{box:[w,x,y,z],offscreen:this.isOffscreen(w,x,y,z)}}placeCollisionCircles(B,C,D,E,F,G,H,I,J,K,L,M,N,O){const P=[],Q=this.transform.elevation,R=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),S=Q?Q.getAtTileOffsetFunc(O,R):a=>[0,0,0],T=new a.pointGeometry(C.tileAnchorX,C.tileAnchorY),U=this.transform.projection.projectTilePoint(C.tileAnchorX,C.tileAnchorY,O.canonical),V=S(T),W=[U.x+V[0],U.y+V[1],U.z+V[2]],X=this.projectAndGetPerspectiveRatio(G,W[0],W[1],W[2],O),{perspectiveRatio:Y}=X,Z=(K?F/Y:F*Y)/a.ONE_EM,$=eh(new a.pointGeometry(W[0],W[1]),H,W[2]).point,_=X.signedDistanceFromCamera>0?ih(Z,E,C.lineOffsetX*Z,C.lineOffsetY*Z,!1,$,T,C,D,H,{},Q&&!K?S:null,K&&!!Q,this.transform.projection,O):null;let aa=!1,ba=!1,ca=!0;if(_&&!X.aboveHorizon){const da=.5*M*Y+N,ea=new a.pointGeometry(-100,-100),fa=new a.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),ga=new ie,ha=_.first,ia=_.last;let ja=[];for(let ka=ha.path.length-1;ka>=1;ka--)ja.push(ha.path[ka]);for(let la=1;la{const c=S(beh(a,I));ja=na.some(a=>a.signedDistanceFromCamera<=0)?[]:na.map(a=>a.point)}let oa=[];if(ja.length>0){const pa=ja[0].clone(),qa=ja[0].clone();for(let ra=1;ra=ea.x&&qa.x<=fa.x&&pa.y>=ea.y&&qa.y<=fa.y?[ja]:qa.xfa.x||qa.yfa.y?[]:a.clipLine([ja],ea.x,ea.y,fa.x,fa.y)}for(const sa of oa){ga.reset(sa,.25*da);let ta=0;ta=ga.length<=.5*da?1:Math.ceil(ga.paddedLength/ma)+1;for(let ua=0;ua0){a.transformMat4$1(ib,ib,db);let kb=!1;this.fogState&&hb&&(kb=(function(b,c,d,e,f,g){const h=g.calculateFogTileMatrix(f),i=[c,d,e];return a.transformMat4(i,i,h),Ja(b,i,g.pitch,g._fov)})(this.fogState,eb,fb,gb||0,hb.toUnwrapped(),this.transform)>.9),jb=ib[2]>ib[3]||kb}else qh(ib,ib,db);return{point:new a.pointGeometry((ib[0]/ib[3]+1)/2*this.transform.width+100,(-ib[1]/ib[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/ib[3]*.5,1.5),signedDistanceFromCamera:ib[3],aboveHorizon:jb}}isOffscreen(lb,mb,nb,ob){return nb<100||lb>=this.screenRightBoundary||ob<100||mb>this.screenBottomBoundary}isInsideGrid(pb,qb,rb,sb){return rb>=0&&pb=0&&qba.collisionGroupID===c}}return this.collisionGroups[b]}}(d),this.collisionCircleArrays={},this.prevPlacement=e,e&&(e.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(g,h,i,j){const k=i.getBucket(h),l=i.latestFeatureIndex;if(!k||!l||h.id!==k.layerIds[0])return;const m=k.layers[0].layout,n=i.collisionBoxArray,o=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),p=i.tileSize/a.EXTENT,q=i.tileID.toUnwrapped(),r=this.transform.calculateProjMatrix(q),s="map"===m.get("text-pitch-alignment"),t="map"===m.get("text-rotation-alignment");h.compileFilter();const u=h.dynamicFilter(),v=h.dynamicFilterNeedsFeature(),w=this.transform.calculatePixelsToTileUnitsMatrix(i),x=ch(r,i.tileID.canonical,s,t,this.transform,w);let y=null;if(s){const z=dh(r,i.tileID.canonical,s,t,this.transform,w);y=a.multiply$1([],this.transform.labelPlaneMatrix,z)}let A=null;u&&i.latestFeatureIndex&&(A={unwrappedTileID:q,dynamicFilter:u,dynamicFilterNeedsFeature:v,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[k.bucketInstanceId]=new Jh(k.bucketInstanceId,l,k.sourceLayerIndex,k.index,i.tileID);const B={bucket:k,layout:m,posMatrix:r,textLabelPlaneMatrix:x,labelToScreenMatrix:y,clippingData:A,scale:o,textPixelRatio:p,holdingForFade:i.holdingForFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(k.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(k.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(k.sourceID)};if(j)for(const C of k.sortKeyRanges){const{sortKey:D,symbolInstanceStart:E,symbolInstanceEnd:F}=C;g.push({sortKey:D,symbolInstanceStart:E,symbolInstanceEnd:F,parameters:B})}else g.push({symbolInstanceStart:0,symbolInstanceEnd:k.symbolInstances.length,parameters:B})}attemptAnchorPlacement(G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X){const Y=[R.textOffset0,R.textOffset1],Z=Ph(G,I,J,Y,K),$=this.collisionIndex.placeCollisionBox(K,H,Qh(Z.x,Z.y,L,M,this.transform.angle),Q,N,O,P.predicate);if((!V||0!==this.collisionIndex.placeCollisionBox(T.getSymbolInstanceIconSize(X,this.transform.zoom,S),V,Qh(Z.x,Z.y,L,M,this.transform.angle),Q,N,O,P.predicate).box.length)&&$.box.length>0){let _;return this.prevPlacement&&this.prevPlacement.variableOffsets[R.crossTileID]&&this.prevPlacement.placements[R.crossTileID]&&this.prevPlacement.placements[R.crossTileID].text&&(_=this.prevPlacement.variableOffsets[R.crossTileID].anchor),this.variableOffsets[R.crossTileID]={textOffset:Y,width:I,height:J,anchor:G,textScale:K,prevAnchor:_},this.markUsedJustification(T,G,R,U),T.allowVerticalPlacement&&(this.markUsedOrientation(T,U,R),this.placedOrientations[R.crossTileID]=U),{shift:Z,placedGlyphBoxes:$}}}placeLayerBucketPart(aa,ba,ca,da){const{bucket:ea,layout:fa,posMatrix:ga,textLabelPlaneMatrix:ha,labelToScreenMatrix:ia,clippingData:ja,textPixelRatio:ka,holdingForFade:la,collisionBoxArray:ma,partiallyEvaluatedTextSize:na,partiallyEvaluatedIconSize:oa,collisionGroup:pa}=aa.parameters,qa=fa.get("text-optional"),ra=fa.get("icon-optional"),sa=fa.get("text-allow-overlap"),ta=fa.get("icon-allow-overlap"),ua="map"===fa.get("text-rotation-alignment"),va="map"===fa.get("text-pitch-alignment"),wa="none"!==fa.get("icon-text-fit"),xa="viewport-y"===fa.get("symbol-z-order"),ya=sa&&(ta||!ea.hasIconData()||ra),za=ta&&(sa||!ea.hasTextData()||qa);!ea.collisionArrays&&ma&&ea.deserializeCollisionBoxes(ma),ca&&da&&ea.updateCollisionDebugBuffers(this.transform.zoom,ma);const Aa=(b,c,d)=>{if(ja){const e={zoom:this.transform.zoom,pitch:this.transform.pitch};let f=null;if(ja.dynamicFilterNeedsFeature){const g=this.retainedQueryData[ea.bucketInstanceId];f=ja.featureIndex.loadFeature({featureIndex:b.featureIndex,bucketIndex:g.bucketIndex,sourceLayerIndex:g.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,ja.dynamicFilter)(e,f,this.retainedQueryData[ea.bucketInstanceId].tileID.canonical,new a.pointGeometry(b.tileAnchorX,b.tileAnchorY),this.transform.calculateDistanceTileData(ja.unwrappedTileID)))return this.placements[b.crossTileID]=new Dh(!1,!1,!1,!0),void(ba[b.crossTileID]=!0)}if(ba[b.crossTileID])return;if(la)return void(this.placements[b.crossTileID]=new Dh(!1,!1,!1));let h=!1,i=!1,j=!0,k=null,l={box:null,offscreen:null},m={box:null,offscreen:null},n=null,o=null,p=null,q=0,r=0,s=0;d.textFeatureIndex?q=d.textFeatureIndex:b.useRuntimeCollisionCircles&&(q=b.featureIndex),d.verticalTextFeatureIndex&&(r=d.verticalTextFeatureIndex);const t=a=>{a.tileID=this.retainedQueryData[ea.bucketInstanceId].tileID,(this.transform.elevation||a.elevation)&&(a.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[ea.bucketInstanceId].tileID,a.tileAnchorX,a.tileAnchorY):0)},u=d.textBox;if(u){t(u);const v=c=>{let d=a.WritingMode.horizontal;if(ea.allowVerticalPlacement&&!c&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[b.crossTileID];e&&(this.placedOrientations[b.crossTileID]=e,d=e,this.markUsedOrientation(ea,d,b))}return d},w=(c,e)=>{if(ea.allowVerticalPlacement&&b.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const f of ea.writingModes)if(f===a.WritingMode.vertical?m=l=e():l=c(),l&&l.box&&l.box.length)break}else l=c()};if(fa.get("text-variable-anchor")){let x=fa.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[b.crossTileID]){const y=this.prevPlacement.variableOffsets[b.crossTileID];x.indexOf(y.anchor)>0&&(x=x.filter(a=>a!==y.anchor)).unshift(y.anchor)}const z=(a,d,e)=>{const f=ea.getSymbolInstanceTextSize(na,b,this.transform.zoom,c),g=(a.x2-a.x1)*f+2*a.padding,i=(a.y2-a.y1)*f+2*a.padding,j=wa&&!ta?d:null;j&&t(j);let l={box:[],offscreen:!1};const m=sa?2*x.length:x.length;for(let n=0;n=x.length,b,c,ea,e,j,na,oa);if(o&&(l=o.placedGlyphBoxes)&&l.box&&l.box.length){h=!0,k=o.shift;break}}return l};w(()=>z(u,d.iconBox,a.WritingMode.horizontal),()=>{const c=d.verticalTextBox;return c&&t(c),ea.allowVerticalPlacement&&!(l&&l.box&&l.box.length)&&b.numVerticalGlyphVertices>0&&c?z(c,d.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null}}),l&&(h=l.box,j=l.offscreen);const A=v(l&&l.box);if(!h&&this.prevPlacement){const B=this.prevPlacement.variableOffsets[b.crossTileID];B&&(this.variableOffsets[b.crossTileID]=B,this.markUsedJustification(ea,B.anchor,b,A))}}else{const C=(d,e)=>{const f=ea.getSymbolInstanceTextSize(na,b,this.transform.zoom,c),g=this.collisionIndex.placeCollisionBox(f,d,new a.pointGeometry(0,0),sa,ka,ga,pa.predicate);return g&&g.box&&g.box.length&&(this.markUsedOrientation(ea,e,b),this.placedOrientations[b.crossTileID]=e),g};w(()=>C(u,a.WritingMode.horizontal),()=>{const c=d.verticalTextBox;return ea.allowVerticalPlacement&&b.numVerticalGlyphVertices>0&&c?(t(c),C(c,a.WritingMode.vertical)):{box:null,offscreen:null}}),v(l&&l.box&&l.box.length)}}if(h=(n=l)&&n.box&&n.box.length>0,j=n&&n.offscreen,b.useRuntimeCollisionCircles){const D=ea.text.placedSymbolArray.get(b.centerJustifiedTextSymbolIndex>=0?b.centerJustifiedTextSymbolIndex:b.verticalPlacedTextSymbolIndex),E=a.evaluateSizeForFeature(ea.textSizeData,na,D),F=fa.get("text-padding");o=this.collisionIndex.placeCollisionCircles(sa,D,ea.lineVertexArray,ea.glyphOffsetArray,E,ga,ha,ia,ca,va,pa.predicate,b.collisionCircleDiameter*E/a.ONE_EM,F,this.retainedQueryData[ea.bucketInstanceId].tileID),h=sa||o.circles.length>0&&!o.collisionDetected,j=j&&o.offscreen}if(d.iconFeatureIndex&&(s=d.iconFeatureIndex),d.iconBox){const G=b=>{t(b);const d=wa&&k?Qh(k.x,k.y,ua,va,this.transform.angle):new a.pointGeometry(0,0),e=ea.getSymbolInstanceIconSize(oa,this.transform.zoom,c);return this.collisionIndex.placeCollisionBox(e,b,d,ta,ka,ga,pa.predicate)};i=m&&m.box&&m.box.length&&d.verticalIconBox?(p=G(d.verticalIconBox)).box.length>0:(p=G(d.iconBox)).box.length>0,j=j&&p.offscreen}const H=qa||0===b.numHorizontalGlyphVertices&&0===b.numVerticalGlyphVertices,I=ra||0===b.numIconVertices;if(H||I?I?H||(i=i&&h):h=i&&h:i=h=i&&h,h&&n&&n.box&&this.collisionIndex.insertCollisionBox(n.box,fa.get("text-ignore-placement"),ea.bucketInstanceId,m&&m.box&&r?r:q,pa.ID),i&&p&&this.collisionIndex.insertCollisionBox(p.box,fa.get("icon-ignore-placement"),ea.bucketInstanceId,s,pa.ID),o&&(h&&this.collisionIndex.insertCollisionCircles(o.circles,fa.get("text-ignore-placement"),ea.bucketInstanceId,q,pa.ID),ca)){const J=ea.bucketInstanceId;let K=this.collisionCircleArrays[J];void 0===K&&(K=this.collisionCircleArrays[J]=new Ih);for(let L=0;L=0;--Ca){const Da=Ba[Ca];Aa(ea.symbolInstances.get(Da),Da,ea.collisionArrays[Da])}}else for(let Ea=aa.symbolInstanceStart;Ea=0&&(Ga.text.placedSymbolArray.get(Na).crossTileID=La>=0&&Na!==La?0:Ia.crossTileID)}markUsedOrientation(Oa,Pa,Qa){const Ra=Pa===a.WritingMode.horizontal||Pa===a.WritingMode.horizontalOnly?Pa:0,Sa=Pa===a.WritingMode.vertical?Pa:0,Ta=[Qa.leftJustifiedTextSymbolIndex,Qa.centerJustifiedTextSymbolIndex,Qa.rightJustifiedTextSymbolIndex];for(const Ua of Ta)Oa.text.placedSymbolArray.get(Ua).placedOrientation=Ra;Qa.verticalPlacedTextSymbolIndex&&(Oa.text.placedSymbolArray.get(Qa.verticalPlacedTextSymbolIndex).placedOrientation=Sa)}commit(Va){this.commitTime=Va,this.zoomAtLastRecencyCheck=this.transform.zoom;const Wa=this.prevPlacement;let Xa=!1;this.prevZoomAdjustment=Wa?Wa.zoomAdjustment(this.transform.zoom):0;const Ya=Wa?Wa.symbolFadeChange(Va):1,Za=Wa?Wa.opacities:{},$a=Wa?Wa.variableOffsets:{},_a=Wa?Wa.placedOrientations:{};for(const ab in this.placements){const bb=this.placements[ab],cb=Za[ab];cb?(this.opacities[ab]=new wh(cb,Ya,bb.text,bb.icon,null,bb.clipped),Xa=Xa||bb.text!==cb.text.placed||bb.icon!==cb.icon.placed):(this.opacities[ab]=new wh(null,Ya,bb.text,bb.icon,bb.skipFade,bb.clipped),Xa=Xa||bb.text||bb.icon)}for(const db in Za){const eb=Za[db];if(!this.opacities[db]){const fb=new wh(eb,Ya,!1,!1);fb.isHidden()||(this.opacities[db]=fb,Xa=Xa||eb.text.placed||eb.icon.placed)}}for(const gb in $a)this.variableOffsets[gb]||!this.opacities[gb]||this.opacities[gb].isHidden()||(this.variableOffsets[gb]=$a[gb]);for(const hb in _a)this.placedOrientations[hb]||!this.opacities[hb]||this.opacities[hb].isHidden()||(this.placedOrientations[hb]=_a[hb]);Xa?this.lastPlacementChangeTime=Va:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=Wa?Wa.lastPlacementChangeTime:Va)}updateLayerOpacities(ib,jb){const kb={};for(const lb of jb){const mb=lb.getBucket(ib);mb&&lb.latestFeatureIndex&&ib.id===mb.layerIds[0]&&this.updateBucketOpacities(mb,kb,lb.collisionBoxArray)}}updateBucketOpacities(nb,ob,pb){nb.hasTextData()&&nb.text.opacityVertexArray.clear(),nb.hasIconData()&&nb.icon.opacityVertexArray.clear(),nb.hasIconCollisionBoxData()&&nb.iconCollisionBox.collisionVertexArray.clear(),nb.hasTextCollisionBoxData()&&nb.textCollisionBox.collisionVertexArray.clear();const qb=nb.layers[0].layout,rb=!!nb.layers[0].dynamicFilter(),sb=new wh(null,0,!1,!1,!0),tb=qb.get("text-allow-overlap"),ub=qb.get("icon-allow-overlap"),vb=qb.get("text-variable-anchor"),wb="map"===qb.get("text-rotation-alignment"),xb="map"===qb.get("text-pitch-alignment"),yb="none"!==qb.get("icon-text-fit"),zb=new wh(null,0,tb&&(ub||!nb.hasIconData()||qb.get("icon-optional")),ub&&(tb||!nb.hasTextData()||qb.get("text-optional")),!0);!nb.collisionArrays&&pb&&(nb.hasIconCollisionBoxData()||nb.hasTextCollisionBoxData())&&nb.deserializeCollisionBoxes(pb);const Ab=(a,b,c)=>{for(let d=0;d0||Fb>0,Jb=Db.numIconVertices>0,Kb=this.placedOrientations[Db.crossTileID],Lb=Kb===a.WritingMode.vertical,Mb=Kb===a.WritingMode.horizontal||Kb===a.WritingMode.horizontalOnly;if(!Ib&&!Jb||Hb.isHidden()||Bb++,Ib){const Nb=Sh(Hb.text);Ab(nb.text,Eb,Lb?0:Nb),Ab(nb.text,Fb,Mb?0:Nb);const Ob=Hb.text.isHidden();[Db.rightJustifiedTextSymbolIndex,Db.centerJustifiedTextSymbolIndex,Db.leftJustifiedTextSymbolIndex].forEach(a=>{a>=0&&(nb.text.placedSymbolArray.get(a).hidden=Ob||Lb?1:0)}),Db.verticalPlacedTextSymbolIndex>=0&&(nb.text.placedSymbolArray.get(Db.verticalPlacedTextSymbolIndex).hidden=Ob||Mb?1:0);const Pb=this.variableOffsets[Db.crossTileID];Pb&&this.markUsedJustification(nb,Pb.anchor,Db,Kb);const Qb=this.placedOrientations[Db.crossTileID];Qb&&(this.markUsedJustification(nb,"left",Db,Qb),this.markUsedOrientation(nb,Qb,Db))}if(Jb){const Rb=Sh(Hb.icon);Db.placedIconSymbolIndex>=0&&(Ab(nb.icon,Db.numIconVertices,Lb?0:Rb),nb.icon.placedSymbolArray.get(Db.placedIconSymbolIndex).hidden=Hb.icon.isHidden()),Db.verticalPlacedIconSymbolIndex>=0&&(Ab(nb.icon,Db.numVerticalIconVertices,Mb?0:Rb),nb.icon.placedSymbolArray.get(Db.verticalPlacedIconSymbolIndex).hidden=Hb.icon.isHidden())}if(nb.hasIconCollisionBoxData()||nb.hasTextCollisionBoxData()){const Sb=nb.collisionArrays[Cb];if(Sb){let Tb=new a.pointGeometry(0,0),Ub=!0;if(Sb.textBox||Sb.verticalTextBox){if(vb){const Vb=this.variableOffsets[Gb];Vb?(Tb=Ph(Vb.anchor,Vb.width,Vb.height,Vb.textOffset,Vb.textScale),wb&&Tb._rotate(xb?this.transform.angle:-this.transform.angle)):Ub=!1}rb&&(Ub=!Hb.clipped),Sb.textBox&&Rh(nb.textCollisionBox.collisionVertexArray,Hb.text.placed,!Ub||Lb,Tb.x,Tb.y),Sb.verticalTextBox&&Rh(nb.textCollisionBox.collisionVertexArray,Hb.text.placed,!Ub||Mb,Tb.x,Tb.y)}const Wb=Ub&&Boolean(!Mb&&Sb.verticalIconBox);Sb.iconBox&&Rh(nb.iconCollisionBox.collisionVertexArray,Hb.icon.placed,Wb,yb?Tb.x:0,yb?Tb.y:0),Sb.verticalIconBox&&Rh(nb.iconCollisionBox.collisionVertexArray,Hb.icon.placed,!Wb,yb?Tb.x:0,yb?Tb.y:0)}}}if(nb.fullyClipped=0===Bb,nb.sortFeatures(this.transform.angle),this.retainedQueryData[nb.bucketInstanceId]&&(this.retainedQueryData[nb.bucketInstanceId].featureSortOrder=nb.featureSortOrder),nb.hasTextData()&&nb.text.opacityVertexBuffer&&nb.text.opacityVertexBuffer.updateData(nb.text.opacityVertexArray),nb.hasIconData()&&nb.icon.opacityVertexBuffer&&nb.icon.opacityVertexBuffer.updateData(nb.icon.opacityVertexArray),nb.hasIconCollisionBoxData()&&nb.iconCollisionBox.collisionVertexBuffer&&nb.iconCollisionBox.collisionVertexBuffer.updateData(nb.iconCollisionBox.collisionVertexArray),nb.hasTextCollisionBoxData()&&nb.textCollisionBox.collisionVertexBuffer&&nb.textCollisionBox.collisionVertexBuffer.updateData(nb.textCollisionBox.collisionVertexArray),nb.bucketInstanceId in this.collisionCircleArrays){const Xb=this.collisionCircleArrays[nb.bucketInstanceId];nb.placementInvProjMatrix=Xb.invProjMatrix,nb.placementViewportMatrix=Xb.viewportMatrix,nb.collisionCircleArray=Xb.circles,delete this.collisionCircleArrays[nb.bucketInstanceId]}}symbolFadeChange(Yb){return 0===this.fadeDuration?1:(Yb-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(Zb){return Math.max(0,(this.transform.zoom-Zb)/1.5)}hasTransitions($b){return this.stale||$b-this.lastPlacementChangeTime_b}setStale(){this.stale=!0}}(bi,fi,gi,hi,ii),this._currentPlacementIndex=ci.length-1,this._forceFullPlacement=di,this._showCollisionBoxes=ei,this._done=!1}isDone(){return this._done}continuePlacement(ji,ki,li){const mi=a.exported.now(),ni=()=>{const b=a.exported.now()-mi;return!this._forceFullPlacement&&b>2};for(;this._currentPlacementIndex>=0;){const oi=ki[ji[this._currentPlacementIndex]],pi=this.placement.collisionIndex.transform.zoom;if("symbol"===oi.type&&(!oi.minzoom||oi.minzoom<=pi)&&(!oi.maxzoom||oi.maxzoom>pi)){if(this._inProgressLayer||(this._inProgressLayer=new Th(oi)),this._inProgressLayer.continuePlacement(li[oi.source],this.placement,this._showCollisionBoxes,oi,ni))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(qi){return this.placement.commit(qi),this.placement}}const ri=512/a.EXTENT/2;class si{constructor(ti,ui,vi){this.tileID=ti,this.indexedSymbolInstances={},this.bucketInstanceId=vi;for(let wi=0;wiTi.overscaledZ)for(const $i in Zi){const _i=Zi[$i];_i.tileID.isChildOf(Ti)&&_i.findMatches(Ui.symbolInstances,Ti,Xi)}else{const aj=Zi[Ti.scaledTo(Number(Yi)).key];aj&&aj.findMatches(Ui.symbolInstances,Ti,Xi)}}for(let bj=0;bj{xj[a]=!0}),this.layerIndexes)xj[yj]||delete this.layerIndexes[yj]}}const zj=(b,c)=>a.emitValidationErrors(b,c&&c.filter(a=>"source.canvas"!==a.identifier)),Aj=a.pick(ae,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Bj=a.pick(ae,["setCenter","setZoom","setBearing","setPitch"]),Cj=function(){const b={},c=a.spec.$version;for(const d in a.spec.$root){const e=a.spec.$root[d];if(e.required){let f=null;null!=(f="version"===d?c:"array"===e.type?[]:{})&&(b[d]=f)}}return b}(),Dj={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Ej extends a.Evented{constructor(Fj,Gj={}){super(),this.map=Fj,this.dispatcher=new cb(Zd(),this),this.imageManager=new n,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(Fj._requestManager,Gj.localFontFamily?a.LocalGlyphMode.all:Gj.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,Gj.localFontFamily||Gj.localIdeographFontFamily),this.lineAtlas=new a.LineAtlas(256,512),this.crossTileSymbolIndex=new mj,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new a.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",a.getReferrer());const Hj=this;this._rtlTextPluginCallback=Ej.registerForPluginStateChange(b=>{Hj.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:b.pluginStatus,pluginURL:b.pluginURL},(b,c)=>{if(a.triggerPluginCompletionEvent(b),c&&c.every(a=>a))for(const d in Hj._sourceCaches){const e=Hj._sourceCaches[d],f=e.getSource().type;"vector"!==f&&"geojson"!==f||e.reload()}})}),this.on("data",a=>{if("source"!==a.dataType||"metadata"!==a.sourceDataType)return;const b=this.getSource(a.sourceId);if(b&&b.vectorLayerIds)for(const c in this._layers){const d=this._layers[c];d.source===b.id&&this._validateLayer(d)}})}loadURL(Ij,Jj={}){this.fire(new a.Event("dataloading",{dataType:"style"}));const Kj="boolean"==typeof Jj.validate?Jj.validate:!a.isMapboxURL(Ij);Ij=this.map._requestManager.normalizeStyleURL(Ij,Jj.accessToken);const Lj=this.map._requestManager.transformRequest(Ij,a.ResourceType.Style);this._request=a.getJSON(Lj,(b,c)=>{this._request=null,b?this.fire(new a.ErrorEvent(b)):c&&this._load(c,Kj)})}loadJSON(Mj,Nj={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(Mj,!1!==Nj.validate)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(Cj,!1)}_updateLayerCount(Oj,Pj){const Qj=Pj?1:-1;Oj.is3D()&&(this._num3DLayers+=Qj),"circle"===Oj.type&&(this._numCircleLayers+=Qj),"symbol"===Oj.type&&(this._numSymbolLayers+=Qj)}_load(Rj,Sj){if(Sj&&zj(this,a.validateStyle(Rj)))return;for(const Tj in this._loaded=!0,this.stylesheet=Rj,this.updateProjection(),Rj.sources)this.addSource(Tj,Rj.sources[Tj],{validate:!1});this._changed=!1,Rj.sprite?this._loadSprite(Rj.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(Rj.glyphs);const Uj=_d(this.stylesheet.layers);for(let Vj of(this._order=Uj.map(a=>a.id),this._layers={},this._serializedLayers={},Uj))(Vj=a.createStyleLayer(Vj)).setEventedParent(this,{layer:{id:Vj.id}}),this._layers[Vj.id]=Vj,this._serializedLayers[Vj.id]=Vj.serialize(),this._updateLayerCount(Vj,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new oa(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new a.Event("data",{dataType:"style"})),this.fire(new a.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(Wj){Wj?this.stylesheet.projection=Wj:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const Xj=this.map.transform.projection,Yj=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),Zj=this.map.transform.projection;if(this._loaded&&(Zj.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),Yj){if(Zj.isReprojectedInTileSpace||Xj.isReprojectedInTileSpace)for(const $j in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[$j].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(_j){this._spriteRequest=(function(b,c,d){let e,f,g;const h=a.exported.devicePixelRatio>1?"@2x":"";let i=a.getJSON(c.transformRequest(c.normalizeSpriteURL(b,h,".json"),a.ResourceType.SpriteJSON),(a,b)=>{i=null,g||(g=a,e=b,k())}),j=a.getImage(c.transformRequest(c.normalizeSpriteURL(b,h,".png"),a.ResourceType.SpriteImage),(a,b)=>{j=null,g||(g=a,f=b,k())});function k(){if(g)d(g);else if(e&&f){const b=a.exported.getImageData(f),c={};for(const h in e){const{width:i,height:j,x:k,y:l,sdf:m,pixelRatio:n,stretchX:o,stretchY:p,content:q}=e[h],r=new a.RGBAImage({width:i,height:j});a.RGBAImage.copy(b,r,{x:k,y:l},{x:0,y:0},{width:i,height:j}),c[h]={data:r,pixelRatio:n,sdf:m,stretchX:o,stretchY:p,content:q}}d(null,c)}}return{cancel(){i&&(i.cancel(),i=null),j&&(j.cancel(),j=null)}}})(_j,this.map._requestManager,(b,c)=>{if(this._spriteRequest=null,b)this.fire(new a.ErrorEvent(b));else if(c)for(const d in c)this.imageManager.addImage(d,c[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new a.Event("data",{dataType:"style"}))})}_validateLayer(ak){const bk=this.getSource(ak.source);if(!bk)return;const ck=ak.sourceLayer;ck&&("geojson"===bk.type||bk.vectorLayerIds&& -1===bk.vectorLayerIds.indexOf(ck))&&this.fire(new a.ErrorEvent(new Error(`Source layer "${ck}" does not exist on source "${bk.id}" as specified by style layer "${ak.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const dk in this._sourceCaches)if(!this._sourceCaches[dk].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(ek){const fk=[];for(const gk of ek){const hk=this._layers[gk];"custom"!==hk.type&&fk.push(hk.serialize())}return fk}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const ik in this._sourceCaches)if(this._sourceCaches[ik].hasTransition())return!0;for(const jk in this._layers)if(this._layers[jk].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(kk){return!!this.terrain&&Dj[kk.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(lk){if(!this._loaded)return;const mk=this._changed;if(this._changed){const nk=Object.keys(this._updatedLayers),ok=Object.keys(this._removedLayers);for(const pk in(nk.length||ok.length)&&this._updateWorkerLayers(nk,ok),this._updatedSources){const qk=this._updatedSources[pk];"reload"===qk?this._reloadSource(pk):"clear"===qk&&this._clearSource(pk)}for(const rk in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[rk].updateTransitions(lk);this.light.updateTransitions(lk),this.fog&&this.fog.updateTransitions(lk),this._resetUpdates()}const sk={};for(const tk in this._sourceCaches){const uk=this._sourceCaches[tk];sk[tk]=uk.used,uk.used=!1}for(const vk of this._order){const wk=this._layers[vk];if(wk.recalculate(lk,this._availableImages),!wk.isHidden(lk.zoom)){const xk=this._getLayerSourceCache(wk);xk&&(xk.used=!0)}const yk=this.map.painter;if(yk){const zk=wk.getProgramIds();if(!zk)continue;const Ak=wk.getProgramConfiguration(lk.zoom);for(const Bk of zk)yk.useProgram(Bk,Ak)}}for(const Ck in sk){const Dk=this._sourceCaches[Ck];sk[Ck]!==Dk.used&&Dk.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:Dk.getSource().id}))}this.light.recalculate(lk),this.terrain&&this.terrain.recalculate(lk),this.fog&&this.fog.recalculate(lk),this.z=lk.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),mk&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const Ek=Object.keys(this._changedImages);if(Ek.length){for(const Fk in this._sourceCaches)this._sourceCaches[Fk].reloadTilesForDependencies(["icons","patterns"],Ek);this._changedImages={}}}_updateWorkerLayers(Gk,Hk){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(Gk),removedIds:Hk})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(Ik){if(this._checkLoaded(),zj(this,a.validateStyle(Ik)))return!1;(Ik=a.clone$1(Ik)).layers=_d(Ik.layers);const Jk=(function(a,b){if(!a)return[{command:ae.setStyle,args:[b]}];let c=[];try{if(!f(a.version,b.version))return[{command:ae.setStyle,args:[b]}];f(a.center,b.center)||c.push({command:ae.setCenter,args:[b.center]}),f(a.zoom,b.zoom)||c.push({command:ae.setZoom,args:[b.zoom]}),f(a.bearing,b.bearing)||c.push({command:ae.setBearing,args:[b.bearing]}),f(a.pitch,b.pitch)||c.push({command:ae.setPitch,args:[b.pitch]}),f(a.sprite,b.sprite)||c.push({command:ae.setSprite,args:[b.sprite]}),f(a.glyphs,b.glyphs)||c.push({command:ae.setGlyphs,args:[b.glyphs]}),f(a.transition,b.transition)||c.push({command:ae.setTransition,args:[b.transition]}),f(a.light,b.light)||c.push({command:ae.setLight,args:[b.light]}),f(a.fog,b.fog)||c.push({command:ae.setFog,args:[b.fog]}),f(a.projection,b.projection)||c.push({command:ae.setProjection,args:[b.projection]});const d={},e=[];!function(a,b,c,d){let e;for(e in b=b||{},a=a||{})a.hasOwnProperty(e)&&(b.hasOwnProperty(e)||ce(e,c,d));for(e in b)b.hasOwnProperty(e)&&(a.hasOwnProperty(e)?f(a[e],b[e])||("geojson"===a[e].type&&"geojson"===b[e].type&&ee(a,b,e)?c.push({command:ae.setGeoJSONSourceData,args:[e,b[e].data]}):de(e,b,c,d)):be(e,b,c))}(a.sources,b.sources,e,d);const g=[];a.layers&&a.layers.forEach(a=>{d[a.source]?c.push({command:ae.removeLayer,args:[a.id]}):g.push(a)});let h=a.terrain;h&&d[h.source]&&(c.push({command:ae.setTerrain,args:[void 0]}),h=void 0),c=c.concat(e),f(h,b.terrain)||c.push({command:ae.setTerrain,args:[b.terrain]}),(function(a,b,c){b=b||[];const d=(a=a||[]).map(ge),e=b.map(ge),g=a.reduce(he,{}),h=b.reduce(he,{}),i=d.slice(),j=Object.create(null);let k,l,m,n,o,p,q;for(k=0,l=0;k!(a.command in Bj));if(0===Jk.length)return!1;const Kk=Jk.filter(a=>!(a.command in Aj));if(Kk.length>0)throw new Error(`Unimplemented: ${Kk.map(a=>a.command).join(", ")}.`);return Jk.forEach(a=>{"setTransition"!==a.command&&this[a.command].apply(this,a.args)}),this.stylesheet=Ik,this.updateProjection(),!0}addImage(Lk,Mk){if(this.getImage(Lk))return this.fire(new a.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(Lk,Mk),this._afterImageUpdated(Lk)}updateImage(Nk,Ok){this.imageManager.updateImage(Nk,Ok)}getImage(Pk){return this.imageManager.getImage(Pk)}removeImage(Qk){if(!this.getImage(Qk))return this.fire(new a.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(Qk),this._afterImageUpdated(Qk)}_afterImageUpdated(Rk){this._availableImages=this.imageManager.listImages(),this._changedImages[Rk]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new a.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(Sk,Tk,Uk={}){if(this._checkLoaded(),void 0!==this.getSource(Sk))throw new Error("There is already a source with this ID");if(!Tk.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(Tk).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(Tk.type)>=0&&this._validate(a.validateStyle.source,`sources.${Sk}`,Tk,null,Uk))return;this.map&&this.map._collectResourceTiming&&(Tk.collectResourceTiming=!0);const Vk=Od(Sk,Tk,this.dispatcher,this);Vk.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:Vk.serialize(),sourceId:Sk}));const Wk=b=>{const c=(b?"symbol:":"other:")+Sk,d=this._sourceCaches[c]=new a.SourceCache(c,Vk,b);(b?this._symbolSourceCaches:this._otherSourceCaches)[Sk]=d,d.style=this,d.onAdd(this.map)};Wk(!1),"vector"!==Tk.type&&"geojson"!==Tk.type||Wk(!0),Vk.onAdd&&Vk.onAdd(this.map),this._changed=!0}removeSource(Xk){this._checkLoaded();const Yk=this.getSource(Xk);if(void 0===Yk)throw new Error("There is no source with this ID");for(const Zk in this._layers)if(this._layers[Zk].source===Xk)return this.fire(new a.ErrorEvent(new Error(`Source "${Xk}" cannot be removed while layer "${Zk}" is using it.`)));if(this.terrain&&this.terrain.get().source===Xk)return this.fire(new a.ErrorEvent(new Error(`Source "${Xk}" cannot be removed while terrain is using it.`)));const $k=this._getSourceCaches(Xk);for(const _k of $k)delete this._sourceCaches[_k.id],delete this._updatedSources[_k.id],_k.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:_k.getSource().id})),_k.setEventedParent(null),_k.clearTiles();delete this._otherSourceCaches[Xk],delete this._symbolSourceCaches[Xk],Yk.setEventedParent(null),Yk.onRemove&&Yk.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(al,bl){this._checkLoaded(),this.getSource(al).setData(bl),this._changed=!0}getSource(cl){const dl=this._getSourceCache(cl);return dl&&dl.getSource()}addLayer(el,fl,gl={}){this._checkLoaded();const hl=el.id;if(this.getLayer(hl))return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${hl}" already exists on this map`)));let il;if("custom"===el.type){if(zj(this,a.validateCustomStyleLayer(el)))return;il=a.createStyleLayer(el)}else{if("object"==typeof el.source&&(this.addSource(hl,el.source),el=a.clone$1(el),el=a.extend(el,{source:hl})),this._validate(a.validateStyle.layer,`layers.${hl}`,el,{arrayIndex:-1},gl))return;il=a.createStyleLayer(el),this._validateLayer(il),il.setEventedParent(this,{layer:{id:hl}}),this._serializedLayers[il.id]=il.serialize(),this._updateLayerCount(il,!0)}const jl=fl?this._order.indexOf(fl):this._order.length;if(fl&& -1===jl)return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${fl}" does not exist on this map.`)));this._order.splice(jl,0,hl),this._layerOrderChanged=!0,this._layers[hl]=il;const kl=this._getLayerSourceCache(il);if(this._removedLayers[hl]&&il.source&&kl&&"custom"!==il.type){const ll=this._removedLayers[hl];delete this._removedLayers[hl],ll.type!==il.type?this._updatedSources[il.source]="clear":(this._updatedSources[il.source]="reload",kl.pause())}this._updateLayer(il),il.onAdd&&il.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(ml,nl){if(this._checkLoaded(),this._changed=!0,!this._layers[ml])return void this.fire(new a.ErrorEvent(new Error(`The layer '${ml}' does not exist in the map's style and cannot be moved.`)));if(ml===nl)return;const ol=this._order.indexOf(ml);this._order.splice(ol,1);const pl=nl?this._order.indexOf(nl):this._order.length;nl&& -1===pl?this.fire(new a.ErrorEvent(new Error(`Layer with id "${nl}" does not exist on this map.`))):(this._order.splice(pl,0,ml),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(ql){this._checkLoaded();const rl=this._layers[ql];if(!rl)return void this.fire(new a.ErrorEvent(new Error(`The layer '${ql}' does not exist in the map's style and cannot be removed.`)));rl.setEventedParent(null),this._updateLayerCount(rl,!1);const sl=this._order.indexOf(ql);this._order.splice(sl,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[ql]=rl,delete this._layers[ql],delete this._serializedLayers[ql],delete this._updatedLayers[ql],delete this._updatedPaintProps[ql],rl.onRemove&&rl.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(tl){return this._layers[tl]}hasLayer(ul){return ul in this._layers}hasLayerType(vl){for(const wl in this._layers)if(this._layers[wl].type===vl)return!0;return!1}setLayerZoomRange(xl,yl,zl){this._checkLoaded();const Al=this.getLayer(xl);Al?Al.minzoom===yl&&Al.maxzoom===zl||(null!=yl&&(Al.minzoom=yl),null!=zl&&(Al.maxzoom=zl),this._updateLayer(Al)):this.fire(new a.ErrorEvent(new Error(`The layer '${xl}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(Bl,Cl,Dl={}){this._checkLoaded();const El=this.getLayer(Bl);if(El){if(!f(El.filter,Cl))return null==Cl?(El.filter=void 0,void this._updateLayer(El)):void(this._validate(a.validateStyle.filter,`layers.${El.id}.filter`,Cl,{layerType:El.type},Dl)||(El.filter=a.clone$1(Cl),this._updateLayer(El)))}else this.fire(new a.ErrorEvent(new Error(`The layer '${Bl}' does not exist in the map's style and cannot be filtered.`)))}getFilter(Fl){return a.clone$1(this.getLayer(Fl).filter)}setLayoutProperty(Gl,Hl,Il,Jl={}){this._checkLoaded();const Kl=this.getLayer(Gl);Kl?f(Kl.getLayoutProperty(Hl),Il)||(Kl.setLayoutProperty(Hl,Il,Jl),this._updateLayer(Kl)):this.fire(new a.ErrorEvent(new Error(`The layer '${Gl}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(Ll,Ml){const Nl=this.getLayer(Ll);if(Nl)return Nl.getLayoutProperty(Ml);this.fire(new a.ErrorEvent(new Error(`The layer '${Ll}' does not exist in the map's style.`)))}setPaintProperty(Ol,Pl,Ql,Rl={}){this._checkLoaded();const Sl=this.getLayer(Ol);Sl?f(Sl.getPaintProperty(Pl),Ql)||(Sl.setPaintProperty(Pl,Ql,Rl)&&this._updateLayer(Sl),this._changed=!0,this._updatedPaintProps[Ol]=!0):this.fire(new a.ErrorEvent(new Error(`The layer '${Ol}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(Tl,Ul){return this.getLayer(Tl).getPaintProperty(Ul)}setFeatureState(Vl,Wl){this._checkLoaded();const Xl=Vl.source,Yl=Vl.sourceLayer,Zl=this.getSource(Xl);if(void 0===Zl)return void this.fire(new a.ErrorEvent(new Error(`The source '${Xl}' does not exist in the map's style.`)));const $l=Zl.type;if("geojson"===$l&&Yl)return void this.fire(new a.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===$l&&!Yl)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===Vl.id&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided.")));const _l=this._getSourceCaches(Xl);for(const am of _l)am.setFeatureState(Yl,Vl.id,Wl)}removeFeatureState(bm,cm){this._checkLoaded();const dm=bm.source,em=this.getSource(dm);if(void 0===em)return void this.fire(new a.ErrorEvent(new Error(`The source '${dm}' does not exist in the map's style.`)));const fm=em.type,gm="vector"===fm?bm.sourceLayer:void 0;if("vector"===fm&&!gm)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(cm&&"string"!=typeof bm.id&&"number"!=typeof bm.id)return void this.fire(new a.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const hm=this._getSourceCaches(dm);for(const im of hm)im.removeFeatureState(gm,bm.id,cm)}getFeatureState(jm){this._checkLoaded();const km=jm.source,lm=jm.sourceLayer,mm=this.getSource(km);if(void 0!==mm){if("vector"!==mm.type||lm)return void 0===jm.id&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(km)[0].getFeatureState(lm,jm.id);this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(new Error(`The source '${km}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const nm={};for(const om in this._sourceCaches){const pm=this._sourceCaches[om].getSource();nm[pm.id]||(nm[pm.id]=pm.serialize())}return a.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:nm,layers:this._serializeLayers(this._order)},a=>void 0!==a)}_updateLayer(qm){this._updatedLayers[qm.id]=!0;const rm=this._getLayerSourceCache(qm);qm.source&&!this._updatedSources[qm.source]&&rm&&"raster"!==rm.getSource().type&&(this._updatedSources[qm.source]="reload",rm.pause()),this._changed=!0,qm.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(sm){var tm,tm;const um={},vm=[];for(let wm=this._order.length-1;wm>=0;wm--){const xm=this._order[wm];if(tm=xm,"fill-extrusion"===this._layers[tm].type)for(const ym of(um[xm]=wm,sm)){const zm=ym[xm];if(zm)for(const Am of zm)vm.push(Am)}}vm.sort((a,b)=>b.intersectionZ-a.intersectionZ);const Bm=[];for(let Cm=this._order.length-1;Cm>=0;Cm--){const Dm=this._order[Cm];if(tm=Dm,"fill-extrusion"===this._layers[tm].type)for(let Em=vm.length-1;Em>=0;Em--){const Fm=vm[Em].feature;if(um[Fm.layer.id]{const b=this.getLayer(a);return b&&b.is3D()}):this.has3DLayers(),Rm=dc.createFromScreenPoints(Jm,Lm);for(const Sm in this._sourceCaches){const Tm=this._sourceCaches[Sm].getSource().id;Km.layers&&!Mm[Tm]||Pm.push(Qd(this._sourceCaches[Sm],this._layers,this._serializedLayers,Rm,Km,Lm,Qm,!!this.map._showQueryGeometry))}return this.placement&&Pm.push(function(a,b,c,d,e,f,g){const h={},i=f.queryRenderedSymbols(d),j=[];for(const k of Object.keys(i).map(Number))j.push(g[k]);for(const l of(j.sort(Sd),j)){const m=l.featureIndex.lookupSymbolFeatures(i[l.bucketInstanceId],b,l.bucketIndex,l.sourceLayerIndex,e.filter,e.layers,e.availableImages,a);for(const n in m){const o=h[n]=h[n]||[],p=m[n];for(const q of(p.sort((a,b)=>{const c=l.featureSortOrder;if(c){const d=c.indexOf(a.featureIndex);return c.indexOf(b.featureIndex)-d}return b.featureIndex-a.featureIndex}),p))o.push(q)}}for(const r in h)h[r].forEach(b=>{const d=b.feature,e=c(a[r]).getFeatureState(d.layer["source-layer"],d.id);d.source=d.layer.source,d.layer["source-layer"]&&(d.sourceLayer=d.layer["source-layer"]),d.state=e});return h}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),Rm.screenGeometry,Km,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(Pm)}querySourceFeatures(Um,Vm){Vm&&Vm.filter&&this._validate(a.validateStyle.filter,"querySourceFeatures.filter",Vm.filter,null,Vm);const Wm=this._getSourceCaches(Um);let Xm=[];for(const Ym of Wm)Xm=Xm.concat(Rd(Ym,Vm));return Xm}addSourceType(Zm,$m,_m){return Ej.getSourceType(Zm)?_m(new Error(`A source type called "${Zm}" already exists.`)):(Ej.setSourceType(Zm,$m),$m.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:Zm,url:$m.workerSourceURL},_m):_m(null,null))}getLight(){return this.light.getLight()}setLight(an,bn={}){this._checkLoaded();const cn=this.light.getLight();let dn=!1;for(const en in an)if(!f(an[en],cn[en])){dn=!0;break}if(!dn)return;const fn={now:a.exported.now(),transition:a.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(an,bn),this.light.updateTransitions(fn)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(gn,hn=1){if(this._checkLoaded(),!gn)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===hn){if("object"==typeof gn.source){const jn="terrain-dem-src";this.addSource(jn,gn.source),gn=a.clone$1(gn),gn=a.extend(gn,{source:jn})}if(this._validate(a.validateStyle.terrain,"terrain",gn))return}if(!this.terrain||this.terrain&&hn!==this.terrain.drapeRenderMode)this._createTerrain(gn,hn);else{const kn=this.terrain,ln=kn.get();for(const mn in gn)if(!f(gn[mn],ln[mn])){kn.set(gn),this.stylesheet.terrain=gn;const nn={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};kn.updateTransitions(nn);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(on){const pn=this.fog=new Na(on,this.map.transform);this.stylesheet.fog=on;const qn={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};pn.updateTransitions(qn)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const a of this.map._markers)a._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(rn){if(this._checkLoaded(),!rn)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const sn=this.fog,tn=sn.get();for(const un in rn)if(!f(rn[un],tn[un])){sn.set(rn),this.stylesheet.fog=rn;const vn={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};sn.updateTransitions(vn);break}}else this._createFog(rn);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const wn=this._order.filter(a=>this.isLayerDraped(this._layers[a])),xn=this._order.filter(a=>!this.isLayerDraped(this._layers[a]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...wn),this._drapedFirstOrder.push(...xn)}_createTerrain(yn,zn){const An=this.terrain=new Ba(yn,zn);this.stylesheet.terrain=yn,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const Bn={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};An.updateTransitions(Bn)}_force3DLayerUpdate(){for(const Cn in this._layers){const Dn=this._layers[Cn];"fill-extrusion"===Dn.type&&this._updateLayer(Dn)}}_forceSymbolLayerUpdate(){for(const En in this._layers){const Fn=this._layers[En];"symbol"===Fn.type&&this._updateLayer(Fn)}}_validate(Gn,Hn,In,Jn,Kn={}){return(!Kn|| !1!==Kn.validate)&&zj(this,Gn.call(a.validateStyle,a.extend({key:Hn,style:this.serialize(),value:In,styleSpec:a.spec},Jn)))}_remove(){for(const Ln in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[Ln].setEventedParent(null);for(const Mn in this._sourceCaches)this._sourceCaches[Mn].clearTiles(),this._sourceCaches[Mn].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(Nn){const On=this._getSourceCaches(Nn);for(const Pn of On)Pn.clearTiles()}_reloadSource(Qn){const Rn=this._getSourceCaches(Qn);for(const Sn of Rn)Sn.resume(),Sn.reload()}_updateSources(Tn){for(const Un in this._sourceCaches)this._sourceCaches[Un].update(Tn)}_generateCollisionBoxes(){for(const Vn in this._sourceCaches){const Wn=this._sourceCaches[Vn];Wn.resume(),Wn.reload()}}_updatePlacement(Xn,Yn,Zn,$n,_n=!1){let ao=!1,bo=!1;const co={};for(const eo of this._order){const fo=this._layers[eo];if("symbol"!==fo.type)continue;if(!co[fo.source]){const go=this._getLayerSourceCache(fo);if(!go)continue;co[fo.source]=go.getRenderableIds(!0).map(a=>go.getTileByID(a)).sort((a,b)=>b.tileID.overscaledZ-a.tileID.overscaledZ||(a.tileID.isLessThan(b.tileID)?-1:1))}const ho=this.crossTileSymbolIndex.addLayer(fo,co[fo.source],Xn.center.lng,Xn.projection);ao=ao||ho}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),_n=_n||this._layerOrderChanged||0===Zn,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(_n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),Xn.zoom))&&(this.pauseablePlacement=new ai(Xn,this._order,_n,Yn,Zn,$n,this.placement,this.fog&&Xn.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,co),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),bo=!0),ao&&this.pauseablePlacement.placement.setStale()),bo||ao)for(const io of this._order){const jo=this._layers[io];"symbol"===jo.type&&this.placement.updateLayerOpacities(jo,co[jo.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(const ko in this._sourceCaches)this._sourceCaches[ko].releaseSymbolFadeTiles()}getImages(lo,mo,no){this.imageManager.getImages(mo.icons,no),this._updateTilesForChangedImages();const oo=a=>{a&&a.setDependencies(mo.tileID.key,mo.type,mo.icons)};oo(this._otherSourceCaches[mo.source]),oo(this._symbolSourceCaches[mo.source])}getGlyphs(po,qo,ro){this.glyphManager.getGlyphs(qo.stacks,ro)}getResource(so,to,uo){return a.makeRequest(to,uo)}_getSourceCache(vo){return this._otherSourceCaches[vo]}_getLayerSourceCache(wo){return"symbol"===wo.type?this._symbolSourceCaches[wo.source]:this._otherSourceCaches[wo.source]}_getSourceCaches(xo){const yo=[];return this._otherSourceCaches[xo]&&yo.push(this._otherSourceCaches[xo]),this._symbolSourceCaches[xo]&&yo.push(this._symbolSourceCaches[xo]),yo}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Ej.getSourceType=function(a){return Nd[a]},Ej.setSourceType=function(a,b){Nd[a]=b},Ej.registerForPluginStateChange=a.registerForPluginStateChange;var zo="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif",Ao="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let Bo={},Co={};Bo=Go("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),Co=Go("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const Do=Go("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nreturn mix(globe,mercator,t);\n#else\nreturn globe;\n#endif\n}\n#ifdef PROJECTION_GLOBE_VIEW\nmat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),Eo=zo;var Fo={background:Go("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:Go("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:Go("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:Go("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Go("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:Go("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Go("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Go("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Go("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:Go("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:Go("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:Go("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:Go("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:Go("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:Go("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:Go("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Go("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:Go("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:Go("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:Go("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:Go("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:Go("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:Go("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:Go("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:Go("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Go("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Ao),skyboxGradient:Go("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",Ao),skyboxCapture:Go("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Go("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:Go("uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)\ndiscard;float t=clamp(1.0-sqrt(normDistFromCenter-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;void main() {gl_Position=vec4(a_pos,1.0);}")};function Go(a,b,c){const d=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,e=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,f=b.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),g=a.match(e),h=b.match(e),i=zo.match(e);let j=h?h.concat(g):g;c||(Bo.staticUniforms&&(j=Bo.staticUniforms.concat(j)),Co.staticUniforms&&(j=Co.staticUniforms.concat(j))),j&&(j=j.concat(i));const k={};return{fragmentSource:a=a.replace(d,(a,b,c,d,e)=>(k[e]=!0,"define"===b?`\n#ifndef HAS_UNIFORM_u_${e}\nvarying ${c} ${d} ${e};\n#else\nuniform ${c} ${d} u_${e};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${e}\n ${c} ${d} ${e} = u_${e};\n#endif\n`)),vertexSource:b=b.replace(d,(a,b,c,d,e)=>{const f="float"===d?"vec2":"vec4",g=e.match(/color/)?"color":f;return k[e]?"define"===b?`\n#ifndef HAS_UNIFORM_u_${e}\nuniform lowp float u_${e}_t;\nattribute ${c} ${f} a_${e};\nvarying ${c} ${d} ${e};\n#else\nuniform ${c} ${d} u_${e};\n#endif\n`:"vec4"===g?`\n#ifndef HAS_UNIFORM_u_${e}\n ${e} = a_${e};\n#else\n ${c} ${d} ${e} = u_${e};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${e}\n ${e} = unpack_mix_${g}(a_${e}, u_${e}_t);\n#else\n ${c} ${d} ${e} = u_${e};\n#endif\n`:"define"===b?`\n#ifndef HAS_UNIFORM_u_${e}\nuniform lowp float u_${e}_t;\nattribute ${c} ${f} a_${e};\n#else\nuniform ${c} ${d} u_${e};\n#endif\n`:"vec4"===g?`\n#ifndef HAS_UNIFORM_u_${e}\n ${c} ${d} ${e} = a_${e};\n#else\n ${c} ${d} ${e} = u_${e};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${e}\n ${c} ${d} ${e} = unpack_mix_${g}(a_${e}, u_${e}_t);\n#else\n ${c} ${d} ${e} = u_${e};\n#endif\n`}),staticAttributes:f,staticUniforms:j}}class Ho{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(Io,Jo,Ko,Lo,Mo,No,Oo,Po){this.context=Io;let Qo=this.boundPaintVertexBuffers.length!==Lo.length;for(let Ro=0;!Qo&&Ro{const f=d.paint.get("hillshade-shadow-color"),g=d.paint.get("hillshade-highlight-color"),h=d.paint.get("hillshade-accent-color");let i=d.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===d.paint.get("hillshade-illumination-anchor")&&(i-=b.transform.angle);const j=!b.options.moving;return{u_matrix:e||b.transform.calculateProjMatrix(c.tileID.toUnwrapped(),j),u_image:0,u_latrange:(function(b,c){const d=Math.pow(2,c.canonical.z),e=c.canonical.y;return[new a.MercatorCoordinate(0,e/d).toLngLat().lat,new a.MercatorCoordinate(0,(e+1)/d).toLngLat().lat]})(0,c.tileID),u_light:[d.paint.get("hillshade-exaggeration"),i],u_shadow:f,u_highlight:g,u_accent:h}})(b,d,e,b.terrain?c.projMatrix:null);b.prepareDrawProgram(i,l,c.toUnwrapped());const{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=b.getTileBoundsBuffers(d);l.draw(i,j.TRIANGLES,f,g,h,a.CullFaceMode.disabled,m,e.id,n,o,p)}function fp(b,c,d){if(!c.needsDEMTextureUpload)return;const e=b.context,f=e.gl;e.pixelStoreUnpackPremultiplyAlpha.set(!1),c.demTexture=c.demTexture||b.getTileTexture(d.stride);const g=d.getPixels();c.demTexture?c.demTexture.update(g,{premultiply:!1}):c.demTexture=new a.Texture(e,g,f.RGBA,{premultiply:!1}),c.needsDEMTextureUpload=!1}function gp(b,c,d,e,f,g){const h=b.context,i=h.gl;if(!c.dem)return;const j=c.dem;if(h.activeTexture.set(i.TEXTURE1),fp(b,c,j),!c.demTexture)return;c.demTexture.bind(i.NEAREST,i.CLAMP_TO_EDGE);const k=j.dim;h.activeTexture.set(i.TEXTURE0);let l=c.fbo;if(!l){const m=new a.Texture(h,{width:k,height:k,data:null},i.RGBA);m.bind(i.LINEAR,i.CLAMP_TO_EDGE),(l=c.fbo=h.createFramebuffer(k,k,!0)).colorAttachment.set(m.texture)}h.bindFramebuffer.set(l.framebuffer),h.viewport.set([0,0,k,k]);const{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=b.getMercatorTileBoundsBuffers();b.useProgram("hillshadePrepare").draw(h,i.TRIANGLES,e,f,g,a.CullFaceMode.disabled,((b,c)=>{const d=c.stride,e=a.create();return a.ortho(e,0,a.EXTENT,-a.EXTENT,0,0,1),a.translate(e,e,[0,-a.EXTENT,0]),{u_matrix:e,u_image:1,u_dimension:[d,d],u_zoom:b.overscaledZ,u_unpack:c.unpackVector}})(c.tileID,j),d.id,n,o,p),c.needsHillshadePrepare=!1}const hp=(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image0:new a.Uniform1i(b,c.u_image0),u_skirt_height:new a.Uniform1f(b,c.u_skirt_height)}),ip=(a,b)=>({u_matrix:a,u_image0:0,u_skirt_height:b}),jp=(a,b,c,d,e)=>({u_proj_matrix:Float32Array.from(a),u_globe_matrix:b,u_merc_matrix:c,u_zoom_transition:d,u_merc_center:e,u_image0:0});function kp(a,b){return null!=a&&null!=b&&!(!a.hasData()||!b.hasData())&&null!=a.demTexture&&null!=b.demTexture&&a.tileID.key!==b.tileID.key}const lp=new class{constructor(){this.operations={}}newMorphing(a,b,c,d,e){if(a in this.operations){const f=this.operations[a];f.to.tileID.key!==c.tileID.key&&(f.queued=c)}else this.operations[a]={startTime:d,phase:0,duration:e,from:b,to:c,queued:null}}getMorphValuesForProxy(g){if(!(g in this.operations))return null;const h=this.operations[g];return{from:h.from,to:h.to,phase:h.phase}}update(i){for(const j in this.operations){const k=this.operations[j];for(k.phase=(i-k.startTime)/k.duration;k.phase>=1||!this._validOp(k);)if(!this._nextOp(k,i)){delete this.operations[j];break}}}_nextOp(l,m){return!!l.queued&&(l.from=l.to,l.to=l.queued,l.queued=null,l.phase=0,l.startTime=m,!0)}_validOp(n){return n.from.hasData()&&n.to.hasData()}},mp={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function np(a,b){const c=1<({u_matrix:a});function pp(b,c,d,e,f){if(f>0){const g=a.exported.now(),h=(g-b.timeAdded)/f,i=c?(g-c.timeAdded)/f:-1,j=d.getSource(),k=e.coveringZoomLevel({tileSize:j.tileSize,roundZoom:j.roundZoom}),l=!c||Math.abs(c.tileID.overscaledZ-k)>Math.abs(b.tileID.overscaledZ-k),m=l&&b.refreshedUponExpiration?1:a.clamp(l?h:1-i,0,1);return b.refreshedUponExpiration&&h>=1&&(b.refreshedUponExpiration=!1),c?{opacity:1,mix:1-m}:{opacity:m,mix:0}}return{opacity:1,mix:0}}class qp extends a.SourceCache{constructor(rp){const sp={type:"raster-dem",maxzoom:rp.transform.maxZoom},tp=new cb(Zd(),null),up=Od("mock-dem",sp,tp,rp.style);super("mock-dem",up,!1),up.setEventedParent(this),this._sourceLoaded=!0}_loadTile(vp,wp){vp.state="loaded",wp(null)}}class xp extends a.SourceCache{constructor(yp){const zp=Od("proxy",{type:"geojson",maxzoom:yp.transform.maxZoom},new cb(Zd(),null),yp.style);super("proxy",zp,!1),zp.setEventedParent(this),this.map=this.getSource().map=yp,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(Ap,Bp,Cp){if(Ap.freezeTileCoverage)return;this.transform=Ap;const Dp=Ap.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((b,c)=>{if(b[c.key]="",!this._tiles[c.key]){const d=new a.Tile(c,this._source.tileSize*c.overscaleFactor(),Ap.tileZoom);d.state="loaded",this._tiles[c.key]=d}return b},{});for(const Ep in this._tiles)Ep in Dp||(this.freeFBO(Ep),this._tiles[Ep].unloadVectorData(),delete this._tiles[Ep])}freeFBO(Fp){const Gp=this.proxyCachedFBO[Fp];if(void 0!==Gp){const Hp=Object.values(Gp);this.renderCachePool.push(...Hp),delete this.proxyCachedFBO[Fp]}}deallocRenderCache(){this.renderCache.forEach(a=>a.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ip extends a.OverscaledTileID{constructor(Jp,Kp,Lp){super(Jp.overscaledZ,Jp.wrap,Jp.canonical.z,Jp.canonical.x,Jp.canonical.y),this.proxyTileKey=Kp,this.projMatrix=Lp}}class Mp extends a.Elevation{constructor(Np,Op){super(),this.painter=Np,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[Pp,Qp,Rp]=function(b){const c=new a.StructArrayLayout4i8,d=new a.StructArrayLayout3ui6;c.reserve(17161),d.reserve(33800);const e=a.EXTENT/128,f=a.EXTENT+e/2,g=f+e;for(let h=-e;hf||h<0||h>f?24575:0,k=a.clamp(Math.round(i),0,a.EXTENT),l=a.clamp(Math.round(h),0,a.EXTENT);c.emplaceBack(k+j,l,k,l)}const m=(a,b)=>{const c=131*b+a;d.emplaceBack(c+1,c,c+131),d.emplaceBack(c+131,c+131+1,c+1)};for(let n=1;n<129;n++)for(let o=1;o<129;o++)m(o,n);return[0,129].forEach(a=>{for(let b=0;b<130;b++)m(b,a),m(a,b)}),[c,d,32768]}(),Sp=Np.context;this.gridBuffer=Sp.createVertexBuffer(Pp,a.boundsAttributes.members),this.gridIndexBuffer=Sp.createIndexBuffer(Qp),this.gridSegments=a.SegmentVector.simpleSegment(0,0,Pp.length,Qp.length),this.gridNoSkirtSegments=a.SegmentVector.simpleSegment(0,0,Pp.length,Rp),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new xp(Op.map),this.orthoMatrix=a.create(),a.ortho(this.orthoMatrix,0,a.EXTENT,0,a.EXTENT,0,1);const Tp=Sp.gl;this._overlapStencilMode=new a.StencilMode({func:Tp.GEQUAL,mask:255},0,255,Tp.KEEP,Tp.KEEP,Tp.REPLACE),this._previousZoom=Np.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=Op,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new qp(Op.map)}set style(Up){Up.on("data",this._onStyleDataEvent.bind(this)),Up.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=Up,this._checkRenderCacheEfficiency()}update(Vp,Wp,Xp){if(Vp&&Vp.terrain){this._style!==Vp&&(this.style=Vp),this.enabled=!0;const Yp=Vp.terrain.properties;this.sourceCache=0===Vp.terrain.drapeRenderMode?this._mockSourceCache:Vp._getSourceCache(Yp.get("source")),this._exaggeration=Yp.get("exaggeration");const Zp=()=>{this.sourceCache.used&&a.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const b=this.getScaledDemTileSize();this.sourceCache.update(Wp,b,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,Zp(),this._initializing=!0),Zp(),Wp.updateElevation(!Xp),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(Wp),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache($p){this._findCoveringTileCache[$p]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const _p=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==_p.efficiency&&a.warnOnce(`Terrain render cache efficiency is not optimal (${_p.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${_p.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(aq){aq.coord&&"source"===aq.dataType?this._clearRenderCacheForTile(aq.sourceCacheId,aq.coord):"style"===aq.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const bq in this._style._sourceCaches)this._style._sourceCaches[bq].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(a=>a.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const cq=2*this.proxySourceCache.getSource().tileSize;return[cq,cq]}set useVertexMorphing(dq){this._useVertexMorphing=dq}updateTileBinding(eq){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const fq=this.proxySourceCache,gq=this.painter.transform;this._initializing&&(this._initializing=0===gq._centerAltitude&& -1===this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(gq.center),-1),this._emptyDEMTextureDirty=!this._initializing);const hq=this.proxyCoords=fq.getIds().map(a=>{const b=fq.getTileByID(a).tileID;return b.projMatrix=gq.calculateProjMatrix(b.toUnwrapped()),b});(function(b,c){const d=c.transform.pointCoordinate(c.transform.getCameraPoint()),e=new a.pointGeometry(d.x,d.y);b.sort((b,c)=>{if(c.overscaledZ-b.overscaledZ)return c.overscaledZ-b.overscaledZ;const d=new a.pointGeometry(b.canonical.x+(1<{this.proxyToSource[a.key]={}}),this.terrainTileForTile={};const jq=this._style._sourceCaches;for(const kq in jq){const lq=jq[kq];if(!lq.used)continue;if(lq!==this.sourceCache&&this.resetTileLookupCache(lq.id),this._setupProxiedCoordsForOrtho(lq,eq[kq],iq),lq.usedForTerrain)continue;const mq=eq[kq];lq.getSource().reparseOverscaled&&this._assignTerrainTiles(mq)}this.proxiedCoords[fq.id]=hq.map(a=>new Ip(a,a.key,this.orthoMatrix)),this._assignTerrainTiles(hq),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(iq),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();const nq={};for(const oq of(this._visibleDemTiles=[],this.proxyCoords)){const pq=this.terrainTileForTile[oq.key];if(!pq)continue;const qq=pq.tileID.key;qq in nq||(this._visibleDemTiles.push(pq),nq[qq]=qq)}}_assignTerrainTiles(rq){this._initializing||rq.forEach(a=>{if(this.terrainTileForTile[a.key])return;const b=this._findTileCoveringTileID(a,this.sourceCache);b&&(this.terrainTileForTile[a.key]=b)})}_prepareDEMTextures(){const sq=this.painter.context,tq=sq.gl;for(const uq in this.terrainTileForTile){const vq=this.terrainTileForTile[uq],wq=vq.dem;wq&&(!vq.demTexture||vq.needsDEMTextureUpload)&&(sq.activeTexture.set(tq.TEXTURE1),fp(this.painter,vq,wq))}}_prepareDemTileUniforms(xq,yq,zq,Aq){if(!yq||null==yq.demTexture)return!1;const Bq=xq.tileID.canonical,Cq=Math.pow(2,yq.tileID.canonical.z-Bq.z),Dq=Aq||"";return zq[`u_dem_tl${Dq}`]=[Bq.x*Cq%1,Bq.y*Cq%1],zq[`u_dem_scale${Dq}`]=Cq,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const Eq=this.painter.context,Fq=Eq.gl;if(!this._emptyDepthBufferTexture){const Gq={width:1,height:1,data:new Uint8Array([255,255,255,255])};this._emptyDepthBufferTexture=new a.Texture(Eq,Gq,Fq.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let Hq=0;const Iq=this._visibleDemTiles.reduce((a,b)=>{if(!b.dem)return a;const c=b.dem.tree.minimums[0];return c>0&&Hq++,a+c},0);return Hq?Iq/Hq:0}_updateEmptyDEMTexture(){const Jq=this.painter.context,Kq=Jq.gl;Jq.activeTexture.set(Kq.TEXTURE2);const Lq=this._getLoadedAreaMinimum(),Mq={width:1,height:1,data:new Uint8Array(a.DEMData.pack(Lq,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let Nq=this._emptyDEMTexture;return Nq?Nq.update(Mq,{premultiply:!1}):Nq=this._emptyDEMTexture=new a.Texture(Jq,Mq,Kq.RGBA,{premultiply:!1}),Nq}setupElevationDraw(Oq,Pq,Qq){var Rq;const Sq=this.painter.context,Tq=Sq.gl,Uq=(Rq=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.DEMData.getUnpackVector(Rq),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});Uq.u_dem_size=this.sourceCache.getSource().tileSize,Uq.u_exaggeration=this.exaggeration();const Vq=this.painter.transform,Wq=Vq.projection.createTileTransform(Vq,Vq.worldSize),Xq=Oq.tileID.canonical;Uq.u_tile_tl_up=Wq.upVector(Xq,0,0),Uq.u_tile_tr_up=Wq.upVector(Xq,a.EXTENT,0),Uq.u_tile_br_up=Wq.upVector(Xq,a.EXTENT,a.EXTENT),Uq.u_tile_bl_up=Wq.upVector(Xq,0,a.EXTENT),Uq.u_tile_up_scale=Wq.upVectorScale(Xq);let Yq=null,Zq=null,$q=1;if(Qq&&Qq.morphing&&this._useVertexMorphing){const _q=Qq.morphing.srcDemTile,ar=Qq.morphing.dstDemTile;$q=Qq.morphing.phase,_q&&ar&&(this._prepareDemTileUniforms(Oq,_q,Uq,"_prev")&&(Zq=_q),this._prepareDemTileUniforms(Oq,ar,Uq)&&(Yq=ar))}if(Zq&&Yq?(Sq.activeTexture.set(Tq.TEXTURE2),Yq.demTexture.bind(Tq.NEAREST,Tq.CLAMP_TO_EDGE,Tq.NEAREST),Sq.activeTexture.set(Tq.TEXTURE4),Zq.demTexture.bind(Tq.NEAREST,Tq.CLAMP_TO_EDGE,Tq.NEAREST),Uq.u_dem_lerp=$q):(Yq=this.terrainTileForTile[Oq.tileID.key],Sq.activeTexture.set(Tq.TEXTURE2),(this._prepareDemTileUniforms(Oq,Yq,Uq)?Yq.demTexture:this.emptyDEMTexture).bind(Tq.NEAREST,Tq.CLAMP_TO_EDGE)),Sq.activeTexture.set(Tq.TEXTURE3),Qq&&Qq.useDepthForOcclusion?(this._depthTexture.bind(Tq.NEAREST,Tq.CLAMP_TO_EDGE),Uq.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height]):(this.emptyDepthBufferTexture.bind(Tq.NEAREST,Tq.CLAMP_TO_EDGE),Uq.u_depth_size_inv=[1,1]),Qq&&Qq.useMeterToDem&&Yq){const br=(1<{if(j===a)return;const d=[];c&&d.push(mp[k]),d.push(mp[a]),d.push("PROJECTION_GLOBE_VIEW"),i=b.useProgram("globeRaster",null,d),j=a},m=b.colorModeForRenderPass(),n=new a.DepthMode(h.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);lp.update(f);const o=b.transform,p=a.calculateGlobeMatrix(o,o.worldSize),q=a.calculateGlobeMercatorMatrix(o),r=[a.mercatorXfromLng(o.center.lng),a.mercatorYfromLat(o.center.lat)],s=b.globeSharedBuffers;(k?[!1,!0]:[!1]).forEach(k=>{j=-1;const t=k?h.LINES:h.TRIANGLES;for(const u of e){const v=d.getTile(u),w=Math.pow(2,u.canonical.z),[x,y]=a.globeBuffersForTileMesh(b,v,u,w),z=a.StencilMode.disabled,A=c.prevTerrainTileForTile[u.key],B=c.terrainTileForTile[u.key];kp(A,B)&&lp.newMorphing(u.key,A,B,f,250),g.activeTexture.set(h.TEXTURE0),v.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE);const C=lp.getMorphValuesForProxy(u.key),D=C?1:0,E={};C&&a.extend$1(E,{morphing:{srcDemTile:C.from,dstDemTile:C.to,phase:a.easeCubicInOut(C.phase)}});const F=a.globeMatrixForTile(u.canonical,p),G=jp(o.projMatrix,F,q,a.globeToMercatorTransition(o.zoom),r);if(l(D,k),c.setupElevationDraw(v,i,E),b.prepareDrawProgram(g,i,u.toUnwrapped()),s){const[H,I]=k?s.getWirefameBuffer(b.context):[s.gridIndexBuffer,s.gridSegments];i.draw(g,t,n,z,m,a.CullFaceMode.backCCW,G,"globe_raster",x,H,I)}if(!k){const J=[0===u.canonical.y?a.globePoleMatrixForTile(u.canonical,!1,o):null,u.canonical.y===w-1?a.globePoleMatrixForTile(u.canonical,!0,o):null];for(const K of J){if(!K)continue;const L=jp(o.projMatrix,K,K,0,r);s&&i.draw(g,t,n,z,m,a.CullFaceMode.disabled,L,"globe_pole_raster",y,s.poleIndexBuffer,s.poleSegments)}}}})}(b,c,d,e,f);else{const g=b.context,h=g.gl;let i,j;const k=b.options.showTerrainWireframe?2:0,l=(a,c)=>{if(j===a)return;const d=[mp[a]];c&&d.push(mp[k]),i=b.useProgram("terrainRaster",null,d),j=a},m=b.colorModeForRenderPass(),n=new a.DepthMode(h.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);lp.update(f);const o=b.transform,p=6*Math.pow(1.5,22-o.zoom)*c.exaggeration();(k?[!1,!0]:[!1]).forEach(k=>{j=-1;const q=k?h.LINES:h.TRIANGLES,[r,s]=k?c.getWirefameBuffer():[c.gridIndexBuffer,c.gridSegments];for(const t of e){const u=d.getTile(t),v=a.StencilMode.disabled,w=c.prevTerrainTileForTile[t.key],x=c.terrainTileForTile[t.key];kp(w,x)&&lp.newMorphing(t.key,w,x,f,250),g.activeTexture.set(h.TEXTURE0),u.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE,h.LINEAR_MIPMAP_NEAREST);const y=lp.getMorphValuesForProxy(t.key),z=y?1:0;let A;y&&(A={morphing:{srcDemTile:y.from,dstDemTile:y.to,phase:a.easeCubicInOut(y.phase)}});const B=ip(t.projMatrix,np(t.canonical,o.renderWorldCopies)?p/10:p);l(z,k),c.setupElevationDraw(u,i,A),b.prepareDrawProgram(g,i,t.toUnwrapped()),i.draw(g,q,n,v,m,a.CullFaceMode.backCCW,B,"terrain_raster",c.gridBuffer,r,s)}})}})(dr,this,this.proxySourceCache,cr,this._updateTimestamp),this.renderingToTexture=!0,cr.splice(0,cr.length))}renderBatch(fr){if(0===this._drapedRenderBatches.length)return fr+1;this.renderingToTexture=!0;const gr=this.painter,hr=this.painter.context,ir=this.proxySourceCache,jr=this.proxiedCoords[ir.id],kr=this._drapedRenderBatches.shift(),lr=[],mr=gr.style.order;let nr=0;for(const or of jr){const pr=ir.getTileByID(or.proxyTileKey),qr=ir.proxyCachedFBO[or.key]?ir.proxyCachedFBO[or.key][fr]:void 0,rr=void 0!==qr?ir.renderCache[qr]:this.pool[nr++],sr=void 0!==qr;if(pr.texture=rr.tex,sr&&!rr.dirty){lr.push(pr.tileID);continue}let tr;hr.bindFramebuffer.set(rr.fb.framebuffer),this.renderedToTile=!1,rr.dirty&&(hr.clear({color:a.Color.transparent,stencil:0}),rr.dirty=!1);for(let ur=kr.start;ur<=kr.end;++ur){const vr=gr.style._layers[mr[ur]];if(vr.isHidden(gr.transform.zoom))continue;const wr=gr.style._getLayerSourceCache(vr),xr=wr?this.proxyToSource[or.key][wr.id]:[or];if(!xr)continue;const yr=xr;hr.viewport.set([0,0,rr.fb.width,rr.fb.height]),tr!==(wr?wr.id:null)&&(this._setupStencil(rr,xr,vr,wr),tr=wr?wr.id:null),gr.renderLayer(gr,wr,vr,yr)}this.renderedToTile?(rr.dirty=!0,lr.push(pr.tileID)):sr|| --nr,5===nr&&(nr=0,this.renderToBackBuffer(lr))}return this.renderToBackBuffer(lr),this.renderingToTexture=!1,hr.bindFramebuffer.set(null),hr.viewport.set([0,0,gr.width,gr.height]),kr.end+1}postRender(){}renderCacheEfficiency(zr){const Ar=zr.order.length;if(0===Ar)return{efficiency:100};let Br,Cr=0,Dr=0,Er=!1;for(let Fr=0;Fra.dem).forEach(a=>{Hr=Math.min(Hr,a.dem.tree.minimums[0])}),0===Hr?Hr:(Hr-30)*this._exaggeration}raycast(Ir,Jr,Kr){if(!this._visibleDemTiles)return null;const Lr=this._visibleDemTiles.filter(a=>a.dem).map(a=>{const b=a.tileID,c=Math.pow(2,b.overscaledZ),{x:d,y:e}=b.canonical,f=d/c,g=(d+1)/c,h=e/c,i=(e+1)/c;return{minx:f,miny:h,maxx:g,maxy:i,t:a.dem.tree.raycastRoot(f,h,g,i,Ir,Jr,Kr),tile:a}});for(const Mr of(Lr.sort((a,b)=>(null!==a.t?a.t:Number.MAX_VALUE)-(null!==b.t?b.t:Number.MAX_VALUE)),Lr)){if(null==Mr.t)return null;const Nr=Mr.tile.dem.tree.raycast(Mr.minx,Mr.miny,Mr.maxx,Mr.maxy,Ir,Jr,Kr);if(null!=Nr)return Nr}return null}_createFBO(){const Or=this.painter.context,Pr=Or.gl,Qr=this.drapeBufferSize;Or.activeTexture.set(Pr.TEXTURE0);const Rr=new a.Texture(Or,{width:Qr[0],height:Qr[1],data:null},Pr.RGBA);Rr.bind(Pr.LINEAR,Pr.CLAMP_TO_EDGE);const Sr=Or.createFramebuffer(Qr[0],Qr[1],!1);return Sr.colorAttachment.set(Rr.texture),Sr.depthAttachment=new Vb(Or,Sr.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=Or.createRenderbuffer(Or.gl.DEPTH_STENCIL,Qr[0],Qr[1]),this._stencilRef=0,Sr.depthAttachment.set(this._sharedDepthStencil),Or.clear({stencil:0})):Sr.depthAttachment.set(this._sharedDepthStencil),Or.extTextureFilterAnisotropic&&!Or.extTextureFilterAnisotropicForceOff&&Pr.texParameterf(Pr.TEXTURE_2D,Or.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Or.extTextureFilterAnisotropicMax),{fb:Sr,tex:Rr,dirty:!1}}_initFBOPool(){for(;this.pool.length{const b=this._style._layers[a],c=b.isHidden(this.painter.transform.zoom),d=b.getCrossfadeParameters(),e=!!d&&1!==d.t,f=b.hasTransition();return"custom"!==b.type&&!c&&(e||f)})}_clearRasterFadeFromRenderCache(){let Ur=!1;for(const Vr in this._style._sourceCaches)if(this._style._sourceCaches[Vr]._source instanceof ad){Ur=!0;break}if(Ur)for(let Wr=0;Wrls.renderCachePool.length){const ms=Object.values(ls.proxyCachedFBO);ls.proxyCachedFBO={};for(let ns=0;ns=0;rs--){const ss=ps[rs];if(ls.getTileByID(ss.key),void 0!==ls.proxyCachedFBO[ss.key]){const ts=ks[ss.key],us=this.proxyToSource[ss.key];let vs=0;for(const ws in us){const xs=us[ws],ys=ts[ws];if(!ys||ys.length!==xs.length||xs.some((a,b)=>a!==ys[b]||qs[ws]&&qs[ws].hasOwnProperty(a.key))){vs=-1;break}++vs}for(const zs in ls.proxyCachedFBO[ss.key])ls.renderCache[ls.proxyCachedFBO[ss.key][zs]].dirty=vs<0||vs!==Object.values(ts).length}}const As=[...this._drapedRenderBatches];for(const Bs of(As.sort((a,b)=>b.end-b.start-(a.end-a.start)),As))for(const Cs of ps){if(ls.proxyCachedFBO[Cs.key])continue;let Ds=ls.renderCachePool.pop();void 0===Ds&&ls.renderCache.length<50&&(Ds=ls.renderCache.length,ls.renderCache.push(this._createFBO())),void 0!==Ds&&(ls.proxyCachedFBO[Cs.key]={},ls.proxyCachedFBO[Cs.key][Bs.start]=Ds,ls.renderCache[Ds].dirty=!0)}this._tilesDirty={}}_setupStencil(Es,Fs,Gs,Hs){if(!Hs||!this._sourceTilesOverlap[Hs.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const Is=this.painter.context,Js=Is.gl;if(Fs.length<=1)return void(this._overlapStencilType=!1);let Ks;if(Gs.isTileClipped())Ks=Fs.length,this._overlapStencilMode.test={func:Js.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(Fs[0].overscaledZ>Fs[Fs.length-1].overscaledZ))return void(this._overlapStencilType=!1);Ks=1,this._overlapStencilMode.test={func:Js.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+Ks>255&&(Is.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=Ks,this._overlapStencilMode.ref=this._stencilRef,Gs.isTileClipped()&&this._renderTileClippingMasks(Fs,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(Ls){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[Ls.key]),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(Ms,Ns){const Os=this.painter,Ps=this.painter.context,Qs=Ps.gl;Os._tileClippingMaskIDs={},Ps.setColorMode(a.ColorMode.disabled),Ps.setDepthMode(a.DepthMode.disabled);const Rs=Os.useProgram("clippingMask");for(const Ss of Ms){const Ts=Os._tileClippingMaskIDs[Ss.key]=--Ns;Rs.draw(Ps,Qs.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:Qs.ALWAYS,mask:0},Ts,255,Qs.KEEP,Qs.KEEP,Qs.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,op(Ss.projMatrix),"$clipping",Os.tileExtentBuffer,Os.quadTriangleIndexBuffer,Os.tileExtentSegments)}}pointCoordinate(Us){const Vs=this.painter.transform;if(Us.x<0||Us.x>Vs.width||Us.y<0||Us.y>Vs.height)return null;const Ws=[Us.x,Us.y,1,1];a.transformMat4$1(Ws,Ws,Vs.pixelMatrixInverse),a.scale$1(Ws,Ws,1/Ws[3]),Ws[0]/=Vs.worldSize,Ws[1]/=Vs.worldSize;const Xs=Vs._camera.position,Ys=a.mercatorZfromAltitude(1,Vs.center.lat),Zs=[Xs[0],Xs[1],Xs[2]/Ys,0],$s=a.subtract([],Ws.slice(0,3),Zs);a.normalize($s,$s);const _s=this.raycast(Zs,$s,this._exaggeration);return null!==_s&&_s?(a.scaleAndAdd(Zs,Zs,$s,_s),Zs[3]=Zs[2],Zs[2]*=Ys,Zs):null}drawDepth(){const at=this.painter,bt=at.context,ct=this.proxySourceCache,dt=Math.ceil(at.width),et=Math.ceil(at.height);if(this._depthFBO&&(this._depthFBO.width!==dt||this._depthFBO.height!==et)&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const ft=bt.gl,gt=bt.createFramebuffer(dt,et,!0);bt.activeTexture.set(ft.TEXTURE0);const ht=new a.Texture(bt,{width:dt,height:et,data:null},ft.RGBA);ht.bind(ft.NEAREST,ft.CLAMP_TO_EDGE),gt.colorAttachment.set(ht.texture);const it=bt.createRenderbuffer(bt.gl.DEPTH_COMPONENT16,dt,et);gt.depthAttachment.set(it),this._depthFBO=gt,this._depthTexture=ht}bt.bindFramebuffer.set(this._depthFBO.framebuffer),bt.viewport.set([0,0,dt,et]),(function(b,c,d,e){if("globe"===b.transform.projection.name)return;const f=b.context,g=f.gl;f.clear({depth:1});const h=b.useProgram("terrainDepth"),i=new a.DepthMode(g.LESS,a.DepthMode.ReadWrite,b.depthRangeFor3D);for(const j of e){const k=d.getTile(j),l=ip(j.projMatrix,0);c.setupElevationDraw(k,h),h.draw(f,g.TRIANGLES,i,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,l,"terrain_depth",c.gridBuffer,c.gridIndexBuffer,c.gridNoSkirtSegments)}})(at,this,ct,this.proxyCoords)}_setupProxiedCoordsForOrtho(jt,kt,lt){if(jt.getSource() instanceof rd)return this._setupProxiedCoordsForImageSource(jt,kt,lt);this._findCoveringTileCache[jt.id]=this._findCoveringTileCache[jt.id]||{};const mt=this.proxiedCoords[jt.id]=[],nt=this.proxyCoords;for(let ot=0;ot(a.min.x=Math.min(a.min.x,b.x-Et.x),a.min.y=Math.min(a.min.y,b.y-Et.y),a.max.x=Math.max(a.max.x,b.x-Et.x),a.max.y=Math.max(a.max.y,b.y-Et.y),a),{min:new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),Gt=(b,c)=>{const d=b.wrap+b.canonical.x/(1<g+Ft.max.x||e+fh+Ft.max.y};for(let Ht=0;Hta.key===Ot.tileID.key);if(Rt)return Rt}if(Ot.tileID.key!==Nt.key){const St=Nt.canonical.z-Ot.tileID.canonical.z;let Tt,Ut,Vt;Qt=a.create();const Wt=Ot.tileID.wrap-Nt.wrap<0?(Ut=(Tt=a.EXTENT>>St)*((Ot.tileID.canonical.x<=eu){const fu=Xt.canonical.z-eu;Yt.getSource().reparseOverscaled?(bu=Math.max(Xt.canonical.z+2,Yt.transform.tileZoom),au=new a.OverscaledTileID(bu,Xt.wrap,eu,Xt.canonical.x>>fu,Xt.canonical.y>>fu)):0!==fu&&(bu=eu,au=new a.OverscaledTileID(bu,Xt.wrap,eu,Xt.canonical.x>>fu,Xt.canonical.y>>fu))}au.key!==Xt.key&&(du.push(au.key),Zt=Yt.getTile(au))}const gu=a=>{du.forEach(b=>{$t[b]=a}),du.length=0};for(bu-=1;bu>=cu&&(!Zt||!Zt.hasData());bu--){Zt&&gu(Zt.tileID.key);const hu=au.calculateScaledKey(bu);if((Zt=Yt.getTileByID(hu))&&Zt.hasData())break;const iu=$t[hu];if(null===iu)break;void 0===iu?du.push(hu):Zt=Yt.getTileByID(iu)}return gu(Zt?Zt.tileID.key:null),Zt&&Zt.hasData()?Zt:null}findDEMTileFor(ju){return this.enabled?this._findTileCoveringTileID(ju,this.sourceCache):null}prepareDrawTile(ku){this.renderedToTile=!0}_clearRenderCacheForTile(lu,mu){let nu=this._tilesDirty[lu];nu||(nu=this._tilesDirty[lu]={}),nu[mu.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const ou=function(b){let c,d,e;const f=new a.StructArrayLayout2ui4,g=131;for(d=1;d<129;d++){for(c=1;c<129;c++)e=d*g+c,f.emplaceBack(e,e+1),f.emplaceBack(e,e+g),f.emplaceBack(e+1,e+g),128===d&&f.emplaceBack(e+g,e+g+1);f.emplaceBack(e+1,e+1+g)}return f}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(ou),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,ou.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function pu(a){const b=[];for(let c=0;cNu.indexOf(Ou)&&Nu.push(Ou);let Pu=zu?zu.defines():[];Pu=Pu.concat(Bu.map(a=>`#define ${a}`));const Qu=Pu.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",Eo,Do.fragmentSource,Co.fragmentSource,yu.fragmentSource).join("\n"),Ru=Pu.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",Eo,Do.vertexSource,Co.vertexSource,Bo.vertexSource,yu.vertexSource).join("\n"),Su=Gu.createShader(Gu.FRAGMENT_SHADER);if(Gu.isContextLost())return void(this.failedToCreate=!0);Gu.shaderSource(Su,Qu),Gu.compileShader(Su),Gu.attachShader(this.program,Su);const Tu=Gu.createShader(Gu.VERTEX_SHADER);if(Gu.isContextLost())return void(this.failedToCreate=!0);Gu.shaderSource(Tu,Ru),Gu.compileShader(Tu),Gu.attachShader(this.program,Tu),this.attributes={};const Uu={};this.numAttributes=Ju.length;for(let Vu=0;Vu>16,h>>16],u_pixel_coord_lower:[65535&g,65535&h]}}const Bv=(b,c,d,e)=>{const f=c.style.light,g=f.properties.get("position"),h=[g.x,g.y,g.z],i=a.create$1();"viewport"===f.properties.get("anchor")&&(a.fromRotation(i,-c.transform.angle),a.transformMat3(h,h,i));const j=f.properties.get("color");return{u_matrix:b,u_lightpos:h,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[j.r,j.g,j.b],u_vertical_gradient:+d,u_opacity:e}},Cv=(b,c,d,e,f,g,h)=>a.extend(Bv(b,c,d,e),Av(g,c,h),{u_height_factor:-Math.pow(2,f.overscaledZ)/h.tileSize/8}),Dv=a=>({u_matrix:a}),Ev=(b,c,d,e)=>a.extend(Dv(b),Av(d,c,e)),Fv=(a,b)=>({u_matrix:a,u_world:b}),Gv=(b,c,d,e,f)=>a.extend(Ev(b,c,d,e),{u_world:f}),Hv=(b,c,d,e)=>{const f=b.transform;let g;return g="map"===e.paint.get("circle-pitch-alignment")?f.calculatePixelsToTileUnitsMatrix(d):new Float32Array([f.pixelsToGLUnits[0],0,0,f.pixelsToGLUnits[1]]),{u_camera_to_center_distance:f.cameraToCenterDistance,u_matrix:b.translatePosMatrix(c.projMatrix,d,e.paint.get("circle-translate"),e.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:g}},Iv=a=>{const b=[];return"map"===a.paint.get("circle-pitch-alignment")&&b.push("PITCH_WITH_MAP"),"map"===a.paint.get("circle-pitch-scale")&&b.push("SCALE_WITH_MAP"),b},Jv=(b,c,d)=>{const e=a.EXTENT/d.tileSize;return{u_matrix:b,u_camera_to_center_distance:c.cameraToCenterDistance,u_extrude_scale:[c.pixelsToGLUnits[0]/e,c.pixelsToGLUnits[1]/e]}},Kv=(a,b,c=1)=>({u_matrix:a,u_color:b,u_overlay:0,u_overlay_scale:c}),Lv=(a,b,c,d)=>({u_matrix:a,u_extrude_scale:lb(b,1,c),u_intensity:d}),Mv=(b,c,d,e,f,g)=>{const h=b.transform,i=h.calculatePixelsToTileUnitsMatrix(c),j={u_matrix:Pv(b,c,d,f),u_pixels_to_tile_units:i,u_device_pixel_ratio:a.exported.devicePixelRatio,u_units_to_pixels:[1/h.pixelsToGLUnits[0],1/h.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:g,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(Qv(d)){const k=Ov(c,b.transform);j.u_texsize=c.lineAtlasTexture.size,j.u_scale=[k,e.fromScale,e.toScale],j.u_mix=e.t}return j},Nv=(b,c,d,e,f)=>{const g=b.transform,h=Ov(c,g);return{u_matrix:Pv(b,c,d,f),u_texsize:c.imageAtlasTexture.size,u_pixels_to_tile_units:g.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:a.exported.devicePixelRatio,u_image:0,u_scale:[h,e.fromScale,e.toScale],u_fade:e.t,u_units_to_pixels:[1/g.pixelsToGLUnits[0],1/g.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Ov(a,b){return 1/lb(a,1,b.tileZoom)}function Pv(a,b,c,d){return a.translatePosMatrix(d||b.tileID.projMatrix,b,c.paint.get("line-translate"),c.paint.get("line-translate-anchor"))}function Qv(a){const b=a.paint.get("line-dasharray").value;return b.value||"constant"!==b.kind}const Rv=(a,b,c,d,e,f)=>{var g,h;return{u_matrix:a,u_tl_parent:b,u_scale_parent:c,u_fade_t:d.mix,u_opacity:d.opacity*e.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:e.paint.get("raster-brightness-min"),u_brightness_high:e.paint.get("raster-brightness-max"),u_saturation_factor:(h=e.paint.get("raster-saturation"))>0?1-1/(1.001-h):-h,u_contrast_factor:(g=e.paint.get("raster-contrast"))>0?1/(1-g):1+g,u_spin_weights:Sv(e.paint.get("raster-hue-rotate")),u_perspective_transform:f}};function Sv(a){a*=Math.PI/180;const b=Math.sin(a),c=Math.cos(a);return[(2*c+1)/3,(-Math.sqrt(3)*b-c+1)/3,(Math.sqrt(3)*b-c+1)/3]}const Tv=(a,b,c,d,e,f,g,h,i,j,k,l,m,n)=>{const o=e.transform;return{u_is_size_zoom_constant:+("constant"===a||"source"===a),u_is_size_feature_constant:+("constant"===a||"camera"===a),u_size_t:b?b.uSizeT:0,u_size:b?b.uSize:0,u_camera_to_center_distance:o.cameraToCenterDistance,u_pitch:o.pitch/360*2*Math.PI,u_rotate_symbol:+c,u_aspect_ratio:o.width/o.height,u_fade_change:e.options.fadeDuration?e.symbolFadeChange:1,u_matrix:f,u_label_plane_matrix:g,u_coord_matrix:h,u_is_text:+i,u_pitch_with_map:+d,u_texsize:j,u_tile_id:k,u_zoom_transition:l,u_inv_rot_matrix:m,u_merc_center:n,u_texture:0}},Uv=(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)=>{const{cameraToCenterDistance:q,_pitch:r}=f.transform;return a.extend(Tv(b,c,d,e,f,g,h,i,j,k,m,n,o,p),{u_gamma_scale:e?q*Math.cos(f.terrain?0:r):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+l})},Vv=(b,c,d,e,f,g,h,i,j,k,l,m,n,o)=>a.extend(Uv(b,c,d,e,f,g,h,i,!0,j,!0,l,m,n,o),{u_texsize_icon:k,u_texture_icon:1}),Wv=(a,b,c)=>({u_matrix:a,u_opacity:b,u_color:c}),Xv=(b,c,d,e,f,g)=>a.extend(function(a,b,c,d){const e=c.imageManager.getPattern(a.from.toString()),f=c.imageManager.getPattern(a.to.toString()),{width:g,height:h}=c.imageManager.getPixelSize(),i=Math.pow(2,d.tileID.overscaledZ),j=d.tileSize*Math.pow(2,c.transform.tileZoom)/i,k=j*(d.tileID.canonical.x+d.tileID.wrap*i),l=j*d.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:e.tl,u_pattern_br_a:e.br,u_pattern_tl_b:f.tl,u_pattern_br_b:f.br,u_texsize:[g,h],u_mix:b.t,u_pattern_size_a:e.displaySize,u_pattern_size_b:f.displaySize,u_scale_a:b.fromScale,u_scale_b:b.toScale,u_tile_units_to_pixels:1/lb(d,1,c.transform.tileZoom),u_pixel_coord_upper:[k>>16,l>>16],u_pixel_coord_lower:[65535&k,65535&l]}}(e,g,d,f),{u_matrix:b,u_opacity:c}),Yv={fillExtrusion:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fillExtrusionPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_height_factor:new a.Uniform1f(b,c.u_height_factor),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fill:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),fillPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),fillOutline:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world)}),fillOutlinePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),circle:(b,c)=>({u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.UniformMatrix2f(b,c.u_extrude_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),collisionBox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.Uniform2f(b,c.u_extrude_scale)}),collisionCircle:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_inv_matrix:new a.UniformMatrix4f(b,c.u_inv_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_viewport_size:new a.Uniform2f(b,c.u_viewport_size)}),debug:(b,c)=>({u_color:new a.UniformColor(b,c.u_color),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_overlay:new a.Uniform1i(b,c.u_overlay),u_overlay_scale:new a.Uniform1f(b,c.u_overlay_scale)}),clippingMask:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmap:(b,c)=>({u_extrude_scale:new a.Uniform1f(b,c.u_extrude_scale),u_intensity:new a.Uniform1f(b,c.u_intensity),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmapTexture:(b,c)=>({u_image:new a.Uniform1i(b,c.u_image),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_opacity:new a.Uniform1f(b,c.u_opacity)}),hillshade:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_latrange:new a.Uniform2f(b,c.u_latrange),u_light:new a.Uniform2f(b,c.u_light),u_shadow:new a.UniformColor(b,c.u_shadow),u_highlight:new a.UniformColor(b,c.u_highlight),u_accent:new a.UniformColor(b,c.u_accent)}),hillshadePrepare:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_dimension:new a.Uniform2f(b,c.u_dimension),u_zoom:new a.Uniform1f(b,c.u_zoom),u_unpack:new a.Uniform4f(b,c.u_unpack)}),line:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_dash_image:new a.Uniform1i(b,c.u_dash_image),u_gradient_image:new a.Uniform1i(b,c.u_gradient_image),u_image_height:new a.Uniform1f(b,c.u_image_height),u_texsize:new a.Uniform2f(b,c.u_texsize),u_scale:new a.Uniform3f(b,c.u_scale),u_mix:new a.Uniform1f(b,c.u_mix),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),linePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_image:new a.Uniform1i(b,c.u_image),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),raster:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_tl_parent:new a.Uniform2f(b,c.u_tl_parent),u_scale_parent:new a.Uniform1f(b,c.u_scale_parent),u_fade_t:new a.Uniform1f(b,c.u_fade_t),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image0:new a.Uniform1i(b,c.u_image0),u_image1:new a.Uniform1i(b,c.u_image1),u_brightness_low:new a.Uniform1f(b,c.u_brightness_low),u_brightness_high:new a.Uniform1f(b,c.u_brightness_high),u_saturation_factor:new a.Uniform1f(b,c.u_saturation_factor),u_contrast_factor:new a.Uniform1f(b,c.u_contrast_factor),u_spin_weights:new a.Uniform3f(b,c.u_spin_weights),u_perspective_transform:new a.Uniform2f(b,c.u_perspective_transform)}),symbolIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_texture:new a.Uniform1i(b,c.u_texture)}),symbolSDF:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texture:new a.Uniform1i(b,c.u_texture),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),symbolTextAndIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texsize_icon:new a.Uniform2f(b,c.u_texsize_icon),u_texture:new a.Uniform1i(b,c.u_texture),u_texture_icon:new a.Uniform1i(b,c.u_texture_icon),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),background:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_color:new a.UniformColor(b,c.u_color)}),backgroundPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image:new a.Uniform1i(b,c.u_image),u_pattern_tl_a:new a.Uniform2f(b,c.u_pattern_tl_a),u_pattern_br_a:new a.Uniform2f(b,c.u_pattern_br_a),u_pattern_tl_b:new a.Uniform2f(b,c.u_pattern_tl_b),u_pattern_br_b:new a.Uniform2f(b,c.u_pattern_br_b),u_texsize:new a.Uniform2f(b,c.u_texsize),u_mix:new a.Uniform1f(b,c.u_mix),u_pattern_size_a:new a.Uniform2f(b,c.u_pattern_size_a),u_pattern_size_b:new a.Uniform2f(b,c.u_pattern_size_b),u_scale_a:new a.Uniform1f(b,c.u_scale_a),u_scale_b:new a.Uniform1f(b,c.u_scale_b),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_tile_units_to_pixels:new a.Uniform1f(b,c.u_tile_units_to_pixels)}),terrainRaster:hp,terrainDepth:hp,skybox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_cubemap:new a.Uniform1i(b,c.u_cubemap),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxGradient:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_center_direction:new a.Uniform3f(b,c.u_center_direction),u_radius:new a.Uniform1f(b,c.u_radius),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxCapture:(b,c)=>({u_matrix_3f:new a.UniformMatrix3f(b,c.u_matrix_3f),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_sun_intensity:new a.Uniform1f(b,c.u_sun_intensity),u_color_tint_r:new a.Uniform4f(b,c.u_color_tint_r),u_color_tint_m:new a.Uniform4f(b,c.u_color_tint_m),u_luminance:new a.Uniform1f(b,c.u_luminance)}),globeRaster:(b,c)=>({u_proj_matrix:new a.UniformMatrix4f(b,c.u_proj_matrix),u_globe_matrix:new a.UniformMatrix4f(b,c.u_globe_matrix),u_merc_matrix:new a.UniformMatrix4f(b,c.u_merc_matrix),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_image0:new a.Uniform1i(b,c.u_image0)}),globeAtmosphere:(b,c)=>({u_center:new a.Uniform2f(b,c.u_center),u_radius:new a.Uniform1f(b,c.u_radius),u_screen_size:new a.Uniform2f(b,c.u_screen_size),u_pixel_ratio:new a.Uniform1f(b,c.u_pixel_ratio),u_opacity:new a.Uniform1f(b,c.u_opacity),u_fadeout_range:new a.Uniform1f(b,c.u_fadeout_range),u_start_color:new a.Uniform3f(b,c.u_start_color),u_end_color:new a.Uniform3f(b,c.u_end_color)})};let Zv;function $v(b,c,d,e,f,g,h){var i;const j=b.context,k=j.gl,l=b.useProgram("collisionBox"),m=[];let n=0,o=0;for(let p=0;p0){const w=a.create(),x=t;a.mul(w,s.placementInvProjMatrix,b.transform.glCoordMatrix),a.mul(w,w,s.placementViewportMatrix),m.push({circleArray:v,circleOffset:o,transform:x,invTransform:w}),n+=v.length/4,o=n}u&&(b.terrain&&b.terrain.setupElevationDraw(r,l),l.draw(j,k.LINES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,Jv(t,b.transform,r),d.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,null,b.transform.zoom,null,u.collisionVertexBuffer,u.collisionVertexBufferExt))}if(!h||!m.length)return;const y=b.useProgram("collisionCircle"),z=new a.StructArrayLayout2f1f2i16;z.resize(4*n),z._trim();let A=0;for(const B of m)for(let C=0;C[0,0,0];o.clear();for(let u=0;u=0&&(q[v.associatedIconIndex]={shiftedAnchor:J,angle:K})}else ph(v.numGlyphs,o)}if(l){p.clear();const M=b.icon.placedSymbolArray;for(let N=0;N[0,0,0];hh(G,E.projMatrix,b,f,Y,$,s,k,ca,E)}const da=b.translatePosMatrix(E.projMatrix,F,g,h),ea=t||f&&z||aa?_v:Y,fa=b.translatePosMatrix($,F,g,h,!0),ga=J&&0!==d.paint.get(f?"text-halo-width":"icon-halo-width").constantOr(1);let ha;const ia=q.createInversionMatrix(E.toUnwrapped());ha=J?G.iconsInText?Vv(K.kind,N,u,s,b,da,ea,fa,P,T,O,B,ia,y):Uv(K.kind,N,u,s,b,da,ea,fa,f,P,!0,O,B,ia,y):Tv(K.kind,N,u,s,b,da,ea,fa,f,P,O,B,ia,y);const ja={program:M,buffers:H,uniformValues:ha,atlasTexture:Q,atlasTextureIcon:U,atlasInterpolation:R,atlasInterpolationIcon:S,isSDF:J,hasHalo:ga,tile:F,labelPlaneMatrixInv:Z};if(v&&G.canOverlap){w=!0;const ka=H.segments.get();for(const la of ka)C.push({segments:new a.SegmentVector([la]),sortKey:la.sortKey,state:ja})}else C.push({segments:H.segments,sortKey:0,state:ja})}for(const ma of(w&&C.sort((a,b)=>a.sortKey-b.sortKey),C)){const na=ma.state;if(b.terrain&&b.terrain.setupElevationDraw(na.tile,na.program,{useDepthForOcclusion:!A,labelPlaneMatrixInv:na.labelPlaneMatrixInv}),n.activeTexture.set(o.TEXTURE0),na.atlasTexture.bind(na.atlasInterpolation,o.CLAMP_TO_EDGE),na.atlasTextureIcon&&(n.activeTexture.set(o.TEXTURE1),na.atlasTextureIcon&&na.atlasTextureIcon.bind(na.atlasInterpolationIcon,o.CLAMP_TO_EDGE)),na.isSDF){const oa=na.uniformValues;na.hasHalo&&(oa.u_is_halo=1,ew(na.buffers,ma.segments,d,b,na.program,x,l,m,oa)),oa.u_is_halo=0}ew(na.buffers,ma.segments,d,b,na.program,x,l,m,na.uniformValues)}}function ew(b,c,d,e,f,g,h,i,j){const k=e.context;f.draw(k,k.gl.TRIANGLES,g,h,i,a.CullFaceMode.disabled,j,d.id,b.layoutVertexBuffer,b.indexBuffer,c,d.paint,e.transform.zoom,b.programConfigurations.get(d.id),b.dynamicLayoutVertexBuffer,b.opacityVertexBuffer)}function fw(b,c,d,e,f,g,h){const i=b.context.gl,j=d.paint.get("fill-pattern"),k=j&&j.constantOr(1),l=d.getCrossfadeParameters();let m,n,o,p,q;for(const r of(h?(n=k&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",m=i.LINES):(n=k?"fillPattern":"fill",m=i.TRIANGLES),e)){const s=c.getTile(r);if(k&&!s.patternsLoaded())continue;const t=s.getBucket(d);if(!t)continue;b.prepareDrawTile(r);const u=t.programConfigurations.get(d.id),v=b.useProgram(n,u);k&&(b.context.activeTexture.set(i.TEXTURE0),s.imageAtlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE),u.updatePaintBuffers(l));const w=j.constantOr(null);if(w&&s.imageAtlas){const x=s.imageAtlas,y=x.patternPositions[w.to.toString()],z=x.patternPositions[w.from.toString()];y&&z&&u.setConstantPatternPositions(y,z)}const A=b.translatePosMatrix(r.projMatrix,s,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(h){p=t.indexBuffer2,q=t.segments2;const B=b.terrain&&b.terrain.renderingToTexture?b.terrain.drapeBufferSize:[i.drawingBufferWidth,i.drawingBufferHeight];o="fillOutlinePattern"===n&&k?Gv(A,b,l,s,B):Fv(A,B)}else p=t.indexBuffer,q=t.segments,o=k?Ev(A,b,l,s):Dv(A);b.prepareDrawProgram(b.context,v,r.toUnwrapped()),v.draw(b.context,m,f,b.stencilModeForClipping(r),g,a.CullFaceMode.disabled,o,d.id,t.layoutVertexBuffer,p,q,d.paint,b.transform.zoom,u)}}function gw(b,c,d,e,f,g,h){const i=b.context,j=i.gl,k=d.paint.get("fill-extrusion-pattern"),l=k.constantOr(1),m=d.getCrossfadeParameters(),n=d.paint.get("fill-extrusion-opacity");for(const o of e){const p=c.getTile(o),q=p.getBucket(d);if(!q)continue;const r=q.programConfigurations.get(d.id),s=b.useProgram(l?"fillExtrusionPattern":"fillExtrusion",r);if(b.terrain){const t=b.terrain;if(!q.enableTerrain)continue;if(t.setupElevationDraw(p,s,{useMeterToDem:!0}),hw(i,c,o,q,d,t),!q.centroidVertexBuffer){const u=s.attributes.a_centroid_pos;void 0!==u&&j.vertexAttrib2f(u,0,0)}}l&&(b.context.activeTexture.set(j.TEXTURE0),p.imageAtlasTexture.bind(j.LINEAR,j.CLAMP_TO_EDGE),r.updatePaintBuffers(m));const v=k.constantOr(null);if(v&&p.imageAtlas){const w=p.imageAtlas,x=w.patternPositions[v.to.toString()],y=w.patternPositions[v.from.toString()];x&&y&&r.setConstantPatternPositions(x,y)}const z=b.translatePosMatrix(o.projMatrix,p,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),A=d.paint.get("fill-extrusion-vertical-gradient"),B=l?Cv(z,b,A,n,o,m,p):Bv(z,b,A,n);b.prepareDrawProgram(i,s,o.toUnwrapped()),s.draw(i,i.gl.TRIANGLES,f,g,h,a.CullFaceMode.backCCW,B,d.id,q.layoutVertexBuffer,q.indexBuffer,q.segments,d.paint,b.transform.zoom,r,b.terrain?q.centroidVertexBuffer:null)}}function hw(b,c,d,e,f,g){const h=[b=>{let c=b.canonical.x-1,d=b.wrap;return c<0&&(c=(1<{let c=b.canonical.x+1,d=b.wrap;return c===1<new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,(0===b.canonical.y?1<new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,b.canonical.y===(1<{const b=c.getSource().maxzoom,d=a=>{const b=c.getTileByID(a);if(b&&b.hasData())return b.getBucket(f)};let e,g,h;return(a.overscaledZ===a.canonical.z||a.overscaledZ>=b)&&(e=d(a.key)),a.overscaledZ>=b&&(g=d(a.calculateScaledKey(a.overscaledZ+1))),a.overscaledZ>b&&(h=d(a.calculateScaledKey(a.overscaledZ-1))),e||g||h},j=[0,0,0],k=(b,c)=>(j[0]=Math.min(b.min.y,c.min.y),j[1]=Math.max(b.max.y,c.max.y),j[2]=a.EXTENT-c.min.x>b.max.x?c.min.x-a.EXTENT:b.max.x,j),l=(b,c)=>(j[0]=Math.min(b.min.x,c.min.x),j[1]=Math.max(b.max.x,c.max.x),j[2]=a.EXTENT-c.min.y>b.max.y?c.min.y-a.EXTENT:b.max.y,j),m=[(a,b)=>k(a,b),(a,b)=>k(b,a),(a,b)=>l(a,b),(a,b)=>l(b,a)],n=new a.pointGeometry(0,0);let o,p,q;const r=(b,c,e,f,h)=>{const i=[[f?e:b,f?b:e,0],[f?e:c,f?c:e,0]],j=h<0?a.EXTENT+h:h,k=[f?j:(b+c)/2,f?(b+c)/2:j,0];return 0===e&&h<0||0!==e&&h>0?g.getForTilePoints(q,[k],!0,p):i.push(k),g.getForTilePoints(d,i,!0,o),Math.max(i[0][2],i[1][2],k[2])/g.exaggeration()};for(let s=0;s<4;s++){const t=e.borders[s];if(0===t.length&&(e.borderDone[s]=!0),e.borderDone[s])continue;const u=q=h[s](d),v=i(u);if(!v||!v.enableTerrain)continue;if(!(p=g.findDEMTileFor(u))||!p.dem)continue;if(!o){const w=g.findDEMTileFor(d);if(!w||!w.dem)return;o=w}const x=(s<2?1:5)-s,y=v.borders[x];let z=0;for(let A=0;AC[0]+3);)v.borderDone[x]||v.encodeCentroid(void 0,D,!1),z++;if(D&&zC[1]-3)&&(F++,++z!==y.length);)D=v.featuresOnBorder[y[z]];if(D=v.featuresOnBorder[y[E]],B.intersectsCount()>1||D.intersectsCount()>1||1!==F){1!==F&&(z=E),e.encodeCentroid(void 0,B,!1),v.borderDone[x]||v.encodeCentroid(void 0,D,!1);continue}const G=m[s](B,D),H=s%2?a.EXTENT-1:0;n.x=r(G[0],Math.min(a.EXTENT-1,G[1]),H,s<2,G[2]),n.y=0,e.encodeCentroid(n,B,!1),v.borderDone[x]||v.encodeCentroid(n,D,!1)}else e.encodeCentroid(void 0,B,!1)}e.borderDone[s]=e.needsCentroidUpdate=!0,v.borderDone[x]||(v.borderDone[x]=v.needsCentroidUpdate=!0)}(e.needsCentroidUpdate|| !e.centroidVertexBuffer&&0!==e.centroidVertexArray.length)&&e.uploadCentroid(b)}const iw=new a.Color(1,0,0,1),jw=new a.Color(0,1,0,1),kw=new a.Color(0,0,1,1),lw=new a.Color(1,0,1,1),mw=new a.Color(0,1,1,1);function nw(a,b,c,d){pw(a,0,b+c/2,a.transform.width,c,d)}function ow(a,b,c,d){pw(a,b-c/2,0,c,a.transform.height,d)}function pw(b,c,d,e,f,g){const h=b.context,i=h.gl;i.enable(i.SCISSOR_TEST),i.scissor(c*a.exported.devicePixelRatio,d*a.exported.devicePixelRatio,e*a.exported.devicePixelRatio,f*a.exported.devicePixelRatio),h.clear({color:g}),i.disable(i.SCISSOR_TEST)}function qw(b,c,d){const e=b.context,f=e.gl,g=d.projMatrix,h=b.useProgram("debug"),i=c.getTileByID(d.key);b.terrain&&b.terrain.setupElevationDraw(i,h);const j=a.DepthMode.disabled,k=a.StencilMode.disabled,l=b.colorModeForRenderPass(),m="$debug";e.activeTexture.set(f.TEXTURE0),b.emptyTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE),i._makeDebugTileBoundsBuffers(b.context,b.transform.projection);const n=i._tileDebugBuffer||b.debugBuffer,o=i._tileDebugIndexBuffer||b.debugIndexBuffer,p=i._tileDebugSegments||b.debugSegments;h.draw(e,f.LINE_STRIP,j,k,l,a.CullFaceMode.disabled,Kv(g,a.Color.red),m,n,o,p);const q=i.latestRawTileData,r=Math.floor((q&&q.byteLength||0)/1024),s=c.getTile(d).tileSize,t=512/Math.min(s,512)*(d.overscaledZ/b.transform.zoom)*.5;let u=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(u+=` => ${d.overscaledZ}`),(function(a,b){a.initDebugOverlayCanvas();const c=a.debugOverlayCanvas,d=a.context.gl,e=a.debugOverlayCanvas.getContext("2d");e.clearRect(0,0,c.width,c.height),e.shadowColor="white",e.shadowBlur=2,e.lineWidth=1.5,e.strokeStyle="white",e.textBaseline="top",e.font="bold 36px Open Sans, sans-serif",e.fillText(b,5,5),e.strokeText(b,5,5),a.debugOverlayTexture.update(c),a.debugOverlayTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE)})(b,`${u} ${r}kb`),h.draw(e,f.TRIANGLES,j,k,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,Kv(g,a.Color.transparent,t),m,b.debugBuffer,b.quadTriangleIndexBuffer,b.debugSegments)}const rw=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:sw}=rw;function tw(a,b,c,d){a.emplaceBack(b,c,d)}class uw{constructor(vw){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,tw(this.vertexArray,-1,-1,1),tw(this.vertexArray,1,-1,1),tw(this.vertexArray,-1,1,1),tw(this.vertexArray,1,1,1),tw(this.vertexArray,-1,-1,-1),tw(this.vertexArray,1,-1,-1),tw(this.vertexArray,-1,1,-1),tw(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=vw.createVertexBuffer(this.vertexArray,sw),this.indexBuffer=vw.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function ww(b,c,d,e,f,g){var h,i,j,k,l;const m=b.gl,n=c.paint.get("sky-atmosphere-color"),o=c.paint.get("sky-atmosphere-halo-color"),p=c.paint.get("sky-atmosphere-sun-intensity"),q=(h=a.fromMat4([],e),i=f,j=p,k=n,l=o,{u_matrix_3f:h,u_sun_direction:i,u_sun_intensity:j,u_color_tint_r:[k.r,k.g,k.b,k.a],u_color_tint_m:[l.r,l.g,l.b,l.a],u_luminance:5e-5});m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_CUBE_MAP_POSITIVE_X+g,c.skyboxTexture,0),d.draw(b,m.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,q,"skyboxCapture",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)}const xw={symbol:function(b,c,d,e,f){if("translucent"!==b.renderPass)return;const g=a.StencilMode.disabled,h=b.colorModeForRenderPass();d.layout.get("text-variable-anchor")&&(function(b,c,d,e,f,g,h){const i=c.transform,j="map"===f,k="map"===g,l=i.projection.createTileTransform(i,i.worldSize);for(const m of b){const n=e.getTile(m),o=n.getBucket(d);if(!o||o.projection!==i.projection.name||!o.text||!o.text.segments.get().length)continue;const p=a.evaluateSizeForZoom(o.textSizeData,i.zoom),q=c.transform.calculatePixelsToTileUnitsMatrix(n),r=ch(m.projMatrix,n.tileID.canonical,k,j,c.transform,q),s="none"!==d.layout.get("icon-text-fit")&&o.hasIconData();if(p){const t=Math.pow(2,i.zoom-n.tileID.overscaledZ);bw(o,j,k,h,a.symbolSize,i,r,m,t,p,s,l)}}})(e,b,d,c,d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),f),0!==d.paint.get("icon-opacity").constantOr(1)&&dw(b,c,d,e,!1,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),d.layout.get("icon-rotation-alignment"),d.layout.get("icon-pitch-alignment"),d.layout.get("icon-keep-upright"),g,h),0!==d.paint.get("text-opacity").constantOr(1)&&dw(b,c,d,e,!0,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),d.layout.get("text-keep-upright"),g,h),c.map.showCollisionBoxes&&($v(b,c,d,e,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),!0),$v(b,c,d,e,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),!1))},circle:function(b,c,d,e){if("translucent"!==b.renderPass)return;const f=d.paint.get("circle-opacity"),g=d.paint.get("circle-stroke-width"),h=d.paint.get("circle-stroke-opacity"),i=void 0!==d.layout.get("circle-sort-key").constantOr(1);if(0===f.constantOr(1)&&(0===g.constantOr(1)||0===h.constantOr(1)))return;const j=b.context,k=j.gl,l=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),m=a.StencilMode.disabled,n=b.colorModeForRenderPass(),o=[];for(let p=0;pa.sortKey-b.sortKey);const y={useDepthForOcclusion:"globe"!==b.transform.projection.name};for(const z of o){const{programConfiguration:A,program:B,layoutVertexBuffer:C,indexBuffer:D,uniformValues:E,tile:F}=z.state,G=z.segments;b.terrain&&b.terrain.setupElevationDraw(F,B,y),b.prepareDrawProgram(j,B,F.tileID.toUnwrapped()),B.draw(j,k.TRIANGLES,l,m,n,a.CullFaceMode.disabled,E,d.id,C,D,G,d.paint,b.transform.zoom,A)}},heatmap:function(b,c,d,e){if(0!==d.paint.get("heatmap-opacity"))if("offscreen"===b.renderPass){const f=b.context,g=f.gl,h=a.StencilMode.disabled,i=new a.ColorMode([g.ONE,g.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(a,b,c){const d=a.gl;a.activeTexture.set(d.TEXTURE1),a.viewport.set([0,0,b.width/4,b.height/4]);let e=c.heatmapFbo;if(e)d.bindTexture(d.TEXTURE_2D,e.colorAttachment.get()),a.bindFramebuffer.set(e.framebuffer);else{const f=d.createTexture();d.bindTexture(d.TEXTURE_2D,f),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.LINEAR),e=c.heatmapFbo=a.createFramebuffer(b.width/4,b.height/4,!1),(function(a,b,c,d){const e=a.gl;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,b.width/4,b.height/4,0,e.RGBA,a.extRenderToTextureHalfFloat?a.extTextureHalfFloat.HALF_FLOAT_OES:e.UNSIGNED_BYTE,null),d.colorAttachment.set(c)})(a,b,f,e)}})(f,b,d),f.clear({color:a.Color.transparent});for(let j=0;j{const b=[];Qv(a)&&b.push("RENDER_LINE_DASH"),a.paint.get("line-gradient")&&b.push("RENDER_LINE_GRADIENT");const c=a.paint.get("line-pattern").constantOr(1),d=1!==a.paint.get("line-opacity").constantOr(1);return!c&&d&&b.push("RENDER_LINE_ALPHA_DISCARD"),b})(d);let u=t.includes("RENDER_LINE_ALPHA_DISCARD");for(const v of(b.terrain&&b.terrain.clipOrMaskOverlapStencilType()&&(u=!1),e)){const w=c.getTile(v);if(n&&!w.patternsLoaded())continue;const x=w.getBucket(d);if(!x)continue;b.prepareDrawTile(v);const y=x.programConfigurations.get(d.id),z=b.useProgram(q,y,t),A=m.constantOr(null);if(A&&w.imageAtlas){const B=w.imageAtlas,C=B.patternPositions[A.to.toString()],D=B.patternPositions[A.from.toString()];C&&D&&y.setConstantPatternPositions(C,D)}const E=j.constantOr(null),F=l.constantOr(null);if(!n&&E&&F&&w.lineAtlas){const G=w.lineAtlas,H=G.getDash(E.to,F),I=G.getDash(E.from,F);H&&I&&y.setConstantPatternPositions(H,I)}const J=b.terrain?v.projMatrix:null,K=n?Nv(b,w,d,p,J):Mv(b,w,d,p,J,x.lineClipsArray.length);if(o){const L=x.gradients[d.id];let M=L.texture;if(d.gradientVersion!==L.version){let N=256;if(d.stepInterpolant){const O=c.getSource().maxzoom,P=v.canonical.z===O?Math.ceil(1<{z.draw(r,s.TRIANGLES,h,c,i,a.CullFaceMode.disabled,K,d.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,d.paint,b.transform.zoom,y,x.layoutVertexBuffer2)};if(u){const R=b.stencilModeForClipping(v).ref;0===R&&b.terrain&&r.clear({stencil:0});const S={func:s.EQUAL,mask:255};K.u_alpha_discard_threshold=.8,Q(new a.StencilMode(S,R,255,s.KEEP,s.KEEP,s.INVERT)),K.u_alpha_discard_threshold=0,Q(new a.StencilMode(S,R,255,s.KEEP,s.KEEP,s.KEEP))}else Q(b.stencilModeForClipping(v))}u&&(b.resetStencilClippingMasks(),b.terrain&&r.clear({stencil:0}))},fill:function(b,c,d,e){const f=d.paint.get("fill-color"),g=d.paint.get("fill-opacity");if(0===g.constantOr(1))return;const h=b.colorModeForRenderPass(),i=d.paint.get("fill-pattern"),j=b.opaquePassEnabledForLayer()&&!i.constantOr(1)&&1===f.constantOr(a.Color.transparent).a&&1===g.constantOr(0)?"opaque":"translucent";if(b.renderPass===j){const k=b.depthModeForSublayer(1,"opaque"===b.renderPass?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);fw(b,c,d,e,k,h,!1)}if("translucent"===b.renderPass&&d.paint.get("fill-antialias")){const l=b.depthModeForSublayer(d.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);fw(b,c,d,e,l,h,!0)}},"fill-extrusion":function(b,c,d,e){const f=d.paint.get("fill-extrusion-opacity");if(0!==f&&"translucent"===b.renderPass){const g=new a.DepthMode(b.context.gl.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);if(1!==f||d.paint.get("fill-extrusion-pattern").constantOr(1))gw(b,c,d,e,g,a.StencilMode.disabled,a.ColorMode.disabled),gw(b,c,d,e,g,b.stencilModeFor3D(),b.colorModeForRenderPass()),b.resetStencilClippingMasks();else{const h=b.colorModeForRenderPass();gw(b,c,d,e,g,a.StencilMode.disabled,h)}}},hillshade:function(b,c,d,e){if("offscreen"!==b.renderPass&&"translucent"!==b.renderPass)return;const f=b.context,g=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),h=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[j,k]="translucent"!==b.renderPass||i?[{},e]:b.stencilConfigForOverlap(e);for(const l of k){const m=c.getTile(l);if(m.needsHillshadePrepare&&"offscreen"===b.renderPass)gp(b,m,d,g,a.StencilMode.disabled,h);else if("translucent"===b.renderPass){const n=i&&b.terrain?b.terrain.stencilModeForRTTOverlap(l):j[l.overscaledZ];ep(b,l,m,d,g,n,h)}}f.viewport.set([0,0,b.width,b.height]),b.resetStencilClippingMasks()},raster:function(b,c,d,e,f,g){if("translucent"!==b.renderPass)return;if(0===d.paint.get("raster-opacity"))return;if(!e.length)return;const h=b.context,i=h.gl,j=c.getSource(),k=b.useProgram("raster"),l=b.colorModeForRenderPass(),m=b.terrain&&b.terrain.renderingToTexture,[n,o]=j instanceof rd||m?[{},e]:b.stencilConfigForOverlap(e),p=o[o.length-1].overscaledZ,q=!b.options.moving;for(const r of o){const s=m?a.DepthMode.disabled:b.depthModeForSublayer(r.overscaledZ-p,1===d.paint.get("raster-opacity")?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,i.LESS),t=r.toUnwrapped(),u=c.getTile(r);if(m&&(!u||!u.hasData()))continue;const v=m?r.projMatrix:b.transform.calculateProjMatrix(t,q),w=b.terrain&&m?b.terrain.stencilModeForRTTOverlap(r):n[r.overscaledZ],x=g?0:d.paint.get("raster-fade-duration");u.registerFadeDuration(x);const y=c.findLoadedParent(r,0),z=pp(u,y,c,b.transform,x);let A,B;b.terrain&&b.terrain.prepareDrawTile(r);const C="nearest"===d.paint.get("raster-resampling")?i.NEAREST:i.LINEAR;h.activeTexture.set(i.TEXTURE0),u.texture.bind(C,i.CLAMP_TO_EDGE),h.activeTexture.set(i.TEXTURE1),y?(y.texture.bind(C,i.CLAMP_TO_EDGE),A=Math.pow(2,y.tileID.overscaledZ-u.tileID.overscaledZ),B=[u.tileID.canonical.x*A%1,u.tileID.canonical.y*A%1]):u.texture.bind(C,i.CLAMP_TO_EDGE);const D=Rv(v,B||[0,0],A||1,z,d,j instanceof rd?j.perspectiveTransform:[0,0]);if(b.prepareDrawProgram(h,k,t),j instanceof rd)k.draw(h,i.TRIANGLES,s,a.StencilMode.disabled,l,a.CullFaceMode.disabled,D,d.id,j.boundsBuffer,b.quadTriangleIndexBuffer,j.boundsSegments);else{const{tileBoundsBuffer:E,tileBoundsIndexBuffer:F,tileBoundsSegments:G}=b.getTileBoundsBuffers(u);k.draw(h,i.TRIANGLES,s,w,l,a.CullFaceMode.disabled,D,d.id,E,F,G)}}b.resetStencilClippingMasks()},background:function(b,c,d,e){const f=d.paint.get("background-color"),g=d.paint.get("background-opacity");if(0===g)return;const h=b.context,i=h.gl,j=b.transform,k=j.tileSize,l=d.paint.get("background-pattern");if(b.isPatternMissing(l))return;const m=!l&&1===f.a&&1===g&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==m)return;const n=a.StencilMode.disabled,o=b.depthModeForSublayer(0,"opaque"===m?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),p=b.colorModeForRenderPass(),q=b.useProgram(l?"backgroundPattern":"background");let r,s=e;s||(r=b.getBackgroundTiles(),s=Object.values(r).map(a=>a.tileID)),l&&(h.activeTexture.set(i.TEXTURE0),b.imageManager.bind(b.context));const t=d.getCrossfadeParameters();for(const u of s){const v=u.toUnwrapped(),w=e?u.projMatrix:b.transform.calculateProjMatrix(v);b.prepareDrawTile(u);const x=c?c.getTile(u):r?r[u.key]:new a.Tile(u,k,j.zoom,b),y=l?Xv(w,g,b,l,{tileID:u,tileSize:k},t):Wv(w,g,f);b.prepareDrawProgram(h,q,v);const{tileBoundsBuffer:z,tileBoundsIndexBuffer:A,tileBoundsSegments:B}=b.getTileBoundsBuffers(x);q.draw(h,i.TRIANGLES,o,n,p,a.CullFaceMode.disabled,y,d.id,z,A,B)}},sky:function(b,c,d){const e=b.transform,f="mercator"===e.projection.name||"globe"===e.projection.name?1:a.smoothstep(7,8,e.zoom),g=d.paint.get("sky-opacity")*f;if(0===g)return;const h=b.context,i=d.paint.get("sky-type"),j=new a.DepthMode(h.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),k=b.frameCounter/1e3%1;"atmosphere"===i?"offscreen"===b.renderPass?d.needsSkyboxCapture(b)&&((function(b,c,d,e){const f=b.context,g=f.gl;let h=c.skyboxFbo;if(!h){h=c.skyboxFbo=f.createFramebuffer(32,32,!1),c.skyboxGeometry=new uw(f),c.skyboxTexture=f.gl.createTexture(),g.bindTexture(g.TEXTURE_CUBE_MAP,c.skyboxTexture),g.texParameteri(g.TEXTURE_CUBE_MAP,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE),g.texParameteri(g.TEXTURE_CUBE_MAP,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE),g.texParameteri(g.TEXTURE_CUBE_MAP,g.TEXTURE_MIN_FILTER,g.LINEAR),g.texParameteri(g.TEXTURE_CUBE_MAP,g.TEXTURE_MAG_FILTER,g.LINEAR);for(let i=0;i<6;++i)g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,g.RGBA,32,32,0,g.RGBA,g.UNSIGNED_BYTE,null)}f.bindFramebuffer.set(h.framebuffer),f.viewport.set([0,0,32,32]);const j=c.getCenter(b,!0),k=b.useProgram("skyboxCapture"),l=new Float64Array(16);a.identity(l),a.rotateY(l,l,-(.5*Math.PI)),ww(f,c,k,l,j,0),a.identity(l),a.rotateY(l,l,.5*Math.PI),ww(f,c,k,l,j,1),a.identity(l),a.rotateX(l,l,-(.5*Math.PI)),ww(f,c,k,l,j,2),a.identity(l),a.rotateX(l,l,.5*Math.PI),ww(f,c,k,l,j,3),a.identity(l),ww(f,c,k,l,j,4),a.identity(l),a.rotateY(l,l,Math.PI),ww(f,c,k,l,j,5),f.viewport.set([0,0,b.width,b.height])})(b,d),d.markSkyboxValid(b)):"sky"===b.renderPass&&(function(b,c,d,e,f){const g=b.context,h=g.gl,i=b.transform,j=b.useProgram("skybox");g.activeTexture.set(h.TEXTURE0),h.bindTexture(h.TEXTURE_CUBE_MAP,c.skyboxTexture);const k={u_matrix:i.skyboxMatrix,u_sun_direction:c.getCenter(b,!1),u_cubemap:0,u_opacity:e,u_temporal_offset:f};b.prepareDrawProgram(g,j),j.draw(g,h.TRIANGLES,d,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.backCW,k,"skybox",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)})(b,d,j,g,k):"gradient"===i&&"sky"===b.renderPass&&(function(b,c,d,e,f){var g,h,i,j,k;const l=b.context,m=l.gl,n=b.transform,o=b.useProgram("skyboxGradient");c.skyboxGeometry||(c.skyboxGeometry=new uw(l)),l.activeTexture.set(m.TEXTURE0);let p=c.colorRampTexture;p||(p=c.colorRampTexture=new a.Texture(l,c.colorRamp,m.RGBA)),p.bind(m.LINEAR,m.CLAMP_TO_EDGE);const q=(g=n.skyboxMatrix,h=c.getCenter(b,!1),i=c.paint.get("sky-gradient-radius"),j=e,k=f,{u_matrix:g,u_color_ramp:0,u_center_direction:h,u_radius:a.degToRad(i),u_opacity:j,u_temporal_offset:k});b.prepareDrawProgram(l,o),o.draw(l,m.TRIANGLES,d,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.backCW,q,"skyboxGradient",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)})(b,d,j,g,k)},debug:function(a,b,c){for(let d=0;dGw.getOpacity(this.transform.pitch)||.03>Gw.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);const[Hw,Iw]=Gw.getFovAdjustedRange(this.transform._fov);if(Hw>Iw)return void(this.transform.fogCullDistSq=null);const Jw=Hw+.78*(Iw-Hw);this.transform.fogCullDistSq=Jw*Jw}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(Kw,Lw){if(this.width=Kw*a.exported.devicePixelRatio,this.height=Lw*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const Mw of this.style.order)this.style._layers[Mw].resize()}setup(){const Nw=this.context,Ow=new a.StructArrayLayout2i4;Ow.emplaceBack(0,0),Ow.emplaceBack(a.EXTENT,0),Ow.emplaceBack(0,a.EXTENT),Ow.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=Nw.createVertexBuffer(Ow,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);const Pw=new a.StructArrayLayout2i4;Pw.emplaceBack(0,0),Pw.emplaceBack(a.EXTENT,0),Pw.emplaceBack(0,a.EXTENT),Pw.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=Nw.createVertexBuffer(Pw,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);const Qw=new a.StructArrayLayout2i4;Qw.emplaceBack(-1,-1),Qw.emplaceBack(1,-1),Qw.emplaceBack(-1,1),Qw.emplaceBack(1,1),this.viewportBuffer=Nw.createVertexBuffer(Qw,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);const Rw=new a.StructArrayLayout4i8;Rw.emplaceBack(0,0,0,0),Rw.emplaceBack(a.EXTENT,0,a.EXTENT,0),Rw.emplaceBack(0,a.EXTENT,0,a.EXTENT),Rw.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=Nw.createVertexBuffer(Rw,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);const Sw=new a.StructArrayLayout3ui6;Sw.emplaceBack(0,1,2),Sw.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=Nw.createIndexBuffer(Sw);const Tw=new a.StructArrayLayout1ui2;for(const Uw of[0,1,3,2,0])Tw.emplaceBack(Uw);this.debugIndexBuffer=Nw.createIndexBuffer(Tw),this.emptyTexture=new a.Texture(Nw,{width:1,height:1,data:new Uint8Array([0,0,0,0])},Nw.gl.RGBA),this.identityMat=a.create();const Vw=this.context.gl;this.stencilClearMode=new a.StencilMode({func:Vw.ALWAYS,mask:0},0,255,Vw.ZERO,Vw.ZERO,Vw.ZERO),this.loadTimeStamps.push(a.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(Ww){return Ww._makeTileBoundsBuffers(this.context,this.transform.projection),Ww._tileBoundsBuffer?{tileBoundsBuffer:Ww._tileBoundsBuffer,tileBoundsIndexBuffer:Ww._tileBoundsIndexBuffer,tileBoundsSegments:Ww._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const Xw=this.context,Yw=Xw.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(Xw,Yw.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,op(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(Zw,$w,_w){if(!$w||this.currentStencilSource===$w.id||!Zw.isTileClipped()||!_w||0===_w.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let ax=!1;for(const bx of _w)if(void 0===this._tileClippingMaskIDs[bx.key]){ax=!0;break}if(!ax)return}this.currentStencilSource=$w.id;const cx=this.context,dx=cx.gl;this.nextStencilID+_w.length>256&&this.clearStencil(),cx.setColorMode(a.ColorMode.disabled),cx.setDepthMode(a.DepthMode.disabled);const ex=this.useProgram("clippingMask");for(const fx of(this._tileClippingMaskIDs={},_w)){const gx=$w.getTile(fx),hx=this._tileClippingMaskIDs[fx.key]=this.nextStencilID++,{tileBoundsBuffer:ix,tileBoundsIndexBuffer:jx,tileBoundsSegments:kx}=this.getTileBoundsBuffers(gx);ex.draw(cx,dx.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:dx.ALWAYS,mask:0},hx,255,dx.KEEP,dx.KEEP,dx.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,op(fx.projMatrix),"$clipping",ix,jx,kx)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const lx=this.nextStencilID++,mx=this.context.gl;return new a.StencilMode({func:mx.NOTEQUAL,mask:255},lx,255,mx.KEEP,mx.KEEP,mx.REPLACE)}stencilModeForClipping(nx){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(nx);const ox=this.context.gl;return new a.StencilMode({func:ox.EQUAL,mask:255},this._tileClippingMaskIDs[nx.key],0,ox.KEEP,ox.KEEP,ox.REPLACE)}stencilConfigForOverlap(px){const qx=this.context.gl,rx=px.sort((a,b)=>b.overscaledZ-a.overscaledZ),sx=rx[rx.length-1].overscaledZ,tx=rx[0].overscaledZ-sx+1;if(tx>1){this.currentStencilSource=void 0,this.nextStencilID+tx>256&&this.clearStencil();const ux={};for(let vx=0;vx=0;this.currentLayer--){const Tx=this.style._layers[Ex[this.currentLayer]],Ux=Cx._getLayerSourceCache(Tx);if(Tx.isSky())continue;const Vx=Ux?Jx[Ux.id]:void 0;this._renderTileClippingMasks(Tx,Ux,Vx),this.renderLayer(this,Ux,Tx,Vx)}if(this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const b=Cx._getLayerSourceCache(a);b&&!a.isHidden(this.transform.zoom)&&(!_x||_x.getSource().maxzoom0?Cy.pop():null}isPatternMissing(Dy){if(!Dy)return!1;if(!Dy.from||!Dy.to)return!0;const Ey=this.imageManager.getPattern(Dy.from.toString()),Fy=this.imageManager.getPattern(Dy.to.toString());return!Ey||!Fy}currentGlobalDefines(){const Gy=this.terrain&&this.terrain.renderingToTexture,Hy=this.style&&this.style.fog,Iy=[];return this.terrain&&!this.terrain.renderingToTexture&&Iy.push("TERRAIN"),Hy&&!Gy&&0!==Hy.getOpacity(this.transform.pitch)&&Iy.push("FOG"),Gy&&Iy.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&Iy.push("OVERDRAW_INSPECTOR"),Iy}useProgram(Jy,Ky,Ly){this.cache=this.cache||{};const My=this.currentGlobalDefines().concat(Ly||[]),Ny=qu.cacheKey(Jy,My,Ky);return this.cache[Ny]||(this.cache[Ny]=new qu(this.context,Jy,Fo[Jy],Ky,Yv[Jy],My)),this.cache[Ny]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const Oy=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(Oy.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=a.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(Py){this.terrain&&this.terrain.prepareDrawTile(Py)}prepareDrawProgram(Qy,Ry,Sy){if(this.terrain&&this.terrain.renderingToTexture)return;const Ty=this.style.fog;if(Ty){const Uy=Ty.getOpacity(this.transform.pitch);0!==Uy&&Ry.setFogUniformValues(Qy,((a,b,c,d)=>{const e=b.properties.get("color"),f=a.frameCounter/1e3%1,g=[e.r/e.a,e.g/e.a,e.b/e.a,d];return{u_fog_matrix:c?a.transform.calculateFogTileMatrix(c):a.identityMat,u_fog_range:b.getFovAdjustedRange(a.transform._fov),u_fog_color:g,u_fog_horizon_blend:b.properties.get("horizon-blend"),u_fog_temporal_offset:f}})(this,Ty,Sy,Uy))}}setTileLoadedFlag(Vy){this.tileLoaded=Vy}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const Wy=this.context.gl,Xy=Wy.createTexture();return Wy.bindTexture(Wy.TEXTURE_2D,Xy),Wy.copyTexImage2D(Wy.TEXTURE_2D,0,Wy.RGBA,0,0,Wy.drawingBufferWidth,Wy.drawingBufferHeight,0),Xy}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const Yy=this.style&&this.style.fog;return!!Yy&&0!==Yy.getOpacity(this.transform.pitch)}getBackgroundTiles(){const Zy=this._backgroundTiles,$y=this._backgroundTiles={},_y=this.transform.coveringTiles({tileSize:512});for(const az of _y)$y[az.key]=Zy[az.key]||new a.Tile(az,512,this.transform.tileZoom,this);return $y}clearBackgroundTiles(){this._backgroundTiles={}}}class bz{constructor(cz=0,dz=0,ez=0,fz=0){if(isNaN(cz)||cz<0||isNaN(dz)||dz<0||isNaN(ez)||ez<0||isNaN(fz)||fz<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=cz,this.bottom=dz,this.left=ez,this.right=fz}interpolate(gz,hz,iz){return null!=hz.top&&null!=gz.top&&(this.top=a.number(gz.top,hz.top,iz)),null!=hz.bottom&&null!=gz.bottom&&(this.bottom=a.number(gz.bottom,hz.bottom,iz)),null!=hz.left&&null!=gz.left&&(this.left=a.number(gz.left,hz.left,iz)),null!=hz.right&&null!=gz.right&&(this.right=a.number(gz.right,hz.right,iz)),this}getCenter(jz,kz){const lz=a.clamp((this.left+jz-this.right)/2,0,jz),mz=a.clamp((this.top+kz-this.bottom)/2,0,kz);return new a.pointGeometry(lz,mz)}equals(nz){return this.top===nz.top&&this.bottom===nz.bottom&&this.left===nz.left&&this.right===nz.right}clone(){return new bz(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function oz(b,c){const d=a.getColumn(b,3);a.fromQuat(b,c),a.setColumn(b,3,d)}function pz(b,c){a.setColumn(b,3,[c[0],c[1],c[2],1])}function qz(b,c){const d=a.identity$1([]);return a.rotateZ$1(d,d,-c),a.rotateX$1(d,d,-b),d}function rz(b,c){const d=[b[0],b[1],0],e=[c[0],c[1],0];if(a.length(d)>=1e-15){const f=a.normalize([],d);a.scale$2(e,f,a.dot(e,f)),c[0]=e[0],c[1]=e[1]}const g=a.cross([],c,b);if(1e-15>a.len(g))return null;const h=Math.atan2(-g[1],g[0]);return qz(Math.atan2(Math.sqrt(b[0]*b[0]+b[1]*b[1]),-b[2]),h)}class sz{constructor(tz,uz){this.position=tz,this.orientation=uz}get position(){return this._position}set position(vz){this._position=this._renderWorldCopies?(function(b){if(!b)return;const c=Array.isArray(b)?new a.MercatorCoordinate(b[0],b[1],b[2]):b;return c.x=a.wrap(c.x,0,1),c})(vz):vz}lookAtPoint(wz,xz){if(this.orientation=null,!this.position)return;const yz=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(wz)):0,zz=this.position,Az=a.MercatorCoordinate.fromLngLat(wz,yz),Bz=[Az.x-zz.x,Az.y-zz.y,Az.z-zz.z];xz||(xz=[0,0,1]),xz[2]=Math.abs(xz[2]),this.orientation=rz(Bz,xz)}setPitchBearing(Cz,Dz){this.orientation=qz(a.degToRad(Cz),a.degToRad(-Dz))}}class Ez{constructor(Fz,Gz){this._transform=a.identity([]),this._orientation=a.identity$1([]),Gz&&(this._orientation=Gz,oz(this._transform,this._orientation)),Fz&&pz(this._transform,Fz)}get mercatorPosition(){const Hz=this.position;return new a.MercatorCoordinate(Hz[0],Hz[1],Hz[2])}get position(){const Iz=a.getColumn(this._transform,3);return[Iz[0],Iz[1],Iz[2]]}set position(Jz){pz(this._transform,Jz)}get orientation(){return this._orientation}set orientation(Kz){this._orientation=Kz,oz(this._transform,this._orientation)}getPitchBearing(){const Lz=this.forward(),Mz=this.right();return{bearing:Math.atan2(-Mz[1],Mz[0]),pitch:Math.atan2(Math.sqrt(Lz[0]*Lz[0]+Lz[1]*Lz[1]),-Lz[2])}}setPitchBearing(Nz,Oz){this._orientation=qz(Nz,Oz),oz(this._transform,this._orientation)}forward(){const Pz=a.getColumn(this._transform,2);return[-Pz[0],-Pz[1],-Pz[2]]}up(){const Qz=a.getColumn(this._transform,1);return[-Qz[0],-Qz[1],-Qz[2]]}right(){const Rz=a.getColumn(this._transform,0);return[Rz[0],Rz[1],Rz[2]]}getCameraToWorld(Sz,Tz){const Uz=new Float64Array(16);return a.invert(Uz,this.getWorldToCamera(Sz,Tz)),Uz}getWorldToCameraPosition(Vz,Wz,Xz){const Yz=this.position;a.scale$2(Yz,Yz,-Vz);const Zz=new Float64Array(16);return a.fromScaling(Zz,[Xz,Xz,Xz]),a.translate(Zz,Zz,Yz),Zz[10]*=Wz,Zz}getWorldToCamera($z,_z){const aA=new Float64Array(16),bA=new Float64Array(4),cA=this.position;return a.conjugate(bA,this._orientation),a.scale$2(cA,cA,-$z),a.fromQuat(aA,bA),a.translate(aA,aA,cA),aA[1]*=-1,aA[5]*=-1,aA[9]*=-1,aA[13]*=-1,aA[8]*=_z,aA[9]*=_z,aA[10]*=_z,aA[11]*=_z,aA}getCameraToClipPerspective(dA,eA,fA,gA){const hA=new Float64Array(16);return a.perspective(hA,dA,eA,fA,gA),hA}getDistanceToElevation(iA){const jA=0===iA?0:a.mercatorZfromAltitude(iA,this.position[1]);return(jA-this.position[2])/this.forward()[2]}clone(){return new Ez([...this.position],[...this.orientation])}}function kA(b,c){const d=mA(b),e=function(b,c,d,e,f){const g=new a.LngLat(d.lng-180*nA,d.lat),h=new a.LngLat(d.lng+180*nA,d.lat),i=b.project(g.lng,g.lat),j=b.project(h.lng,h.lat),k=-Math.atan2(j.y-i.y,j.x-i.x),l=a.MercatorCoordinate.fromLngLat(d);l.y=a.clamp(l.y,-0.999975,.999975);const m=l.toLngLat(),n=b.project(m.lng,m.lat),o=a.MercatorCoordinate.fromLngLat(m);o.x+=nA;const p=o.toLngLat(),q=b.project(p.lng,p.lat),r=pA(q.x-n.x,q.y-n.y,k),s=a.MercatorCoordinate.fromLngLat(m);s.y+=nA;const t=s.toLngLat(),u=b.project(t.lng,t.lat),v=pA(u.x-n.x,u.y-n.y,k),w=Math.abs(r.x)/Math.abs(v.y),x=a.identity([]);a.rotateZ(x,x,-k*(1-(f?0:e)));const y=a.identity([]);return a.scale(y,y,[1,1-(1-w)*e,1]),y[4]=-v.x/v.y*e,a.rotateZ(y,y,k),a.multiply$1(y,x,y),y}(b.projection,0,b.center,d,c),f=lA(b);return a.scale(e,e,[f,f,1]),e}function lA(b){const c=b.projection,d=mA(b),e=oA(c,b.center),f=oA(c,a.LngLat.convert(c.center));return Math.pow(2,e*d+(1-d)*f)}function mA(b){const c=b.projection.range;if(!c)return 0;const d=Math.max(b.width,b.height),e=Math.log(d/1024)/Math.LN2;return a.smoothstep(c[0]+e,c[1]+e,b.zoom)}const nA=1/4e4;function oA(b,c){const d=a.clamp(c.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),e=new a.LngLat(c.lng-180*nA,d),f=new a.LngLat(c.lng+180*nA,d),g=b.project(e.lng,d),h=b.project(f.lng,d),i=a.MercatorCoordinate.fromLngLat(e),j=a.MercatorCoordinate.fromLngLat(f),k=h.x-g.x,l=h.y-g.y,m=j.x-i.x,n=j.y-i.y;return Math.log(Math.sqrt((m*m+n*n)/(k*k+l*l)))/Math.LN2}function pA(a,b,c){const d=Math.cos(c),e=Math.sin(c);return{x:a*d-b*e,y:a*e+b*d}}class qA{constructor(rA,sA,tA,uA,vA){this.tileSize=512,this._renderWorldCopies=void 0===vA||vA,this._minZoom=rA||0,this._maxZoom=sA||22,this._minPitch=null==tA?0:tA,this._maxPitch=null==uA?60:uA,this.setProjection(),this.setMaxBounds(),this.width=0,this.height=0,this._center=new a.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new bz,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Ez,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const wA=new qA(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return wA.setProjection(this.getProjection()),wA._elevation=this._elevation,wA._centerAltitude=this._centerAltitude,wA.tileSize=this.tileSize,wA.setMaxBounds(this.getMaxBounds()),wA.width=this.width,wA.height=this.height,wA.cameraElevationReference=this.cameraElevationReference,wA._center=this._center,wA._setZoom(this.zoom),wA._cameraZoom=this._cameraZoom,wA.angle=this.angle,wA._fov=this._fov,wA._pitch=this._pitch,wA._nearZ=this._nearZ,wA._farZ=this._farZ,wA._averageElevation=this._averageElevation,wA._unmodified=this._unmodified,wA._edgeInsets=this._edgeInsets.clone(),wA._camera=this._camera.clone(),wA._calcMatrices(),wA.freezeTileCoverage=this.freezeTileCoverage,wA}get elevation(){return this._elevation}set elevation(xA){this._elevation!==xA&&(this._elevation=xA,xA?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(yA){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),yA&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels"])}setProjection(zA){null==zA&&(zA={name:"mercator"}),this.projectionOptions=zA;const AA=this.projection?this.getProjection():void 0;return this.projection=a.getProjection(zA),!f(AA,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(BA){this._minZoom!==BA&&(this._minZoom=BA,this.zoom=Math.max(this.zoom,BA))}get maxZoom(){return this._maxZoom}set maxZoom(CA){this._maxZoom!==CA&&(this._maxZoom=CA,this.zoom=Math.min(this.zoom,CA))}get minPitch(){return this._minPitch}set minPitch(DA){this._minPitch!==DA&&(this._minPitch=DA,this.pitch=Math.max(this.pitch,DA))}get maxPitch(){return this._maxPitch}set maxPitch(EA){this._maxPitch!==EA&&(this._maxPitch=EA,this.pitch=Math.min(this.pitch,EA))}get renderWorldCopies(){return this._renderWorldCopies&& !0===this.projection.supportsWorldCopies}set renderWorldCopies(FA){void 0===FA?FA=!0:null===FA&&(FA=!1),this._renderWorldCopies=FA}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const GA=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(GA))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.pointGeometry(this.width,this.height)}get bearing(){return a.wrap(this.rotation,-180,180)}set bearing(HA){this.rotation=HA}get rotation(){return-this.angle/Math.PI*180}set rotation(IA){var JA,KA,LA,MA,NA,OA,PA,QA,RA,SA;const TA=-IA*Math.PI/180;this.angle!==TA&&(this._unmodified=!1,this.angle=TA,this._calcMatrices(),JA=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(JA[1]=0,JA[2]=0),JA[0]=1,JA[3]=1,this.rotationMatrix=JA,KA=this.rotationMatrix,LA=this.rotationMatrix,MA=this.angle,NA=LA[0],OA=LA[1],PA=LA[2],QA=LA[3],RA=Math.sin(MA),SA=Math.cos(MA),KA[0]=NA*SA+PA*RA,KA[1]=OA*SA+QA*RA,KA[2]=-(NA*RA)+PA*SA,KA[3]=-(OA*RA)+QA*SA)}get pitch(){return this._pitch/Math.PI*180}set pitch(UA){const VA=a.clamp(UA,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==VA&&(this._unmodified=!1,this._pitch=VA,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(WA){WA=Math.max(.01,Math.min(60,WA)),this._fov!==WA&&(this._unmodified=!1,this._fov=WA/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(XA){this._averageElevation=XA,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(YA){const ZA=Math.min(Math.max(YA,this.minZoom),this.maxZoom);this._zoom!==ZA&&(this._unmodified=!1,this._setZoom(ZA),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom($A){this._zoom=$A,this.scale=this.zoomScale($A),this.tileZoom=Math.floor($A),this.zoomFraction=$A-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const _A=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return -1===_A?(this._cameraZoom=null,!1):(this._centerAltitude=_A,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const aB=this._elevation,bB=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],cB=this.horizonLineFromTop();let dB=0,eB=0;for(let fB=0;fBYB.maxzoom&&(ZB=YB.maxzoom);const bC=this.locationCoordinate(this.center),cC=1<{const c=1/4e4,d=new a.MercatorCoordinate(b.x+c,b.y,b.z),e=new a.MercatorCoordinate(b.x,b.y+c,b.z),f=b.toLngLat(),g=d.toLngLat(),h=e.toLngLat(),i=this.locationCoordinate(f),j=this.locationCoordinate(g),k=this.locationCoordinate(h),l=Math.hypot(j.x-i.x,j.y-i.y),m=Math.hypot(k.x-i.x,k.y-i.y);return Math.sqrt(l*m)*nC/c},pC=b=>{const c=lC,d=mC;return{aabb:a.tileAABB(this,cC,0,0,0,b,d,c,this.projection),zoom:0,x:0,y:0,minZ:d,maxZ:c,wrap:b,fullyVisible:!1}},qC=[];let rC=[];const sC=ZB,tC=YB.reparseOverscaled?$B:ZB,uC=a=>a*a,vC=uC((hC-this._centerAltitude)*gC),wC=a=>{if(!this._elevation||!a.tileID||!aC)return;const b=this._elevation.getMinMaxForTile(a.tileID),c=a.aabb;b?(c.min[2]=b.min,c.max[2]=b.max,c.center[2]=(c.min[2]+c.max[2])/2):(a.shouldSplit=xC(a),a.shouldSplit||(c.min[2]=c.max[2]=c.center[2]=this._centerAltitude))},xC=b=>{if(b.zoom.85?1:h}const i=c*c+d*d+e;return i{if(b*uC(.707)0;){const zC=qC.pop(),AC=zC.x,BC=zC.y;let CC=zC.fullyVisible;if(!CC){const DC=zC.aabb.intersects(eC);if(0===DC)continue;CC=2===DC}if(zC.zoom!==sC&&xC(zC))for(let EC=0;EC<4;EC++){const FC=(AC<<1)+EC%2,GC=(BC<<1)+(EC>>1),HC={aabb:aC?zC.aabb.quadrant(EC):a.tileAABB(this,cC,zC.zoom+1,FC,GC,zC.wrap,zC.minZ,zC.maxZ,this.projection),zoom:zC.zoom+1,x:FC,y:GC,wrap:zC.wrap,fullyVisible:CC,tileID:void 0,shouldSplit:void 0,minZ:zC.minZ,maxZ:zC.maxZ};_B&&(HC.tileID=new a.OverscaledTileID(zC.zoom+1===sC?tC:zC.zoom+1,zC.wrap,zC.zoom+1,FC,GC),wC(HC)),qC.push(HC)}else{const IC=zC.zoom===sC?tC:zC.zoom;if(YB.minzoom&&YB.minzoom>IC)continue;const JC=dC[0]-(.5+AC+(zC.wrap<{const c=[0,0,0,1],d=[a.EXTENT,a.EXTENT,0,1],e=this.calculateFogTileMatrix(b.tileID.toUnwrapped());a.transformMat4$1(c,c,e),a.transformMat4$1(d,d,e);const f=a.getAABBPointSquareDist(c,d);if(0===f)return!0;let g=!1;const h=this._elevation;if(h&&f>MC&&0!==NC){const i=this.calculateProjMatrix(b.tileID.toUnwrapped());let j;YB.isTerrainDEM||(j=h.getMinMaxForTile(b.tileID)),j||(j={min:mC,max:lC});const k=a.furthestTileCorner(this.rotation),l=[k[0]*a.EXTENT,k[1]*a.EXTENT,j.max];a.transformMat4(l,l,i),g=(1-l[1])*this.height*.5a.distanceSq-b.distanceSq).map(a=>a.tileID)}resize(OC,PC){this.width=OC,this.height=PC,this.pixelsToGLUnits=[2/OC,-2/PC],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(QC){return Math.pow(2,QC)}scaleZoom(RC){return Math.log(RC)/Math.LN2}project(SC){const TC=a.clamp(SC.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),UC=this.projection.project(SC.lng,TC);return new a.pointGeometry(UC.x*this.worldSize,UC.y*this.worldSize)}unproject(VC){return this.projection.unproject(VC.x/this.worldSize,VC.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(WC,XC){const YC=this.pointCoordinate(XC),ZC=this.pointCoordinate(this.centerPoint),$C=this.locationCoordinate(WC);this.setLocation(new a.MercatorCoordinate($C.x-(YC.x-ZC.x),$C.y-(YC.y-ZC.y)))}setLocation(_C){this.center=this.coordinateLocation(_C),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(aD){return this.projection.locationPoint(this,aD)}locationPoint3D(bD){return this._coordinatePoint(this.locationCoordinate(bD),!0)}pointLocation(cD){return this.coordinateLocation(this.pointCoordinate(cD))}pointLocation3D(dD){return this.coordinateLocation(this.pointCoordinate3D(dD))}locationCoordinate(eD,fD){const gD=fD?a.mercatorZfromAltitude(fD,eD.lat):void 0,hD=this.projection.project(eD.lng,eD.lat);return new a.MercatorCoordinate(hD.x,hD.y,gD)}coordinateLocation(iD){return this.projection.unproject(iD.x,iD.y)}pointRayIntersection(jD,kD){const lD=null!=kD?kD:this._centerAltitude,mD=[jD.x,jD.y,0,1],nD=[jD.x,jD.y,1,1];a.transformMat4$1(mD,mD,this.pixelMatrixInverse),a.transformMat4$1(nD,nD,this.pixelMatrixInverse);const oD=nD[3];a.scale$1(mD,mD,1/mD[3]),a.scale$1(nD,nD,1/oD);const pD=mD[2],qD=nD[2];return{p0:mD,p1:nD,t:pD===qD?0:(lD-pD)/(qD-pD)}}screenPointToMercatorRay(rD){const sD=[rD.x,rD.y,0,1],tD=[rD.x,rD.y,1,1];return a.transformMat4$1(sD,sD,this.pixelMatrixInverse),a.transformMat4$1(tD,tD,this.pixelMatrixInverse),a.scale$1(sD,sD,1/sD[3]),a.scale$1(tD,tD,1/tD[3]),sD[2]=a.mercatorZfromAltitude(sD[2],this._center.lat)*this.worldSize,tD[2]=a.mercatorZfromAltitude(tD[2],this._center.lat)*this.worldSize,a.scale$1(sD,sD,1/this.worldSize),a.scale$1(tD,tD,1/this.worldSize),new a.Ray([sD[0],sD[1],sD[2]],a.normalize([],a.sub([],tD,sD)))}rayIntersectionCoordinate(uD){const{p0:vD,p1:wD,t:xD}=uD,yD=a.mercatorZfromAltitude(vD[2],this._center.lat),zD=a.mercatorZfromAltitude(wD[2],this._center.lat);return new a.MercatorCoordinate(a.number(vD[0],wD[0],xD)/this.worldSize,a.number(vD[1],wD[1],xD)/this.worldSize,a.number(yD,zD,xD))}pointCoordinate(AD,BD=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(AD.x,AD.y,BD)}pointCoordinate3D(CD){if(!this.elevation)return this.pointCoordinate(CD);const DD=this.elevation;let ED=this.elevation.pointCoordinate(CD);if(ED)return new a.MercatorCoordinate(ED[0],ED[1],ED[2]);let FD=0,GD=this.horizonLineFromTop();if(CD.y>GD)return this.pointCoordinate(CD);const HD=.02*GD,ID=CD.clone();for(let JD=0;JD<10&&GD-FD>HD;JD++){ID.y=a.number(FD,GD,.66);const KD=DD.pointCoordinate(ID);KD?(GD=ID.y,ED=KD):FD=ID.y}return ED?new a.MercatorCoordinate(ED[0],ED[1],ED[2]):this.pointCoordinate(CD)}isPointAboveHorizon(LD){if(this.elevation)return!this.elevation.pointCoordinate(LD);{const MD=this.horizonLineFromTop();return LD.y0?new a.pointGeometry(QD[0]/QD[3],QD[1]/QD[3]):new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(RD,SD){var TD,UD,TD,UD,TD,UD,TD,UD;const VD=new a.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),WD=new a.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),XD=new a.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),YD=new a.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let ZD=this.pointCoordinate(VD,RD),$D=this.pointCoordinate(WD,RD);const _D=this.pointCoordinate(XD,SD),aE=this.pointCoordinate(YD,SD);return ZD.y>1&&$D.y>=0?ZD=new a.MercatorCoordinate((1-aE.y)/(TD=aE,((UD=ZD).y-TD.y)/(UD.x-TD.x))+aE.x,1):ZD.y<0&&$D.y<=1&&(ZD=new a.MercatorCoordinate(-aE.y/(TD=aE,((UD=ZD).y-TD.y)/(UD.x-TD.x))+aE.x,0)),$D.y>1&&ZD.y>=0?$D=new a.MercatorCoordinate((1-_D.y)/(TD=_D,((UD=$D).y-TD.y)/(UD.x-TD.x))+_D.x,1):$D.y<0&&ZD.y<=1&&($D=new a.MercatorCoordinate(-_D.y/(TD=_D,((UD=$D).y-TD.y)/(UD.x-TD.x))+_D.x,0)),(new a.LngLatBounds).extend(this.coordinateLocation(ZD)).extend(this.coordinateLocation($D)).extend(this.coordinateLocation(aE)).extend(this.coordinateLocation(_D))}_getBounds3D(){const bE=this.elevation;if(!bE.visibleDemTiles.length)return this._getBounds(0,0);const cE=bE.visibleDemTiles.reduce((a,b)=>{if(b.dem){const c=b.dem.tree;a.min=Math.min(a.min,c.minimums[0]),a.max=Math.max(a.max,c.maximums[0])}return a},{min:Number.MAX_VALUE,max:0});return this._getBounds(cE.min*bE.exaggeration(),cE.max*bE.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(dE=!0){const eE=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,fE=this.height/2-eE*(1-this._horizonShift);return dE?Math.max(0,fE):fE}getMaxBounds(){return this.maxBounds}setMaxBounds(gE){this.maxBounds=gE,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,gE&&(this.minLat=gE.getSouth(),this.maxLat=gE.getNorth(),this.minLng=gE.getWest(),this.maxLng=gE.getEast(),this.maxLngjF&&(fF=jF-hF),jF-iFlF&&(eF=lF-gF),lF-kF.5?GF-1:GF,HF>.5?HF-1:HF,0]),this.alignedProjMatrix=IF,tF=a.create(),a.scale(tF,tF,[this.width/2,-this.height/2,1]),a.translate(tF,tF,[1,-1,0]),this.labelPlaneMatrix=tF,tF=a.create(),a.scale(tF,tF,[1,-1,1]),a.translate(tF,tF,[-1,-1,0]),a.scale(tF,tF,[2/this.width,2/this.height,1]),this.glCoordMatrix=tF,this.pixelMatrix=a.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},tF=a.invert(new Float64Array(16),this.pixelMatrix),!tF)throw new Error("failed to invert matrix");this.pixelMatrixInverse=tF,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const JF=this.cameraWorldSize,KF=this.cameraPixelsPerMeter,LF=this._camera.position,MF=1/this.height,NF=[JF,JF,KF];a.scale$2(NF,NF,MF),a.scale$2(LF,LF,-1),a.multiply$2(LF,LF,NF);const OF=a.create();a.translate(OF,OF,LF),a.scale(OF,OF,NF),this.mercatorFogMatrix=OF,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(JF,KF,MF)}_computeCameraPosition(PF){const QF=(PF=PF||this.pixelsPerMeter)/this.pixelsPerMeter,RF=this._camera.forward(),SF=this.point,TF=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*QF-PF/this.worldSize*this._centerAltitude;return[SF.x/this.worldSize-RF[0]*TF,SF.y/this.worldSize-RF[1]*TF,PF/this.worldSize*this._centerAltitude-RF[2]*TF]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(UF){const VF=this._maxCameraBoundsDistance()*Math.cos(this._pitch),WF=UF[2];let XF=1;WF>0&&(XF=Math.min((VF-this._camera.position[2])/WF,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,UF,XF),this._updateStateFromCamera()}_updateStateFromCamera(){const YF=this._camera.position,ZF=this._camera.forward(),{pitch:$F,bearing:_F}=this._camera.getPitchBearing(),aG=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,bG=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),cG=Math.max((YF[2]-aG)/Math.cos($F),bG),dG=this._zoomFromMercatorZ(cG);a.scaleAndAdd(YF,YF,ZF,cG),this._pitch=a.clamp($F,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(_F,-Math.PI,Math.PI),this._setZoom(a.clamp(dG,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new a.MercatorCoordinate(YF[0],YF[1],YF[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(eG){return Math.pow(2,eG)*this.tileSize}_mercatorZfromZoom(fG){return this.cameraToCenterDistance/this._worldSizeFromZoom(fG)}_minimumHeightOverTerrain(){const gG=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(gG)}_zoomFromMercatorZ(hG){return this.scaleZoom(this.cameraToCenterDistance/(hG*this.tileSize))}_terrainEnabled(){return!(!this._elevation|| !this.projection.supportsTerrain&&(a.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(iG,jG){const kG=Math.min(iG.x,jG.x),lG=Math.max(iG.x,jG.x),mG=Math.min(iG.y,jG.y),nG=Math.max(iG.y,jG.y);if(mGqG||tG.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.pointGeometry(0,0),new a.pointGeometry(this.width,this.height))}zoomDeltaToMovement(uG,vG){const wG=a.length(a.sub([],this._camera.position,uG)),xG=this._zoomFromMercatorZ(wG)+vG;return wG-this._mercatorZfromZoom(xG)}getCameraPoint(){const yG=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.pointGeometry(0,yG))}}function zG(a,b){let c=!1,d=null;const e=()=>{d=null,c&&(a(),d=setTimeout(e,b),c=!1)};return()=>(c=!0,d||e(),d)}const AG={linearity:.3,easing:a.bezier(0,0,.3,1)},BG=a.extend({deceleration:2500,maxSpeed:1400},AG),CG=a.extend({deceleration:20,maxSpeed:1400},AG),DG=a.extend({deceleration:1e3,maxSpeed:360},AG),EG=a.extend({deceleration:1e3,maxSpeed:90},AG);function FG(a,b){(!a.duration||a.durationQG.unproject(a)),VG=TG.reduce((a,b,c,d)=>a.add(b.div(d.length)),new a.pointGeometry(0,0));super(PG,{points:TG,point:VG,lngLats:UG,lngLat:QG.unproject(VG),originalEvent:RG}),this._defaultPrevented=!1}}class WG extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(XG,YG,ZG){super(XG,{originalEvent:ZG}),this._defaultPrevented=!1}}class $G{constructor(_G,aH){this._map=_G,this._clickTolerance=aH.clickTolerance}reset(){delete this._mousedownPos}wheel(bH){return this._firePreventable(new WG(bH.type,this._map,bH))}mousedown(cH,dH){return this._mousedownPos=dH,this._firePreventable(new HG(cH.type,this._map,cH))}mouseup(eH){this._map.fire(new HG(eH.type,this._map,eH))}preclick(fH){const gH=a.extend({},fH);gH.type="preclick",this._map.fire(new HG(gH.type,this._map,gH))}click(hH,iH){this._mousedownPos&&this._mousedownPos.dist(iH)>=this._clickTolerance||(this.preclick(hH),this._map.fire(new HG(hH.type,this._map,hH)))}dblclick(jH){return this._firePreventable(new HG(jH.type,this._map,jH))}mouseover(kH){this._map.fire(new HG(kH.type,this._map,kH))}mouseout(lH){this._map.fire(new HG(lH.type,this._map,lH))}touchstart(mH){return this._firePreventable(new OG(mH.type,this._map,mH))}touchmove(nH){this._map.fire(new OG(nH.type,this._map,nH))}touchend(oH){this._map.fire(new OG(oH.type,this._map,oH))}touchcancel(pH){this._map.fire(new OG(pH.type,this._map,pH))}_firePreventable(qH){if(this._map.fire(qH),qH.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class rH{constructor(sH){this._map=sH}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(tH){this._map.fire(new HG(tH.type,this._map,tH))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new HG("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(uH){this._delayContextMenu?this._contextMenuEvent=uH:this._map.fire(new HG(uH.type,this._map,uH)),this._map.listens("contextmenu")&&uH.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class vH{constructor(wH,xH){this._map=wH,this._el=wH.getCanvasContainer(),this._container=wH.getContainer(),this._clickTolerance=xH.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(yH,zH){this.isEnabled()&&yH.shiftKey&&0===yH.button&&(g.disableDrag(),this._startPos=this._lastPos=zH,this._active=!0)}mousemoveWindow(AH,BH){if(!this._active)return;const CH=BH;if(this._lastPos.equals(CH)|| !this._box&&CH.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${EH}px,${GH}px)`,this._box.style.width=FH-EH+"px",this._box.style.height=HH-GH+"px")})}mouseupWindow(IH,JH){if(!this._active)return;if(0!==IH.button)return;const KH=this._startPos,LH=JH;if(this.reset(),g.suppressClick(),KH.x!==LH.x||KH.y!==LH.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:IH})),{cameraAnimation:a=>a.fitScreenCoordinates(KH,LH,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",IH)}keydown(MH){this._active&&27===MH.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",MH))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),g.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(NH,OH){return this._map.fire(new a.Event(NH,{originalEvent:OH}))}}function PH(a,b){const c={};for(let d=0;dthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=c.timeStamp),e.length===this.numTouches&&(this.centroid=(function(b){const c=new a.pointGeometry(0,0);for(const d of b)c._add(d);return c.div(b.length)})(d),this.touches=PH(e,d)))}touchmove(f,g,h){if(this.aborted||!this.centroid)return;const i=PH(h,g);for(const j in this.touches){const k=this.touches[j],l=i[j];(!l||l.dist(k)>30)&&(this.aborted=!0)}}touchend(m,n,o){if((!this.centroid||m.timeStamp-this.startTime>500)&&(this.aborted=!0),0===o.length){const p=!this.aborted&&this.centroid;if(this.reset(),p)return p}}}(RH),this.numTaps=RH.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(SH,TH,UH){this.singleTap.touchstart(SH,TH,UH)}touchmove(VH,WH,XH){this.singleTap.touchmove(VH,WH,XH)}touchend(YH,ZH,$H){const _H=this.singleTap.touchend(YH,ZH,$H);if(_H){const aI=YH.timeStamp-this.lastTime<500,bI=!this.lastTap||30>this.lastTap.dist(_H);if(aI&&bI||this.reset(),this.count++,this.lastTime=YH.timeStamp,this.lastTap=_H,this.count===this.numTaps)return this.reset(),_H}}}class cI{constructor(){this._zoomIn=new QH({numTouches:1,numTaps:2}),this._zoomOut=new QH({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(dI,eI,fI){this._zoomIn.touchstart(dI,eI,fI),this._zoomOut.touchstart(dI,eI,fI)}touchmove(gI,hI,iI){this._zoomIn.touchmove(gI,hI,iI),this._zoomOut.touchmove(gI,hI,iI)}touchend(jI,kI,lI){const mI=this._zoomIn.touchend(jI,kI,lI),nI=this._zoomOut.touchend(jI,kI,lI);return mI?(this._active=!0,jI.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:a=>a.easeTo({duration:300,zoom:a.getZoom()+1,around:a.unproject(mI)},{originalEvent:jI})}):nI?(this._active=!0,jI.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:a=>a.easeTo({duration:300,zoom:a.getZoom()-1,around:a.unproject(nI)},{originalEvent:jI})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const oI={0:1,2:2};class pI{constructor(qI){this.reset(),this._clickTolerance=qI.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(rI,sI){return!1}_move(tI,uI){return{}}mousedown(vI,wI){if(this._lastPoint)return;const xI=g.mouseButton(vI);this._correctButton(vI,xI)&&(this._lastPoint=wI,this._eventButton=xI)}mousemoveWindow(yI,zI){const AI=this._lastPoint;if(AI){if(yI.preventDefault(),(function(a,b){const c=oI[b];return void 0===a.buttons||(a.buttons&c)!==c})(yI,this._eventButton))this.reset();else if(this._moved||!(zI.dist(AI)0&&(this._active=!0);const kJ=PH(jJ,iJ),lJ=new a.pointGeometry(0,0),mJ=new a.pointGeometry(0,0);let nJ=0;for(const oJ in kJ){const pJ=kJ[oJ],qJ=this._touches[oJ];qJ&&(lJ._add(pJ),mJ._add(pJ.sub(qJ)),nJ++,kJ[oJ]=pJ)}if(this._touches=kJ,nJ{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class sJ{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(tJ){}_move(uJ,vJ,wJ){return{}}touchstart(xJ,yJ,zJ){this._firstTwoTouches||zJ.length<2||(this._firstTwoTouches=[zJ[0].identifier,zJ[1].identifier],this._start([yJ[0],yJ[1]]))}touchmove(AJ,BJ,CJ){if(!this._firstTwoTouches)return;AJ.preventDefault();const[DJ,EJ]=this._firstTwoTouches,FJ=QJ(CJ,BJ,DJ),GJ=QJ(CJ,BJ,EJ);if(!FJ||!GJ)return;const HJ=this._aroundCenter?null:FJ.add(GJ).div(2);return this._move([FJ,GJ],HJ,AJ)}touchend(IJ,JJ,KJ){if(!this._firstTwoTouches)return;const[LJ,MJ]=this._firstTwoTouches,NJ=QJ(KJ,JJ,LJ),OJ=QJ(KJ,JJ,MJ);NJ&&OJ||(this._active&&g.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(PJ){this._enabled=!0,this._aroundCenter=!!PJ&&"center"===PJ.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function QJ(a,b,c){for(let d=0;dMath.abs(RJ(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:RJ(this._distance,WJ),pinchAround:VJ}}}function XJ(a,b){return 180*a.angleWith(b)/Math.PI}class YJ extends sJ{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(ZJ){this._startVector=this._vector=ZJ[0].sub(ZJ[1]),this._minDiameter=ZJ[0].dist(ZJ[1])}_move($J,_J){const aK=this._vector;if(this._vector=$J[0].sub($J[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:XJ(this._vector,aK),pinchAround:_J}}_isBelowThreshold(bK){this._minDiameter=Math.min(this._minDiameter,bK.mag());const cK=25/(Math.PI*this._minDiameter)*360,dK=XJ(bK,this._startVector);return Math.abs(dK)Math.abs(a.x)}class fK extends sJ{constructor(gK){super(),this._map=gK}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(hK){this._lastPoints=hK,eK(hK[0].sub(hK[1]))&&(this._valid=!1)}_move(iK,jK,kK){const lK=iK[0].sub(this._lastPoints[0]),mK=iK[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&kK.touches.length<3)&&(this._valid=this.gestureBeginsVertically(lK,mK,kK.timeStamp),this._valid))return this._lastPoints=iK,this._active=!0,{pitchDelta:-((lK.y+mK.y)/2*.5)}}gestureBeginsVertically(nK,oK,pK){if(void 0!==this._valid)return this._valid;const qK=nK.mag()>=2,rK=oK.mag()>=2;if(!qK&&!rK)return;if(!qK||!rK)return void 0===this._firstMove&&(this._firstMove=pK),pK-this._firstMove<100&&void 0;const sK=nK.y>0==oK.y>0;return eK(nK)&&eK(oK)&&sK}}class tK{constructor(){this._panStep=100,this._bearingStep=15,this._pitchStep=10,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(uK){if(uK.altKey||uK.ctrlKey||uK.metaKey)return;let vK=0,wK=0,xK=0,yK=0,zK=0;switch(uK.keyCode){case 61:case 107:case 171:case 187:vK=1;break;case 189:case 109:case 173:vK=-1;break;case 37:uK.shiftKey?wK=-1:(uK.preventDefault(),yK=-1);break;case 39:uK.shiftKey?wK=1:(uK.preventDefault(),yK=1);break;case 38:uK.shiftKey?xK=1:(uK.preventDefault(),zK=-1);break;case 40:uK.shiftKey?xK=-1:(uK.preventDefault(),zK=1);break;default:return}return this._rotationDisabled&&(wK=0,xK=0),{cameraAnimation:a=>{const b=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:AK,zoom:vK?Math.round(b)+vK*(uK.shiftKey?2:1):b,bearing:a.getBearing()+wK*this._bearingStep,pitch:a.getPitch()+xK*this._pitchStep,offset:[-yK*this._panStep,-zK*this._panStep],center:a.getCenter()},{originalEvent:uK})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function AK(a){return a*(2-a)}const BK=4.000244140625;class CK{constructor(DK,EK){this._map=DK,this._el=DK.getCanvasContainer(),this._handler=EK,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(FK){this._defaultZoomRate=FK}setWheelZoomRate(GK){this._wheelZoomRate=GK}isEnabled(){return!!this._enabled}isActive(){return!!this._active|| void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(HK){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!HK&&"center"===HK.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(IK){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(IK.ctrlKey||IK.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let JK=IK.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*IK.deltaY:IK.deltaY;const KK=a.exported.now(),LK=KK-(this._lastWheelEventTime||0);this._lastWheelEventTime=KK,0!==JK&&JK%BK==0?this._type="wheel":0!==JK&&4>Math.abs(JK)?this._type="trackpad":LK>400?(this._type=null,this._lastValue=JK,this._timeout=setTimeout(this._onTimeout,40,IK)):this._type||(this._type=200>Math.abs(LK*JK)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,JK+=this._lastValue)),IK.shiftKey&&JK&&(JK/=4),this._type&&(this._lastWheelEvent=IK,this._delta-=JK,this._active||this._start(IK)),IK.preventDefault()}_onTimeout(MK){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(MK)}_start(NK){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const OK=g.mousePos(this._el,NK);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:OK,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const PK=this._map.transform,QK=()=>PK._terrainEnabled()&&this._aroundCoord?PK.computeZoomRelativeTo(this._aroundCoord):PK.zoom;if(0!==this._delta){const RK="wheel"===this._type&&Math.abs(this._delta)>BK?this._wheelZoomRate:this._defaultZoomRate;let SK=2/(1+Math.exp(-Math.abs(this._delta*RK)));this._delta<0&&0!==SK&&(SK=1/SK);const TK=QK(),UK=Math.pow(2,TK),VK="number"==typeof this._targetZoom?PK.zoomScale(this._targetZoom):UK;this._targetZoom=Math.min(PK.maxZoom,Math.max(PK.minZoom,PK.scaleZoom(VK*SK))),"wheel"===this._type&&(this._startZoom=QK(),this._easing=this._smoothOutEasing(200)),this._delta=0}const WK="number"==typeof this._targetZoom?this._targetZoom:QK(),XK=this._startZoom,YK=this._easing;let ZK,$K=!1;if("wheel"===this._type&&XK&&YK){const _K=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),aL=YK(_K);ZK=a.number(XK,WK,aL),_K<1?this._frameId||(this._frameId=!0):$K=!0}else ZK=WK,$K=!0;return this._active=!0,$K&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!$K,zoomDelta:ZK-QK(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(bL){let cL=a.ease;if(this._prevEase){const dL=this._prevEase,eL=(a.exported.now()-dL.start)/dL.duration,fL=dL.easing(eL+.01)-dL.easing(eL),gL=.27/Math.sqrt(fL*fL+1e-4)*.01,hL=Math.sqrt(.0729-gL*gL);cL=a.bezier(gL,hL,.25,1)}return this._prevEase={start:a.exported.now(),duration:bL,easing:cL},cL}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=g.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(a.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!a.window.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class iL{constructor(jL,kL){this._clickZoom=jL,this._tapZoom=kL}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class lL{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(mL,nL){return mL.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:a.getZoom()+(mL.shiftKey?-1:1),around:a.unproject(nL)},{originalEvent:mL})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class oL{constructor(){this._tap=new QH({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(pL,qL,rL){this._swipePoint||(this._tapTime&&pL.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?rL.length>0&&(this._swipePoint=qL[0],this._swipeTouch=rL[0].identifier):this._tap.touchstart(pL,qL,rL))}touchmove(sL,tL,uL){if(this._tapTime){if(this._swipePoint){if(uL[0].identifier!==this._swipeTouch)return;const vL=tL[0],wL=vL.y-this._swipePoint.y;return this._swipePoint=vL,sL.preventDefault(),this._active=!0,{zoomDelta:wL/128}}}else this._tap.touchmove(sL,tL,uL)}touchend(xL,yL,zL){this._tapTime?this._swipePoint&&0===zL.length&&this.reset():this._tap.touchend(xL,yL,zL)&&(this._tapTime=xL.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class AL{constructor(BL,CL,DL){this._el=BL,this._mousePan=CL,this._touchPan=DL}enable(EL){this._inertiaOptions=EL||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class FL{constructor(GL,HL,IL){this._pitchWithRotate=GL.pitchWithRotate,this._mouseRotate=HL,this._mousePitch=IL}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class JL{constructor(KL,LL,ML,NL){this._el=KL,this._touchZoom=LL,this._touchRotate=ML,this._tapDragZoom=NL,this._rotationDisabled=!1,this._enabled=!0}enable(OL){this._touchZoom.enable(OL),this._rotationDisabled||this._touchRotate.enable(OL),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const PL=a=>a.zoom||a.drag||a.pitch||a.rotate;class QL extends a.Event{}function RL(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}const SL="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class TL extends a.Evented{constructor(UL,VL){super(),this._moving=!1,this._zooming=!1,this.transform=UL,this._bearingSnap=VL.bearingSnap,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(WL,XL){return this.jumpTo({center:WL},XL)}panBy(YL,ZL,$L){return YL=a.pointGeometry.convert(YL).mult(-1),this.panTo(this.transform.center,a.extend({offset:YL},ZL),$L)}panTo(_L,aM,bM){return this.easeTo(a.extend({center:_L},aM),bM)}getZoom(){return this.transform.zoom}setZoom(cM,dM){return this.jumpTo({zoom:cM},dM),this}zoomTo(eM,fM,gM){return this.easeTo(a.extend({zoom:eM},fM),gM)}zoomIn(hM,iM){return this.zoomTo(this.getZoom()+1,hM,iM),this}zoomOut(jM,kM){return this.zoomTo(this.getZoom()-1,jM,kM),this}getBearing(){return this.transform.bearing}setBearing(lM,mM){return this.jumpTo({bearing:lM},mM),this}getPadding(){return this.transform.padding}setPadding(nM,oM){return this.jumpTo({padding:nM},oM),this}rotateTo(pM,qM,rM){return this.easeTo(a.extend({bearing:pM},qM),rM)}resetNorth(sM,tM){return this.rotateTo(0,a.extend({duration:1e3},sM),tM),this}resetNorthPitch(uM,vM){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},uM),vM),this}snapToNorth(wM,xM){return Math.abs(this.getBearing())c=>{if(TO&&(b.zoom=a.number(CO,GO,c)),UO&&(b.bearing=a.number(DO,HO,c)),VO&&(b.pitch=a.number(EO,IO,c)),WO&&(b.interpolatePadding(FO,JO,c),LO=b.centerPoint.add(KO)),RO)b.setLocationAtPoint(RO,SO);else{const d=b.zoomScale(b.zoom-CO),e=GO>CO?Math.min(2,QO):Math.max(.5,QO),f=Math.pow(e,1-c),g=b.unproject(OO.add(PO.mult(c*f)).mult(d));b.setLocationAtPoint(b.renderWorldCopies?g.wrap():g,LO)}return zO.preloadOnly||this._fireMoveEvents(AO),b};if(zO.preloadOnly){const YO=this._emulate(XO,zO.duration,BO);return this._preloadTiles(YO),this}const ZO={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=TO,this._rotating=UO,this._pitching=VO,this._padding=WO,this._easeId=zO.easeId,this._prepareEase(AO,zO.noMoveStart,ZO),this._ease(XO(BO),a=>{BO.recenterOnTerrain(),this._afterEase(AO,a)},zO),this}_prepareEase($O,_O,aP={}){this._moving=!0,this.transform.cameraElevationReference="sea",_O||aP.moving||this.fire(new a.Event("movestart",$O)),this._zooming&&!aP.zooming&&this.fire(new a.Event("zoomstart",$O)),this._rotating&&!aP.rotating&&this.fire(new a.Event("rotatestart",$O)),this._pitching&&!aP.pitching&&this.fire(new a.Event("pitchstart",$O))}_fireMoveEvents(bP){this.fire(new a.Event("move",bP)),this._zooming&&this.fire(new a.Event("zoom",bP)),this._rotating&&this.fire(new a.Event("rotate",bP)),this._pitching&&this.fire(new a.Event("pitch",bP))}_afterEase(cP,dP){if(this._easeId&&dP&&this._easeId===dP)return;delete this._easeId,this.transform.cameraElevationReference="ground";const eP=this._zooming,fP=this._rotating,gP=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,eP&&this.fire(new a.Event("zoomend",cP)),fP&&this.fire(new a.Event("rotateend",cP)),gP&&this.fire(new a.Event("pitchend",cP)),this.fire(new a.Event("moveend",cP))}flyTo(hP,iP){if(!hP.essential&&a.exported.prefersReducedMotion){const jP=a.pick(hP,["center","zoom","bearing","pitch","around"]);return this.jumpTo(jP,iP)}this.stop(),hP=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},hP);const kP=this.transform,lP=this.getZoom(),mP=this.getBearing(),nP=this.getPitch(),oP=this.getPadding(),pP="zoom"in hP?a.clamp(+hP.zoom,kP.minZoom,kP.maxZoom):lP,qP="bearing"in hP?this._normalizeBearing(hP.bearing,mP):mP,rP="pitch"in hP?+hP.pitch:nP,sP="padding"in hP?hP.padding:kP.padding,tP=kP.zoomScale(pP-lP),uP=a.pointGeometry.convert(hP.offset);let vP=kP.centerPoint.add(uP);const wP=kP.pointLocation(vP),xP=a.LngLat.convert(hP.center||wP);this._normalizeCenter(xP);const yP=kP.project(wP),zP=kP.project(xP).sub(yP);let AP=hP.curve;const BP=Math.max(kP.width,kP.height),CP=BP/tP,DP=zP.mag();if("minZoom"in hP){const EP=a.clamp(Math.min(hP.minZoom,lP,pP),kP.minZoom,kP.maxZoom),FP=BP/kP.zoomScale(EP-lP);AP=Math.sqrt(FP/DP*2)}const GP=AP*AP;function HP(a){const b=(CP*CP-BP*BP+(a?-1:1)*GP*GP*DP*DP)/(2*(a?CP:BP)*GP*DP);return Math.log(Math.sqrt(b*b+1)-b)}function IP(a){return(Math.exp(a)-Math.exp(-a))/2}function JP(a){return(Math.exp(a)+Math.exp(-a))/2}const KP=HP(0);let LP=function(a){return JP(KP)/JP(KP+AP*a)},MP=function(a){var b;return BP*((JP(KP)*(IP(b=KP+AP*a)/JP(b))-IP(KP))/GP)/DP},NP=(HP(1)-KP)/AP;if(1e-6>Math.abs(DP)||!isFinite(NP)){if(1e-6>Math.abs(BP-CP))return this.easeTo(hP,iP);const OP=CPhP.maxDuration&&(hP.duration=0);const PP=mP!==qP,QP=rP!==nP,RP=!kP.isPaddingEqual(sP),SP=b=>c=>{const d=c*NP,e=1/LP(d);b.zoom=1===c?pP:lP+b.scaleZoom(e),PP&&(b.bearing=a.number(mP,qP,c)),QP&&(b.pitch=a.number(nP,rP,c)),RP&&(b.interpolatePadding(oP,sP,c),vP=b.centerPoint.add(uP));const f=1===c?xP:b.unproject(yP.add(zP.mult(MP(d))).mult(e));return b.setLocationAtPoint(b.renderWorldCopies?f.wrap():f,vP),b._updateCenterElevation(),hP.preloadOnly||this._fireMoveEvents(iP),b};if(hP.preloadOnly){const TP=this._emulate(SP,hP.duration,kP);return this._preloadTiles(TP),this}return this._zooming=!0,this._rotating=PP,this._pitching=QP,this._padding=RP,this._prepareEase(iP,!1),this._ease(SP(kP),()=>this._afterEase(iP),hP),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(UP,VP){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const WP=this._onEaseEnd;delete this._onEaseEnd,WP.call(this,VP)}if(!UP){const XP=this.handlers;XP&&XP.stop(!1)}return this}_ease(YP,ZP,$P){!1===$P.animate||0===$P.duration?(YP(1),ZP()):(this._easeStart=a.exported.now(),this._easeOptions=$P,this._onEaseFrame=YP,this._onEaseEnd=ZP,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const _P=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(_P)),_P<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(aQ,bQ){aQ=a.wrap(aQ,-180,180);const cQ=Math.abs(aQ-bQ);return Math.abs(aQ-360-bQ)180?-360:fQ< -180?360:0}_emulate(gQ,hQ,iQ){const jQ=Math.ceil(15*hQ/1e3),kQ=[],lQ=gQ(iQ.clone());for(let mQ=0;mQ<=jQ;mQ++){const nQ=lQ(mQ/jQ);kQ.push(nQ.clone())}return kQ}}class oQ{constructor(pQ={}){this.options=pQ,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(qQ){const rQ=this.options&&this.options.compact;return this._map=qQ,this._container=g.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=g.create("button","mapboxgl-ctrl-attrib-button",this._container),g.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=g.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),rQ&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===rQ&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(sQ,tQ){const uQ=this._map._getUIString(`AttributionControl.${tQ}`);sQ.setAttribute("aria-label",uQ),sQ.removeAttribute("title"),sQ.firstElementChild&&sQ.firstElementChild.setAttribute("title",uQ)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let vQ=this._editLink;vQ||(vQ=this._editLink=this._container.querySelector(".mapbox-improve-map"));const wQ=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN}];if(vQ){const xQ=wQ.reduce((a,b,c)=>(b.value&&(a+=`${b.key}=${b.value}${czQ.indexOf(EQ.attribution)&&zQ.push(EQ.attribution)}}zQ.sort((a,b)=>a.length-b.length),zQ=zQ.filter((a,b)=>{for(let c=b+1;c=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?zQ=[...this.options.customAttribution,...zQ]:zQ.unshift(this.options.customAttribution));const FQ=zQ.join(" | ");FQ!==this._attribHTML&&(this._attribHTML=FQ,zQ.length?(this._innerContainer.innerHTML=FQ,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class GQ{constructor(){a.bindAll(["_updateLogo"],this),a.bindAll(["_updateCompact"],this)}onAdd(HQ){this._map=HQ,this._container=g.create("div","mapboxgl-ctrl");const IQ=g.create("a","mapboxgl-ctrl-logo");return IQ.target="_blank",IQ.rel="noopener nofollow",IQ.href="https://www.mapbox.com/",IQ.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),IQ.setAttribute("rel","noopener nofollow"),this._container.appendChild(IQ),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(JQ){JQ&&"metadata"!==JQ.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const KQ=this._map.style._sourceCaches;if(0===Object.entries(KQ).length)return!0;for(const LQ in KQ){const MQ=KQ[LQ].getSource();if(MQ.hasOwnProperty("mapbox_logo")&&!MQ.mapbox_logo)return!1}return!0}_updateCompact(){const NQ=this._container.children;if(NQ.length){const OQ=NQ[0];this._map.getCanvasContainer().offsetWidth<250?OQ.classList.add("mapboxgl-compact"):OQ.classList.remove("mapboxgl-compact")}}}class PQ{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(QQ){const RQ=++this._id;return this._queue.push({callback:QQ,id:RQ,cancelled:!1}),RQ}remove(SQ){const TQ=this._currentlyRunning,UQ=TQ?this._queue.concat(TQ):this._queue;for(const VQ of UQ)if(VQ.id===SQ)return void(VQ.cancelled=!0)}run(WQ=0){const XQ=this._currentlyRunning=this._queue;for(const YQ of(this._queue=[],XQ))if(!YQ.cancelled&&(YQ.callback(WQ),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ZQ(b,c,d){if(b=new a.LngLat(b.lng,b.lat),c){const e=new a.LngLat(b.lng-360,b.lat),f=new a.LngLat(b.lng+360,b.lat),g=360*Math.ceil(Math.abs(b.lng-d.center.lng)/360),h=d.locationPoint(b).distSqr(c),i=c.x<0||c.y<0||c.x>d.width||c.y>d.height;d.locationPoint(e).distSqr(c)180;){const j=d.locationPoint(b);if(j.x>=0&&j.y>=0&&j.x<=d.width&&j.y<=d.height)break;b.lng>d.center.lng?b.lng-=360:b.lng+=360}return b}const $Q={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class _Q extends a.Evented{constructor(aR,bR){if(super(),(aR instanceof a.window.HTMLElement||bR)&&(aR=a.extend({element:aR},bR)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=aR&&aR.anchor||"center",this._color=aR&&aR.color||"#3FB1CE",this._scale=aR&&aR.scale||1,this._draggable=aR&&aR.draggable||!1,this._clickTolerance=aR&&aR.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=aR&&aR.rotation||0,this._rotationAlignment=aR&&aR.rotationAlignment||"auto",this._pitchAlignment=aR&&aR.pitchAlignment&&"auto"!==aR.pitchAlignment?aR.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),aR&&aR.element)this._element=aR.element,this._offset=a.pointGeometry.convert(aR&&aR.offset||[0,0]);else{this._defaultMarker=!0,this._element=g.create("div");const cR=41,dR=27,eR=g.createSVG("svg",{display:"block",height:cR*this._scale+"px",width:dR*this._scale+"px",viewBox:`0 0 ${dR} ${cR}`},this._element),fR=g.createSVG("radialGradient",{id:"shadowGradient"},g.createSVG("defs",{},eR));g.createSVG("stop",{offset:"10%","stop-opacity":.4},fR),g.createSVG("stop",{offset:"100%","stop-opacity":.05},fR),g.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},eR),g.createSVG("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},eR),g.createSVG("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},eR),g.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},eR),this._offset=a.pointGeometry.convert(aR&&aR.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",a=>{a.preventDefault()}),this._element.addEventListener("mousedown",a=>{a.preventDefault()});const gR=this._element.classList;for(const hR in $Q)gR.remove(`mapboxgl-marker-anchor-${hR}`);gR.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(iR){return iR===this._map||(this.remove(),this._map=iR,iR.getCanvasContainer().appendChild(this._element),iR.on("move",this._updateMoving),iR.on("moveend",this._update),iR.on("remove",this._clearFadeTimer),iR._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick)),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(jR){return this._lngLat=a.LngLat.convert(jR),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(kR){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),kR){if(!("offset"in kR.options)){const lR=38.1,mR=13.5,nR=Math.sqrt(Math.pow(mR,2)/2);kR.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-lR],"bottom-left":[nR,-1*(lR-mR+nR)],"bottom-right":[-nR,-1*(lR-mR+nR)],left:[mR,-1*(lR-mR)],right:[-mR,-1*(lR-mR)]}:this._offset}this._popup=kR,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(oR){const pR=oR.code,qR=oR.charCode||oR.keyCode;"Space"!==pR&&"Enter"!==pR&&32!==qR&&13!==qR||this.togglePopup()}_onMapClick(rR){const sR=rR.originalEvent.target,tR=this._element;this._popup&&(sR===tR||tR.contains(sR))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const uR=this._popup;return uR&&(uR.isOpen()?(uR.remove(),this._element.setAttribute("aria-expanded","false")):(uR.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_evaluateOpacity(){const vR=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(vR))return void this._clearFadeTimer();const wR=this._map.unproject(vR);let xR=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const yR=this._map.getFreeCameraOptions();if(yR.position){const zR=yR.position.toLngLat();xR=zR.distanceTo(wR)<.9*zR.distanceTo(this._lngLat)}}const AR=(1-this._map._queryFogOpacity(wR))*(xR?.2:1);this._element.style.opacity=`${AR}`,this._popup&&this._popup._setOpacity(`${AR}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(BR){const CR=this._map.transform;return!!BR&&BR.x>=0&&BR.x=0&&BR.y{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(this._map.getTerrain()||this._map.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const HR=this._map.transform,IR=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&IR._rotate(HR.angle),"map"===this._pitchAlignment&&(IR.y*=Math.cos(HR._pitch)),IR}getOffset(){return this._offset}setOffset(JR){return this._offset=a.pointGeometry.convert(JR),this._update(),this}_onMove(KR){if(!this._isDragging){const LR=this._clickTolerance||this._map._clickTolerance;this._isDragging=KR.point.dist(this._pointerdownPos)>=LR}this._isDragging&&(this._pos=KR.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new a.Event("dragstart"))),this.fire(new a.Event("drag")))}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new a.Event("dragend")),this._state="inactive"}_addDragHandler(MR){this._element.contains(MR.originalEvent.target)&&(MR.preventDefault(),this._positionDelta=MR.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=MR.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(NR){return this._draggable=!!NR,this._map&&(NR?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(OR){return this._rotation=OR||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(PR){return this._rotationAlignment=PR||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(QR){return this._pitchAlignment=QR&&"auto"!==QR?QR:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const{HTMLImageElement:RR,HTMLElement:SR,ImageBitmap:TR}=a.window;function UR(a){a.parentNode&&a.parentNode.removeChild(a)}class VR{constructor(WR,XR,YR=!1){this._clickTolerance=10,this.element=XR,this.mouseRotate=new JI({clickTolerance:WR.dragRotate._mouseRotate._clickTolerance}),this.map=WR,YR&&(this.mousePitch=new QI({clickTolerance:WR.dragRotate._mousePitch._clickTolerance})),a.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),XR.addEventListener("mousedown",this.mousedown),XR.addEventListener("touchstart",this.touchstart,{passive:!1}),XR.addEventListener("touchmove",this.touchmove),XR.addEventListener("touchend",this.touchend),XR.addEventListener("touchcancel",this.reset)}down(ZR,$R){this.mouseRotate.mousedown(ZR,$R),this.mousePitch&&this.mousePitch.mousedown(ZR,$R),g.disableDrag()}move(_R,aS){const bS=this.map,cS=this.mouseRotate.mousemoveWindow(_R,aS);if(cS&&cS.bearingDelta&&bS.setBearing(bS.getBearing()+cS.bearingDelta),this.mousePitch){const dS=this.mousePitch.mousemoveWindow(_R,aS);dS&&dS.pitchDelta&&bS.setPitch(bS.getPitch()+dS.pitchDelta)}}off(){const eS=this.element;eS.removeEventListener("mousedown",this.mousedown),eS.removeEventListener("touchstart",this.touchstart,{passive:!1}),eS.removeEventListener("touchmove",this.touchmove),eS.removeEventListener("touchend",this.touchend),eS.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){g.enableDrag(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(fS){this.down(a.extend({},fS,{ctrlKey:!0,preventDefault:()=>fS.preventDefault()}),g.mousePos(this.element,fS)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(gS){this.move(gS,g.mousePos(this.element,gS))}mouseup(hS){this.mouseRotate.mouseupWindow(hS),this.mousePitch&&this.mousePitch.mouseupWindow(hS),this.offTemp()}touchstart(iS){1!==iS.targetTouches.length?this.reset():(this._startPos=this._lastPos=g.touchPos(this.element,iS.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>iS.preventDefault()},this._startPos))}touchmove(jS){1!==jS.targetTouches.length?this.reset():(this._lastPos=g.touchPos(this.element,jS.targetTouches)[0],this.move({preventDefault:()=>jS.preventDefault()},this._lastPos))}touchend(kS){0===kS.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)5280?pS(b,d,i/5280,a._getUIString("ScaleControl.Miles"),a):pS(b,d,i,a._getUIString("ScaleControl.Feet"),a)}else c&&"nautical"===c.unit?pS(b,d,h/1852,a._getUIString("ScaleControl.NauticalMiles"),a):h>=1e3?pS(b,d,h/1e3,a._getUIString("ScaleControl.Kilometers"),a):pS(b,d,h,a._getUIString("ScaleControl.Meters"),a)}function pS(a,b,c,d,e){const f=function(a){const b=Math.pow(10,`${Math.floor(a)}`.length-1);let c=a/b;return b*(c=c>=10?10:c>=5?5:c>=3?3:c>=2?2:c>=1?1:(function(a){const b=Math.pow(10,Math.ceil(-Math.log(a)/Math.LN10));return Math.round(a*b)/b})(c))}(c),g=f/c;e._requestDomTask(()=>{a.style.width=b*g+"px",a.innerHTML=`${f} ${d}`})}const qS={version:a.version,supported:b,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends TL{constructor(c){if(null!=(c=a.extend({},{center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},c)).minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new qA(c.minZoom,c.maxZoom,c.minPitch,c.maxPitch,c.renderWorldCopies),c),this._interactive=c.interactive,this._minTileCacheSize=c.minTileCacheSize,this._maxTileCacheSize=c.maxTileCacheSize,this._failIfMajorPerformanceCaveat=c.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=c.preserveDrawingBuffer,this._antialias=c.antialias,this._trackResize=c.trackResize,this._bearingSnap=c.bearingSnap,this._refreshExpiredTiles=c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=c.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=c.collectResourceTiming,this._optimizeForTerrain=c.optimizeForTerrain,this._renderTaskQueue=new PQ,this._domRenderTaskQueue=new PQ,this._controls=[],this._markers=[],this._mapId=a.uniqueId(),this._locale=a.extend({},{"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},c.locale),this._clickTolerance=c.clickTolerance,this._cooperativeGestures=c.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new class{constructor(b){this.jumpTo(b)}getValue(c){if(c<=this._startTime)return this._start;if(c>=this._endTime)return this._end;const d=a.easeCubicInOut((c-this._startTime)/(this._endTime-this._startTime));return this._start*(1-d)+this._end*d}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(f){this._startTime=-1/0,this._endTime=-1/0,this._start=f,this._end=f}easeTo(g,h,i){this._start=this.getValue(h),this._end=g,this._startTime=h,this._endTime=h+i}}(0),this._requestManager=new a.RequestManager(c.transformRequest,c.accessToken,c.testMode),this._silenceAuthErrors=!!c.testMode,"string"==typeof c.container){if(this._container=a.window.document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof SR))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(this._container.childNodes.length>0&&a.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),c.maxBounds&&this.setMaxBounds(c.maxBounds),a.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==a.window&&(a.window.addEventListener("online",this._onWindowOnline,!1),a.window.addEventListener("resize",this._onWindowResize,!1),a.window.addEventListener("orientationchange",this._onWindowResize,!1),a.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new class{constructor(b,c){this._map=b,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new class{constructor(b){this._map=b,this.clear()}clear(){this._inertiaBuffer=[]}record(c){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:c})}_drainInertiaBuffer(){const d=this._inertiaBuffer,e=a.exported.now();for(;d.length>0&&e-d[0].time>160;)d.shift()}_onMoveEnd(f){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const g={zoom:0,bearing:0,pitch:0,pan:new a.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:h}of this._inertiaBuffer)g.zoom+=h.zoomDelta||0,g.bearing+=h.bearingDelta||0,g.pitch+=h.pitchDelta||0,h.panDelta&&g.pan._add(h.panDelta),h.around&&(g.around=h.around),h.pinchAround&&(g.pinchAround=h.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,j={};if(g.pan.mag()){const k=GG(g.pan.mag(),i,a.extend({},BG,f||{}));j.offset=g.pan.mult(k.amount/g.pan.mag()),j.center=this._map.transform.center,FG(j,k)}if(g.zoom){const l=GG(g.zoom,i,CG);j.zoom=this._map.transform.zoom+l.amount,FG(j,l)}if(g.bearing){const m=GG(g.bearing,i,DG);j.bearing=this._map.transform.bearing+a.clamp(m.amount,-179,179),FG(j,m)}if(g.pitch){const n=GG(g.pitch,i,EG);j.pitch=this._map.transform.pitch+n.amount,FG(j,n)}if(j.zoom||j.bearing){const o=void 0===g.pinchAround?g.around:g.pinchAround;j.around=o?this._map.unproject(o):this._map.getCenter()}return this.clear(),a.extend(j,{noMoveStart:!0})}}(b),this._bearingSnap=c.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new class{constructor(){this.constants=[1,1,.01],this.radius=0}setup(b,c){const d=a.sub([],c,b);this.radius=a.length(d[2]<0?a.div([],d,this.constants):[d[0],d[1],0])}projectRay(e){a.div(e,e,this.constants),a.normalize(e,e),a.mul$1(e,e,this.constants);const f=a.scale$2([],e,this.radius);if(f[2]>0){const g=a.scale$2([],[0,0,1],a.dot(f,[0,0,1])),h=a.scale$2([],a.normalize([],[f[0],f[1],0]),this.radius),i=a.add([],f,a.scale$2([],a.sub([],a.add([],h,g),f),2));f[0]=i[0],f[1]=i[1]}return f}},this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(c),a.bindAll(["handleEvent","handleWindowEvent"],this);const d=this._el;for(const[e,f,h]of(this._listeners=[[d,"touchstart",{passive:!0}],[d,"touchmove",{passive:!1}],[d,"touchend",void 0],[d,"touchcancel",void 0],[d,"mousedown",void 0],[d,"mousemove",void 0],[d,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0}],[a.window.document,"mouseup",void 0],[d,"mouseover",void 0],[d,"mouseout",void 0],[d,"dblclick",void 0],[d,"click",void 0],[d,"keydown",{capture:!1}],[d,"keyup",void 0],[d,"wheel",{passive:!1}],[d,"contextmenu",void 0],[a.window,"blur",void 0]],this._listeners))e.addEventListener(f,e===a.window.document?this.handleWindowEvent:this.handleEvent,h)}destroy(){for(const[i,j,k]of this._listeners)i.removeEventListener(j,i===a.window.document?this.handleWindowEvent:this.handleEvent,k)}_addDefaultHandlers(l){const m=this._map,n=m.getCanvasContainer();this._add("mapEvent",new $G(m,l));const o=m.boxZoom=new vH(m,l);this._add("boxZoom",o);const p=new cI,q=new lL;m.doubleClickZoom=new iL(q,p),this._add("tapZoom",p),this._add("clickZoom",q);const r=new oL;this._add("tapDragZoom",r);const s=m.touchPitch=new fK(m);this._add("touchPitch",s);const t=new JI(l),u=new QI(l);m.dragRotate=new FL(l,t,u),this._add("mouseRotate",t,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);const v=new CI(l),w=new XI(m,l);m.dragPan=new AL(n,v,w),this._add("mousePan",v),this._add("touchPan",w,["touchZoom","touchRotate"]);const x=new YJ,y=new SJ;m.touchZoomRotate=new JL(n,y,x,r),this._add("touchRotate",x,["touchPan","touchZoom"]),this._add("touchZoom",y,["touchPan","touchRotate"]),this._add("blockableMapEvent",new rH(m));const z=m.scrollZoom=new CK(m,this);this._add("scrollZoom",z,["mousePan"]);const A=m.keyboard=new tK;for(const B of(this._add("keyboard",A),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"]))l.interactive&&l[B]&&m[B].enable(l[B])}_add(C,D,E){this._handlers.push({handlerName:C,handler:D,allowed:E}),this._handlersById[C]=D}stop(F){if(!this._updatingCamera){for(const{handler:G}of this._handlers)G.reset();this._inertia.clear(),this._fireEvents({},{},F),this._changes=[]}}isActive(){for(const{handler:H}of this._handlers)if(H.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(PL(this._eventsInProgress))||this.isZooming()}_blockedByActive(I,J,K){for(const L in I)if(L!==K&&(!J||0>J.indexOf(L)))return!0;return!1}handleWindowEvent(M){this.handleEvent(M,`${M.type}Window`)}_getMapTouches(N){const O=[];for(const P of N)this._el.contains(P.target)&&O.push(P);return O}handleEvent(Q,R){this._updatingCamera=!0;const S="renderFrame"===Q.type,T=S?void 0:Q,U={needsRenderFrame:!1},V={},W={},X=Q.touches?this._getMapTouches(Q.touches):void 0,Y=X?g.touchPos(this._el,X):S?void 0:g.mousePos(this._el,Q);for(const{handlerName:Z,handler:$,allowed:_}of this._handlers){if(!$.isEnabled())continue;let aa;this._blockedByActive(W,_,Z)?$.reset():$[R||Q.type]&&(aa=$[R||Q.type](Q,Y,X),this.mergeHandlerResult(U,V,aa,Z,T),aa&&aa.needsRenderFrame&&this._triggerRenderFrame()),(aa||$.isActive())&&(W[Z]=$)}const ba={};for(const ca in this._previousActiveHandlers)W[ca]||(ba[ca]=T);this._previousActiveHandlers=W,(Object.keys(ba).length||RL(U))&&(this._changes.push([U,V,ba]),this._triggerRenderFrame()),(Object.keys(W).length||RL(U))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:da}=U;da&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],da(this._map))}mergeHandlerResult(ea,fa,ga,ha,ia){if(!ga)return;a.extend(ea,ga);const ja={handlerName:ha,originalEvent:ga.originalEvent||ia};void 0!==ga.zoomDelta&&(fa.zoom=ja),void 0!==ga.panDelta&&(fa.drag=ja),void 0!==ga.pitchDelta&&(fa.pitch=ja),void 0!==ga.bearingDelta&&(fa.rotate=ja)}_applyChanges(){const ka={},la={},ma={};for(const[na,oa,pa]of this._changes)na.panDelta&&(ka.panDelta=(ka.panDelta||new a.pointGeometry(0,0))._add(na.panDelta)),na.zoomDelta&&(ka.zoomDelta=(ka.zoomDelta||0)+na.zoomDelta),na.bearingDelta&&(ka.bearingDelta=(ka.bearingDelta||0)+na.bearingDelta),na.pitchDelta&&(ka.pitchDelta=(ka.pitchDelta||0)+na.pitchDelta),void 0!==na.around&&(ka.around=na.around),void 0!==na.aroundCoord&&(ka.aroundCoord=na.aroundCoord),void 0!==na.pinchAround&&(ka.pinchAround=na.pinchAround),na.noInertia&&(ka.noInertia=na.noInertia),a.extend(la,oa),a.extend(ma,pa);this._updateMapTransform(ka,la,ma),this._changes=[]}_updateMapTransform(qa,ra,sa){const ta=this._map,ua=ta.transform,va=a=>[a.x,a.y,a.z];if((a=>{const b=this._eventsInProgress.drag;return b&&!this._handlersById[b.handlerName].isActive()})()&&!RL(qa)){const wa=ua.zoom;ua.cameraElevationReference="sea",ua.recenterOnTerrain(),ua.cameraElevationReference="ground",wa!==ua.zoom&&this._map._update(!0)}if(!RL(qa))return this._fireEvents(ra,sa,!0);let{panDelta:xa,zoomDelta:ya,bearingDelta:za,pitchDelta:Aa,around:Ba,aroundCoord:Ca,pinchAround:Da}=qa;void 0!==Da&&(Ba=Da),ra.drag&&!this._eventsInProgress.drag&&Ba&&(this._dragOrigin=va(ua.pointCoordinate3D(Ba)),this._trackingEllipsoid.setup(ua._camera.position,this._dragOrigin)),ua.cameraElevationReference="sea",ta._stop(!0),Ba=Ba||ta.transform.centerPoint,za&&(ua.bearing+=za),Aa&&(ua.pitch+=Aa),ua._updateCameraState();const Ea=[0,0,0];if(xa){const Fa=ua.pointCoordinate(Ba),Ga=ua.pointCoordinate(Ba.sub(xa));Fa&&Ga&&(Ea[0]=Ga.x-Fa.x,Ea[1]=Ga.y-Fa.y)}const Ha=ua.zoom,Ia=[0,0,0];if(ya){const Ja=va(Ca||ua.pointCoordinate3D(Ba)),Ka={dir:a.normalize([],a.sub([],Ja,ua._camera.position))};if(Ka.dir[2]<0){const La=ua.zoomDeltaToMovement(Ja,ya);a.scale$2(Ia,Ka.dir,La)}}const Ma=a.add(Ea,Ea,Ia);ua._translateCameraConstrained(Ma),ya&&Math.abs(ua.zoom-Ha)>1e-4&&ua.recenterOnTerrain(),ua.cameraElevationReference="ground",this._map._update(),qa.noInertia||this._inertia.record(qa),this._fireEvents(ra,sa,!0)}_fireEvents(Na,Oa,Pa){const Qa=PL(this._eventsInProgress),Ra=PL(Na),Sa={};for(const Ta in Na){const{originalEvent:Ua}=Na[Ta];this._eventsInProgress[Ta]||(Sa[`${Ta}start`]=Ua),this._eventsInProgress[Ta]=Na[Ta]}for(const Va in!Qa&&Ra&&this._fireEvent("movestart",Ra.originalEvent),Sa)this._fireEvent(Va,Sa[Va]);for(const Wa in Ra&&this._fireEvent("move",Ra.originalEvent),Na){const{originalEvent:Xa}=Na[Wa];this._fireEvent(Wa,Xa)}const Ya={};let Za;for(const $a in this._eventsInProgress){const{handlerName:_a,originalEvent:ab}=this._eventsInProgress[$a];this._handlersById[_a].isActive()||(delete this._eventsInProgress[$a],Za=Oa[_a]||ab,Ya[`${$a}end`]=Za)}for(const bb in Ya)this._fireEvent(bb,Ya[bb]);const cb=PL(this._eventsInProgress);if(Pa&&(Qa||Ra)&&!cb){this._updatingCamera=!0;const db=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),eb=a=>0!==a&& -this._bearingSnap{delete this._frameId,this.handleEvent(new QL("renderFrame",{timeStamp:a})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}(this,c),this._localFontFamily=c.localFontFamily,this._localIdeographFontFamily=c.localIdeographFontFamily,c.style&&this.setStyle(c.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),c.projection&&this.setProjection(c.projection),this._hash=c.hash&&new class{constructor(b){this._hashName=b&&encodeURIComponent(b),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=zG(this._updateHashUnthrottled.bind(this),300)}addTo(c){return this._map=c,a.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return a.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(d){const e=this._map.getCenter(),f=Math.round(100*this._map.getZoom())/100,g=Math.pow(10,Math.ceil((f*Math.LN2+Math.log(512/360/.5))/Math.LN10)),h=Math.round(e.lng*g)/g,i=Math.round(e.lat*g)/g,j=this._map.getBearing(),k=this._map.getPitch();let l="";if(l+=d?`/${h}/${i}/${f}`:`${f}/${i}/${h}`,(j||k)&&(l+="/"+Math.round(10*j)/10),k&&(l+=`/${Math.round(k)}`),this._hashName){const m=this._hashName;let n=!1;const o=a.window.location.hash.slice(1).split("&").map(a=>{const b=a.split("=")[0];return b===m?(n=!0,`${b}=${l}`):a}).filter(a=>a);return n||o.push(`${m}=${l}`),`#${o.join("&")}`}return`#${l}`}_getCurrentHash(){const p=a.window.location.hash.replace("#","");if(this._hashName){let q;return p.split("&").map(a=>a.split("=")).forEach(a=>{a[0]===this._hashName&&(q=a)}),(q&&q[1]||"").split("/")}return p.split("/")}_onHashChange(){const r=this._getCurrentHash();if(r.length>=3&&!r.some(a=>isNaN(a))){const s=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(r[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+r[2],+r[1]],zoom:+r[0],bearing:s,pitch:+(r[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,t)}}("string"==typeof c.hash&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.extend({},c.fitBoundsOptions,{duration:0})))),this.resize(),c.attributionControl&&this.addControl(new oQ({customAttribution:c.customAttribution})),this._logoControl=new GQ,this.addControl(this._logoControl,c.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",b=>{this._update("style"===b.dataType),this.fire(new a.Event(`${b.dataType}data`,b))}),this.on("dataloading",b=>{this.fire(new a.Event(`${b.dataType}dataloading`,b))})}_getMapId(){return this._mapId}addControl(d,e){if(void 0===e&&(e=d.getDefaultPosition?d.getDefaultPosition():"top-right"),!d||!d.onAdd)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const f=d.onAdd(this);this._controls.push(d);const h=this._controlPositions[e];return -1!==e.indexOf("bottom")?h.insertBefore(f,h.firstChild):h.appendChild(f),this}removeControl(i){if(!i||!i.onRemove)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const j=this._controls.indexOf(i);return j> -1&&this._controls.splice(j,1),i.onRemove(this),this}hasControl(k){return this._controls.indexOf(k)> -1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(l){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const m=!this._moving;return m&&this.fire(new a.Event("movestart",l)).fire(new a.Event("move",l)),this.fire(new a.Event("resize",l)),m&&this.fire(new a.Event("moveend",l)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(n){return this.transform.setMaxBounds(a.LngLatBounds.convert(n)),this._update()}setMinZoom(o){if((o=null==o?-2:o)>= -2&&o<=this.transform.maxZoom)return this.transform.minZoom=o,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=p,this._update(),this.getZoom()>p?this.setZoom(p):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(q){if((q=null==q?0:q)<0)throw new Error("minPitch must be greater than or equal to 0");if(q>=0&&q<=this.transform.maxPitch)return this.transform.minPitch=q,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(r>=this.transform.minPitch)return this.transform.maxPitch=r,this._update(),this.getPitch()>r?this.setPitch(r):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(s){return this.transform.renderWorldCopies=s,this._update()}getProjection(){return this.transform.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),"string"==typeof t&&(t={name:t}),this._runtimeProjection=t,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(u){return this.transform.locationPoint3D(a.LngLat.convert(u))}unproject(v){return this.transform.pointLocation3D(a.pointGeometry.convert(v))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(w,x,y){if("mouseenter"===w||"mouseover"===w){let z=!1;const A=a=>{const b=x.filter(a=>this.getLayer(a)),c=b.length?this.queryRenderedFeatures(a.point,{layers:b}):[];c.length?z||(z=!0,y.call(this,new HG(w,this,a.originalEvent,{features:c}))):z=!1},B=()=>{z=!1};return{layers:new Set(x),listener:y,delegates:{mousemove:A,mouseout:B}}}if("mouseleave"===w||"mouseout"===w){let C=!1;const D=a=>{const b=x.filter(a=>this.getLayer(a));(b.length?this.queryRenderedFeatures(a.point,{layers:b}):[]).length?C=!0:C&&(C=!1,y.call(this,new HG(w,this,a.originalEvent)))},E=a=>{C&&(C=!1,y.call(this,new HG(w,this,a.originalEvent)))};return{layers:new Set(x),listener:y,delegates:{mousemove:D,mouseout:E}}}return{layers:new Set(x),listener:y,delegates:{[w]:a=>{const b=x.filter(a=>this.getLayer(a)),c=b.length?this.queryRenderedFeatures(a.point,{layers:b}):[];c.length&&(a.features=c,y.call(this,a),delete a.features)}}}}on(F,G,H){if(void 0===H)return super.on(F,G);Array.isArray(G)||(G=[G]);const I=this._createDelegatedListener(F,G,H);for(const J in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[F]=this._delegatedListeners[F]||[],this._delegatedListeners[F].push(I),I.delegates)this.on(J,I.delegates[J]);return this}once(K,L,M){if(void 0===M)return super.once(K,L);Array.isArray(L)||(L=[L]);const N=this._createDelegatedListener(K,L,M);for(const O in N.delegates)this.once(O,N.delegates[O]);return this}off(P,Q,R){if(void 0===R)return super.off(P,Q);Q=new Set(Array.isArray(Q)?Q:[Q]);const S=(a,b)=>{if(a.size!==b.size)return!1;for(const c of a)if(!b.has(c))return!1;return!0},T=this._delegatedListeners?this._delegatedListeners[P]:void 0;return T&&(a=>{for(let b=0;b{b?this.fire(new a.ErrorEvent(b)):c&&this._updateDiff(c,ga)})}else"object"==typeof fa&&this._updateDiff(fa,ga)}_updateDiff(ja,ka){try{this.style.setState(ja)&&this._update(!0)}catch(la){a.warnOnce(`Unable to perform style diff: ${la.message||la.error||la}. Rebuilding the style from scratch.`),this._updateStyle(ja,ka)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.warnOnce("There is no style added to the map.")}addSource(ma,na){return this._lazyInitEmptyStyle(),this.style.addSource(ma,na),this._update(!0)}isSourceLoaded(oa){const pa=this.style&&this.style._getSourceCaches(oa);if(0!==pa.length)return pa.every(a=>a.loaded());this.fire(new a.ErrorEvent(new Error(`There is no source with ID '${oa}'`)))}areTilesLoaded(){const qa=this.style&&this.style._sourceCaches;for(const ra in qa){const sa=qa[ra]._tiles;for(const ta in sa){const ua=sa[ta];if("loaded"!==ua.state&&"errored"!==ua.state)return!1}}return!0}addSourceType(va,wa,xa){return this._lazyInitEmptyStyle(),this.style.addSourceType(va,wa,xa)}removeSource(ya){return this.style.removeSource(ya),this._updateTerrain(),this._update(!0)}getSource(za){return this.style.getSource(za)}addImage(Aa,Ba,{pixelRatio:Ca=1,sdf:Da=!1,stretchX:Ea,stretchY:Fa,content:Ga}={}){if(this._lazyInitEmptyStyle(),Ba instanceof RR||TR&&Ba instanceof TR){const{width:Ha,height:Ia,data:Ja}=a.exported.getImageData(Ba);this.style.addImage(Aa,{data:new a.RGBAImage({width:Ha,height:Ia},Ja),pixelRatio:Ca,stretchX:Ea,stretchY:Fa,content:Ga,sdf:Da,version:0})}else{if(void 0===Ba.width|| void 0===Ba.height)return this.fire(new a.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:Ka,height:La,data:Ma}=Ba,Na=Ba;this.style.addImage(Aa,{data:new a.RGBAImage({width:Ka,height:La},new Uint8Array(Ma)),pixelRatio:Ca,stretchX:Ea,stretchY:Fa,content:Ga,sdf:Da,version:0,userImage:Na}),Na.onAdd&&Na.onAdd(this,Aa)}}}updateImage(Oa,Pa){const Qa=this.style.getImage(Oa);if(!Qa)return this.fire(new a.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const Ra=Pa instanceof RR||TR&&Pa instanceof TR?a.exported.getImageData(Pa):Pa,{width:Sa,height:Ta,data:Ua}=Ra;return void 0===Sa|| void 0===Ta?this.fire(new a.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`"))):Sa!==Qa.data.width||Ta!==Qa.data.height?this.fire(new a.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(Qa.data.replace(Ua,!(Pa instanceof RR||TR&&Pa instanceof TR)),void this.style.updateImage(Oa,Qa))}hasImage(Va){return Va?!!this.style.getImage(Va):(this.fire(new a.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(Wa){this.style.removeImage(Wa)}loadImage(Xa,Ya){a.getImage(this._requestManager.transformRequest(Xa,a.ResourceType.Image),(b,c)=>{Ya(b,c instanceof RR?a.exported.getImageData(c):c)})}listImages(){return this.style.listImages()}addLayer(Za,$a){return this._lazyInitEmptyStyle(),this.style.addLayer(Za,$a),this._update(!0)}moveLayer(_a,ab){return this.style.moveLayer(_a,ab),this._update(!0)}removeLayer(bb){return this.style.removeLayer(bb),this._update(!0)}getLayer(cb){return this.style.getLayer(cb)}setLayerZoomRange(db,eb,fb){return this.style.setLayerZoomRange(db,eb,fb),this._update(!0)}setFilter(gb,hb,ib={}){return this.style.setFilter(gb,hb,ib),this._update(!0)}getFilter(jb){return this.style.getFilter(jb)}setPaintProperty(kb,lb,mb,nb={}){return this.style.setPaintProperty(kb,lb,mb,nb),this._update(!0)}getPaintProperty(ob,pb){return this.style.getPaintProperty(ob,pb)}setLayoutProperty(qb,rb,sb,tb={}){return this.style.setLayoutProperty(qb,rb,sb,tb),this._update(!0)}getLayoutProperty(ub,vb){return this.style.getLayoutProperty(ub,vb)}setLight(wb,xb={}){return this._lazyInitEmptyStyle(),this.style.setLight(wb,xb),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(yb){return this._lazyInitEmptyStyle(),!yb&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(yb),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){"globe"===this.transform.projection.name&&this.transform.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(zb){return this._lazyInitEmptyStyle(),this.style.setFog(zb),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(Ab){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.LngLat.convert(Ab),this.transform):0}setFeatureState(Bb,Cb){return this.style.setFeatureState(Bb,Cb),this._update()}removeFeatureState(Db,Eb){return this.style.removeFeatureState(Db,Eb),this._update()}getFeatureState(Fb){return this.style.getFeatureState(Fb)}_updateContainerDimensions(){if(!this._container)return;const Gb=this._container.getBoundingClientRect().width||400,Hb=this._container.getBoundingClientRect().height||300;let Ib,Jb=this._container;for(;Jb&&!Ib;){const Kb=a.window.getComputedStyle(Jb).transform;Kb&&"none"!==Kb&&(Ib=Kb.match(/matrix.*\((.+)\)/)[1].split(", ")),Jb=Jb.parentElement}Ib?(this._containerWidth=Ib[0]&&"0"!==Ib[0]?Math.abs(Gb/Ib[0]):Gb,this._containerHeight=Ib[3]&&"0"!==Ib[3]?Math.abs(Hb/Ib[3]):Hb):(this._containerWidth=Gb,this._containerHeight=Hb)}_detectMissingCSS(){"rgb(250, 128, 114)"!==a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&a.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const Lb=this._container;Lb.classList.add("mapboxgl-map"),(this._missingCSSCanary=g.create("div","mapboxgl-canary",Lb)).style.visibility="hidden",this._detectMissingCSS();const Mb=this._canvasContainer=g.create("div","mapboxgl-canvas-container",Lb);this._interactive&&Mb.classList.add("mapboxgl-interactive"),this._canvas=g.create("canvas","mapboxgl-canvas",Mb),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const Nb=this._controlContainer=g.create("div","mapboxgl-control-container",Lb),Ob=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(a=>{Ob[a]=g.create("div",`mapboxgl-ctrl-${a}`,Nb)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(Pb,Qb){const Rb=a.exported.devicePixelRatio||1;this._canvas.width=Rb*Math.ceil(Pb),this._canvas.height=Rb*Math.ceil(Qb),this._canvas.style.width=`${Pb}px`,this._canvas.style.height=`${Qb}px`}_addMarker(Sb){this._markers.push(Sb)}_removeMarker(Tb){const Ub=this._markers.indexOf(Tb);-1!==Ub&&this._markers.splice(Ub,1)}_setupPainter(){const Vb=a.extend({},b.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),Wb=this._canvas.getContext("webgl",Vb)||this._canvas.getContext("experimental-webgl",Vb);Wb?(a.storeAuthState(Wb,!0),this.painter=new yw(Wb,this.transform),this.on("data",a=>{"source"===a.dataType&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(Wb)):this.fire(new a.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(Xb){Xb.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:Xb}))}_contextRestored(Yb){this._setupPainter(),this.resize(),this._update(),this.fire(new a.Event("webglcontextrestored",{originalEvent:Yb}))}_onMapScroll(Zb){if(Zb.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update($b){return this.style&&(this._styleDirty=this._styleDirty||$b,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(_b){return this._update(),this._renderTaskQueue.add(_b)}_cancelRenderFrame(ac){this._renderTaskQueue.remove(ac)}_requestDomTask(bc){!this.loaded()||this.loaded()&&!this.isMoving()?bc():this._domRenderTaskQueue.add(bc)}_render(cc){let dc;const ec=this.painter.context.extTimerQuery,fc=a.exported.now();this.listens("gpu-timing-frame")&&(dc=ec.createQueryEXT(),ec.beginQueryEXT(ec.TIME_ELAPSED_EXT,dc));let gc=this._updateAverageElevation(fc);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(cc),this._domRenderTaskQueue.run(cc),this._removed)return;this._updateProjection();let hc=!1;const ic=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const jc=this.transform.zoom,kc=this.transform.pitch,lc=a.exported.now();this.style.zoomHistory.update(jc,lc);const mc=new a.EvaluationParameters(jc,{now:lc,fadeDuration:ic,pitch:kc,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),nc=mc.crossFadingFactor();1===nc&&nc===this._crossFadingFactor||(hc=!0,this._crossFadingFactor=nc),this.style.update(mc)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,ic,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:ic,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.Event("load"))),this.style&&(this.style.hasTransitions()||hc)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const oc=a.exported.now()-fc;ec.endQueryEXT(ec.TIME_ELAPSED_EXT,dc),setTimeout(()=>{const b=ec.getQueryObjectEXT(dc,ec.QUERY_RESULT_EXT)/1e6;ec.deleteQueryEXT(dc),this.fire(new a.Event("gpu-timing-frame",{cpuTime:oc,gpuTime:b}))},50)}if(this.listens("gpu-timing-layer")){const pc=this.painter.collectGpuTimers();setTimeout(()=>{const b=this.painter.queryGpuTimers(pc);this.fire(new a.Event("gpu-timing-layer",{layerTimes:b}))},50)}const qc=this._sourcesDirty||this._styleDirty||this._placementDirty||gc;if(qc||this._repaint)this.triggerRepaint();else{const rc=!this.isMoving()&&this.loaded();if(rc&&(gc=this._updateAverageElevation(fc,!0)),gc)this.triggerRepaint();else if(this._triggerFrame(!1),rc&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const sc=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:sc})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||qc||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const tc of this._markers)tc._update()}_updateAverageElevation(uc,vc=!1){const wc=a=>(this.transform.averageElevation=a,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&wc(0);if((vc||uc-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(uc)){const xc=this.transform.averageElevation;let yc=this.transform.sampleAverageElevation();isNaN(yc)?yc=0:this._averageElevationLastSampledAt=uc;const zc=Math.abs(xc-yc);if(zc>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(yc),wc(yc);this._averageElevation.easeTo(yc,uc,300)}else if(zc>1e-4)return this._averageElevation.jumpTo(yc),wc(yc)}return!!this._averageElevation.isEasing(uc)&&wc(this._averageElevation.getValue(uc))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,b=>{if(b&&(b.message===a.AUTH_ERR_MSG||401===b.status)){const c=this.painter.context.gl;a.storeAuthState(c,!1),this._logoControl instanceof GQ&&this._logoControl._updateLogo(),c&&c.clear(c.DEPTH_BUFFER_BIT|c.COLOR_BUFFER_BIT|c.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),a.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const Ac=this.painter.canvasCopy(),Bc=this.painter.getCanvasCopiesAndTimestamps();Bc.timeStamps.push(performance.now());const Cc=this.painter.context.gl,Dc=Cc.createFramebuffer();function Ec(a){Cc.framebufferTexture2D(Cc.FRAMEBUFFER,Cc.COLOR_ATTACHMENT0,Cc.TEXTURE_2D,a,0);const b=new Uint8Array(Cc.drawingBufferWidth*Cc.drawingBufferHeight*4);return Cc.readPixels(0,0,Cc.drawingBufferWidth,Cc.drawingBufferHeight,Cc.RGBA,Cc.UNSIGNED_BYTE,b),b}return Cc.bindFramebuffer(Cc.FRAMEBUFFER,Dc),this._canvasPixelComparison(Ec(Ac),Bc.canvasCopies.map(Ec),Bc.timeStamps)}_canvasPixelComparison(Fc,Gc,Hc){let Ic=Hc[1]-Hc[0];const Jc=Fc.length/4;for(let Kc=0;Kc{const b=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,b&&this._render(a)}))}_preloadTiles(Rc){const Sc=this.style&&Object.values(this.style._sourceCaches)||[];return a.asyncAll(Sc,(a,b)=>a._preloadTiles(Rc,b),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(Tc){this._trackResize&&this.resize({originalEvent:Tc})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(Uc){this._showTileBoundaries!==Uc&&(this._showTileBoundaries=Uc,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(Vc){this._showTerrainWireframe!==Vc&&(this._showTerrainWireframe=Vc,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(Wc){this._speedIndexTiming!==Wc&&(this._speedIndexTiming=Wc,this._update())}get showPadding(){return!!this._showPadding}set showPadding(Xc){this._showPadding!==Xc&&(this._showPadding=Xc,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(Yc){this._showCollisionBoxes!==Yc&&(this._showCollisionBoxes=Yc,Yc?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(Zc){this._showOverdrawInspector!==Zc&&(this._showOverdrawInspector=Zc,this._update())}get repaint(){return!!this._repaint}set repaint($c){this._repaint!==$c&&(this._repaint=$c,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(_c){this._vertices=_c,this._update()}_setCacheLimits(ad,bd){a.setCacheLimits(ad,bd)}get version(){return a.version}},NavigationControl:class{constructor(b){this.options=a.extend({},{showCompass:!0,showZoom:!0,visualizePitch:!1},b),this._container=g.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",a=>a.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",a=>this._map.zoomIn({},{originalEvent:a})),g.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",a=>this._map.zoomOut({},{originalEvent:a})),g.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",a=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:a}):this._map.resetNorth({},{originalEvent:a})}),this._compassIcon=g.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const c=this._map.getZoom(),d=c===this._map.getMaxZoom(),e=c===this._map.getMinZoom();this._zoomInButton.disabled=d,this._zoomOutButton.disabled=e,this._zoomInButton.setAttribute("aria-disabled",d.toString()),this._zoomOutButton.setAttribute("aria-disabled",e.toString())}_rotateCompassArrow(){const f=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=f)})}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new VR(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(i,j){const k=g.create("button",i,this._container);return k.type="button",k.addEventListener("click",j),k}_setButtonTitle(l,m){const n=this._map._getUIString(`NavigationControl.${m}`);l.setAttribute("aria-label",n),l.firstElementChild&&l.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends a.Evented{constructor(b){super(),this.options=a.extend({},{positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},b),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation"],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=zG(this._updateMarkerRotation,20)}onAdd(c){var d;return this._map=c,this._container=g.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),d=this._setupUI,void 0!==lS?d(lS):void 0!==a.window.navigator.permissions?a.window.navigator.permissions.query({name:"geolocation"}).then(a=>{d(lS="denied"!==a.state)}):d(lS=!!a.window.navigator.geolocation),this._container}onRemove(){void 0!==this._geolocationWatchID&&(a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,mS=0,nS=!1}_isOutOfMapMaxBounds(e){const f=this._map.getMaxBounds(),h=e.coords;return f&&(h.longitudef.getEast()||h.latitudef.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(i){if(this._map){if(this._isOutOfMapMaxBounds(i))return this._setErrorState(),this.fire(new a.Event("outofmaxbounds",i)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=i,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(i),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(i),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("geolocate",i)),this._finish()}}_updateCamera(j){const k=new a.LngLat(j.coords.longitude,j.coords.latitude),l=j.coords.accuracy,m=this._map.getBearing(),n=a.extend({bearing:m},this.options.fitBoundsOptions);this._map.fitBounds(k.toBounds(l),n,{geolocateSource:!0})}_updateMarker(o){if(o){const p=new a.LngLat(o.coords.longitude,o.coords.latitude);this._accuracyCircleMarker.setLngLat(p).addTo(this._map),this._userLocationDotMarker.setLngLat(p).addTo(this._map),this._accuracy=o.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const q=this._map._containerHeight/2,r=this._map.unproject([0,q]),s=this._map.unproject([100,q]),t=r.distanceTo(s)/100,u=Math.ceil(2*this._accuracy/t);this._circleElement.style.width=`${u}px`,this._circleElement.style.height=`${u}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(v){if(this._map){if(this.options.trackUserLocation)if(1===v.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const w=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",w),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",w),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===v.code&&nS)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",v)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(x){if(this._container.addEventListener("contextmenu",a=>a.preventDefault()),this._geolocateButton=g.create("button","mapboxgl-ctrl-geolocate",this._container),g.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===x){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const y=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",y),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",y)}else{const z=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",z),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",z)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=g.create("div","mapboxgl-user-location"),this._dotElement.appendChild(g.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(g.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new _Q({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=g.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new _Q({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",b=>{b.geolocateSource||"ACTIVE_LOCK"!==this._watchState||b.originalEvent&&"resize"===b.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.Event("trackuserlocationend")))})}_onDeviceOrientation(A){this._userLocationDotMarker&&(A.webkitCompassHeading?this._heading=A.webkitCompassHeading:!0===A.absolute&&(this._heading=-1*A.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new a.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":mS--,nS=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new a.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&& void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let B;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),mS++,mS>1?(B={maximumAge:6e5,timeout:0},nS=!0):(B=this.options.positionOptions,nS=!1),this._geolocationWatchID=a.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,B),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else a.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const C=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};void 0!==a.window.DeviceMotionEvent&&"function"==typeof a.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(a=>{"granted"===a&&C()}).catch(console.error):C()}_clearWatch(){a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),a.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:oQ,ScaleControl:class{constructor(b){this.options=a.extend({},{maxWidth:100,unit:"metric"},b),a.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){oS(this._map,this._container,this.options)}onAdd(c){return this._map=c,this._container=g.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",c.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(d){this.options.unit=d,oS(this._map,this._container,this.options)}},FullscreenControl:class{constructor(b){this._fullscreen=!1,b&&b.container&&(b.container instanceof a.window.HTMLElement?this._container=b.container:a.warnOnce("Full screen control 'container' must be a DOM element.")),a.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in a.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in a.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(c){return this._map=c,this._container||(this._container=this._map.getContainer()),this._controlContainer=g.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,a.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!a.window.document.fullscreenEnabled&&!a.window.document.webkitFullscreenEnabled)}_setupUI(){const d=this._fullscreenButton=g.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);g.create("span","mapboxgl-ctrl-icon",d).setAttribute("aria-hidden",!0),d.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(a.window.document.fullscreenElement||a.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?a.window.document.exitFullscreen?a.window.document.exitFullscreen():a.window.document.webkitCancelFullScreen&&a.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.Evented{constructor(b){super(),this.options=a.extend(Object.create({closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"}),b),a.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this),this._classList=new Set(b&&b.className?b.className.trim().split(/\s+/):[])}addTo(c){return this._map&&this.remove(),this._map=c,this.options.closeOnClick&&this._map.on("preclick",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new a.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(d){return this._lngLat=a.LngLat.convert(d),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(a.window.document.createTextNode(e))}setHTML(f){const h=a.window.document.createDocumentFragment(),i=a.window.document.createElement("body");let j;for(i.innerHTML=f;j=i.firstChild;)h.appendChild(j);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(k){return this.options.maxWidth=k,this._update(),this}setDOMContent(l){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=g.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(l),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(m){return this._classList.add(m),this._container&&this._updateClassList(),this}removeClassName(n){return this._classList.delete(n),this._container&&this._updateClassList(),this}setOffset(o){return this.options.offset=o,this._update(),this}toggleClassName(p){let q;return this._classList.delete(p)?q=!1:(this._classList.add(p),q=!0),this._container&&this._updateClassList(),q}_createCloseButton(){this.options.closeButton&&(this._closeButton=g.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(r){this._update(r.point)}_onMouseMove(s){this._update(s.point)}_onDrag(t){this._update(t.point)}_getAnchor(u){if(this.options.anchor)return this.options.anchor;const v=this._pos,w=this._container.offsetWidth,x=this._container.offsetHeight;let y;return y=v.y+u.bottom.ythis._map.transform.height-x?["bottom"]:[],v.xthis._map.transform.width-w/2&&y.push("right"),0===y.length?"bottom":y.join("-")}_updateClassList(){const z=[...this._classList];z.push("mapboxgl-popup"),this._anchor&&z.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&z.push("mapboxgl-popup-track-pointer"),this._container.className=z.join(" ")}_update(A){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=g.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=g.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ZQ(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||A){const B=this._pos=this._trackPointer&&A?A:this._map.project(this._lngLat),C=function(b){if(b||(b=new a.pointGeometry(0,0)),"number"==typeof b){const c=Math.round(Math.sqrt(.5*Math.pow(b,2)));return{center:new a.pointGeometry(0,0),top:new a.pointGeometry(0,b),"top-left":new a.pointGeometry(c,c),"top-right":new a.pointGeometry(-c,c),bottom:new a.pointGeometry(0,-b),"bottom-left":new a.pointGeometry(c,-c),"bottom-right":new a.pointGeometry(-c,-c),left:new a.pointGeometry(b,0),right:new a.pointGeometry(-b,0)}}if(b instanceof a.pointGeometry||Array.isArray(b)){const d=a.pointGeometry.convert(b);return{center:d,top:d,"top-left":d,"top-right":d,bottom:d,"bottom-left":d,"bottom-right":d,left:d,right:d}}return{center:a.pointGeometry.convert(b.center||[0,0]),top:a.pointGeometry.convert(b.top||[0,0]),"top-left":a.pointGeometry.convert(b["top-left"]||[0,0]),"top-right":a.pointGeometry.convert(b["top-right"]||[0,0]),bottom:a.pointGeometry.convert(b.bottom||[0,0]),"bottom-left":a.pointGeometry.convert(b["bottom-left"]||[0,0]),"bottom-right":a.pointGeometry.convert(b["bottom-right"]||[0,0]),left:a.pointGeometry.convert(b.left||[0,0]),right:a.pointGeometry.convert(b.right||[0,0])}}(this.options.offset),D=this._anchor=this._getAnchor(C),E=B.add(C[D]).round();this._map._requestDomTask(()=>{this._container&&D&&(this._container.style.transform=`${$Q[D]} translate(${E.x}px,${E.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const F=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");F&&F.focus()}_onClose(){this.remove()}_setOpacity(G){this._content&&(this._content.style.opacity=G),this._tip&&(this._tip.style.opacity=G)}},Marker:_Q,Style:Ej,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.pointGeometry,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:sz,Evented:a.Evented,config:a.config,prewarm:function(){Zd().acquire(Ud)},clearPrewarmedResources:function(){const a=Yd;a&&(a.isPreloaded()&&1===a.numActive()?(a.release(Ud),Yd=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return a.config.ACCESS_TOKEN},set accessToken(t){a.config.ACCESS_TOKEN=t},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(t){a.config.API_URL=t},get workerCount(){return Vd.workerCount},set workerCount(e){Vd.workerCount=e},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){a.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(b){a.clearTileCache(b)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return qS}),c})}}]) +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(b,c,a){var d=a(3454);!function(c,a){b.exports=a()}(this,function(){"use strict";var c,e,b;function a(g,a){if(c)if(e){var f="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+c+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",d={};c(d),b=a(d),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(b.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else e=a;else c=a}return a(["exports"],function(a){"use strict";var fa,Bb="2.7.0",sf=H;function H(a,c,d,b){this.cx=3*a,this.bx=3*(d-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*c,this.by=3*(b-c)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=b,this.p2x=d,this.p2y=b}H.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},H.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},H.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},H.prototype.solveCurveX=function(c,e){var b,d,a,f,g;for(void 0===e&&(e=1e-6),a=c,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(a)-c)Math.abs(h))break;a-=f/h}if((a=c)<(b=0))return b;if(a>(d=1))return d;for(;bf?b=a:d=a,a=.5*(d-b)+b}return a},H.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var Ha=Ia;function Ia(a,b){this.x=a,this.y=b}Ia.prototype={clone:function(){return new Ia(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(b,a){var c=Math.cos(b),d=Math.sin(b),e=a.y+d*(this.x-a.x)+c*(this.y-a.y);return this.x=a.x+c*(this.x-a.x)-d*(this.y-a.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ia.convert=function(a){return a instanceof Ia?a:Array.isArray(a)?new Ia(a[0],a[1]):a};var s="undefined"!=typeof self?self:{},I="undefined"!=typeof Float32Array?Float32Array:Array;function Ja(){var a=new I(9);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function Ka(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function La(a,b,c){var h=b[0],i=b[1],j=b[2],k=b[3],l=b[4],m=b[5],n=b[6],o=b[7],p=b[8],q=b[9],r=b[10],s=b[11],t=b[12],u=b[13],v=b[14],w=b[15],d=c[0],e=c[1],f=c[2],g=c[3];return a[0]=d*h+e*l+f*p+g*t,a[1]=d*i+e*m+f*q+g*u,a[2]=d*j+e*n+f*r+g*v,a[3]=d*k+e*o+f*s+g*w,a[4]=(d=c[4])*h+(e=c[5])*l+(f=c[6])*p+(g=c[7])*t,a[5]=d*i+e*m+f*q+g*u,a[6]=d*j+e*n+f*r+g*v,a[7]=d*k+e*o+f*s+g*w,a[8]=(d=c[8])*h+(e=c[9])*l+(f=c[10])*p+(g=c[11])*t,a[9]=d*i+e*m+f*q+g*u,a[10]=d*j+e*n+f*r+g*v,a[11]=d*k+e*o+f*s+g*w,a[12]=(d=c[12])*h+(e=c[13])*l+(f=c[14])*p+(g=c[15])*t,a[13]=d*i+e*m+f*q+g*u,a[14]=d*j+e*n+f*r+g*v,a[15]=d*k+e*o+f*s+g*w,a}function Cb(b,a,f){var r,g,h,i,j,k,l,m,n,o,p,q,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[1],h=a[2],i=a[3],j=a[4],k=a[5],l=a[6],m=a[7],n=a[8],o=a[9],p=a[10],q=a[11],b[0]=r=a[0],b[1]=g,b[2]=h,b[3]=i,b[4]=j,b[5]=k,b[6]=l,b[7]=m,b[8]=n,b[9]=o,b[10]=p,b[11]=q,b[12]=r*c+j*d+n*e+a[12],b[13]=g*c+k*d+o*e+a[13],b[14]=h*c+l*d+p*e+a[14],b[15]=i*c+m*d+q*e+a[15]),b}function Db(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function Eb(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*d+j*c,a[5]=g*d+k*c,a[6]=h*d+l*c,a[7]=i*d+m*c,a[8]=j*d-f*c,a[9]=k*d-g*c,a[10]=l*d-h*c,a[11]=m*d-i*c,a}function Fb(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d-j*c,a[1]=g*d-k*c,a[2]=h*d-l*c,a[3]=i*d-m*c,a[8]=f*c+j*d,a[9]=g*c+k*d,a[10]=h*c+l*d,a[11]=i*c+m*d,a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)});var Gb=La;function Ma(){var a=new I(3);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function tf(b){var a=new I(3);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a}function Na(a){return Math.hypot(a[0],a[1],a[2])}function Q(b,c,d){var a=new I(3);return a[0]=b,a[1]=c,a[2]=d,a}function Hb(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function Oa(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function Pa(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function uf(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function Ib(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function Jb(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function Kb(c,a){var d=a[0],e=a[1],f=a[2],b=d*d+e*e+f*f;return b>0&&(b=1/Math.sqrt(b)),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function Lb(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function Mb(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function Nb(b,g,a){var c=g[0],d=g[1],e=g[2],f=a[3]*c+a[7]*d+a[11]*e+a[15];return b[0]=(a[0]*c+a[4]*d+a[8]*e+a[12])/(f=f||1),b[1]=(a[1]*c+a[5]*d+a[9]*e+a[13])/f,b[2]=(a[2]*c+a[6]*d+a[10]*e+a[14])/f,b}function Ob(a,h,b){var c=b[0],d=b[1],e=b[2],i=h[0],j=h[1],k=h[2],l=d*k-e*j,f=e*i-c*k,g=c*j-d*i,p=d*g-e*f,n=e*l-c*g,o=c*f-d*l,m=2*b[3];return f*=m,g*=m,n*=2,o*=2,a[0]=i+(l*=m)+(p*=2),a[1]=j+f+n,a[2]=k+g+o,a}var J,Pb=Oa;function Qb(b,c,a){var d=c[0],e=c[1],f=c[2],g=c[3];return b[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*g,b[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*g,b[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*g,b[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*g,b}function Qa(){var a=new I(4);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function Rb(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function Sb(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+i*c,a[1]=g*d+h*c,a[2]=h*d-g*c,a[3]=i*d-f*c,a}function vf(a,b){return a[0]===b[0]&&a[1]===b[1]}Ma(),J=new I(4),I!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0,J[3]=0),Ma(),Q(1,0,0),Q(0,1,0),Qa(),Qa(),Ja(),fa=new I(2),I!=Float32Array&&(fa[0]=0,fa[1]=0);const wf=Math.PI/180,xf=180/Math.PI;function ga(a){return a*wf}function Tb(a){return a*xf}const yf=[[0,0],[1,0],[1,1],[0,1]];function Ub(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function Ra(a,b,c,d){const e=new sf(a,b,c,d);return function(a){return e.solve(a)}}const Vb=Ra(.25,.1,.25,1);function Wb(a,b,c){return Math.min(c,Math.max(b,a))}function Xb(b,c,a){return(a=Wb((a-b)/(c-b),0,1))*a*(3-2*a)}function Yb(e,a,c){const b=c-a,d=((e-a)%b+b)%b+a;return d===a?c:d}function Zb(a,c,b){if(!a.length)return b(null,[]);let d=a.length;const e=new Array(a.length);let f=null;a.forEach((a,g)=>{c(a,(a,c)=>{a&&(f=a),e[g]=c,0== --d&&b(f,e)})})}function $b(a){const b=[];for(const c in a)b.push(a[c]);return b}function _b(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}let zf=1;function ac(){return zf++}function Af(){return(function b(a){return a?(a^16*Math.random()>>a/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,b)})()}function bc(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function Bf(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function cc(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function dc(a,b){return -1!==a.indexOf(b,a.length-b.length)}function Cf(a,d,e){const c={};for(const b in a)c[b]=d.call(e||this,a[b],b,a);return c}function ec(a,d,e){const c={};for(const b in a)d.call(e||this,a[b],b,a)&&(c[b]=a[b]);return c}function fc(a){return Array.isArray(a)?a.map(fc):"object"==typeof a&&a?Cf(a,fc):a}const Df={};function gc(a){Df[a]||("undefined"!=typeof console&&console.warn(a),Df[a]=!0)}function Ef(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function Ff(a){let e=0;for(let b,c,d=0,f=a.length,g=f-1;d@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,c,d,e)=>{const b=d||e;return a[c]=!b||b.toLowerCase(),""}),a["max-age"]){const b=parseInt(a["max-age"],10);isNaN(b)?delete a["max-age"]:a["max-age"]=b}return a}let Hf,ha,If,Jf=null;function Kf(b){if(null==Jf){const a=b.navigator?b.navigator.userAgent:null;Jf=!!b.safari||!(!a||!(/\b(iPad|iPhone|iPod)\b/.test(a)||a.match("Safari")&&!a.match("Chrome")))}return Jf}function Lf(b){try{const a=s[b];return a.setItem("_mapbox_test_",1),a.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const ic={now:()=>void 0!==If?If:s.performance.now(),setNow(a){If=a},restoreNow(){If=void 0},frame(a){const b=s.requestAnimationFrame(a);return{cancel:()=>s.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=s.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw new Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(Hf||(Hf=s.document.createElement("a")),Hf.href=a,Hf.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==ha&&(ha=s.matchMedia("(prefers-reduced-motion: reduce)")),ha.matches)}};let R;const jc={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==R){const Sa=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R=null!=d.env.API_URL_REGEX?new RegExp(d.env.API_URL_REGEX):Sa}catch(Mf){R=Sa}}return R},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},kc={supported:!1,testSupport:function(a){!Of&&ia&&(Pf?Qf(a):Nf=a)}};let Nf,ia,Of=!1,Pf=!1;function Qf(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,ia),a.isContextLost())return;kc.supported=!0}catch(c){}a.deleteTexture(b),Of=!0}s.document&&((ia=s.document.createElement("img")).onload=function(){Nf&&Qf(Nf),Nf=null,Pf=!0},ia.onerror=function(){Of=!0,Nf=null},ia.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const lc="NO_ACCESS_TOKEN";function mc(a){return 0===a.indexOf("mapbox:")}function Rf(a){return jc.API_URL_REGEX.test(a)}const Sf=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Tf(b){const a=b.match(Sf);if(!a)throw new Error("Unable to parse URL object");return{protocol:a[1],authority:a[2],path:a[3]||"/",params:a[4]?a[4].split("&"):[]}}function Uf(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function Vf(b){if(!b)return null;const a=b.split(".");if(!a||3!==a.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(a[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class Wf{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(c){const a=Vf(jc.ACCESS_TOKEN);let b="";return b=a&&a.u?s.btoa(encodeURIComponent(a.u).replace(/%([0-9A-F]{2})/g,(b,a)=>String.fromCharCode(Number("0x"+a)))):jc.ACCESS_TOKEN||"",c?`mapbox.eventData.${c}:${b}`:`mapbox.eventData:${b}`}fetchEventData(){const c=Lf("localStorage"),d=this.getStorageKey(),e=this.getStorageKey("uuid");if(c)try{const a=s.localStorage.getItem(d);a&&(this.eventData=JSON.parse(a));const b=s.localStorage.getItem(e);b&&(this.anonId=b)}catch(f){gc("Unable to read from LocalStorage")}}saveEventData(){const a=Lf("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{s.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){gc("Unable to write to LocalStorage")}}processRequests(a){}postEvent(d,a,h,e){if(!jc.EVENTS_URL)return;const b=Tf(jc.EVENTS_URL);b.params.push(`access_token=${e||jc.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(d).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:Bb,skuId:"01",userId:this.anonId},f=a?_b(c,a):c,g={url:Uf(b),headers:{"Content-Type":"text/plain"},body:JSON.stringify([f])};this.pendingRequest=gg(g,a=>{this.pendingRequest=null,h(a),this.saveEventData(),this.processRequests(e)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const Ta=new class extends Wf{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){jc.EVENTS_URL&&jc.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>mc(a)||Rf(a))&&this.queueRequest(Date.now(),b)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const c=Vf(jc.ACCESS_TOKEN),f=c?c.u:jc.ACCESS_TOKEN;let a=f!==this.eventData.tokenU;Bf(this.anonId)||(this.anonId=Af(),a=!0);const b=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(b),d=(b-this.eventData.lastSuccess)/864e5;a=a||d>=1||d< -1||g.getDate()!==h.getDate()}else a=!0;if(!a)return this.processRequests();this.postEvent(b,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=b,this.eventData.tokenU=f)},e)}},nc=Ta.postTurnstileEvent.bind(Ta),Ua=new class extends Wf{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(b,c,a,d){this.skuToken=c,this.errorCb=d,jc.EVENTS_URL&&(a||jc.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(lc)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||(this.anonId||this.fetchEventData(),Bf(this.anonId)||(this.anonId=Af()),this.postEvent(c,{skuToken:this.skuToken},b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b))}},oc=Ua.postMapLoadEvent.bind(Ua),Va=new class extends Wf{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,b,f,c){if(!jc.API_URL||!jc.SESSION_PATH)return;const a=Tf(jc.API_URL+jc.SESSION_PATH);a.params.push(`sku=${b||""}`),a.params.push(`access_token=${c||jc.ACCESS_TOKEN||""}`);const d={url:Uf(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=hg(d,a=>{this.pendingRequest=null,f(a),this.saveEventData(),this.processRequests(c)})}getSessionAPI(b,c,a,d){this.skuToken=c,this.errorCb=d,jc.SESSION_PATH&&jc.API_URL&&(a||jc.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(new Error(lc)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||this.getSession(c,this.skuToken,b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b)}},pc=Va.getSessionAPI.bind(Va),Xf=new Set,Yf="mapbox-tiles";let Zf,$f,_f=500,ag=50;function bg(){s.caches&&!Zf&&(Zf=s.caches.open(Yf))}function cg(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let dg=1/0;const Wa={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Wa);class eg extends Error{constructor(a,b,c){401===b&&Rf(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const qc=hc()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,rc=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(qc())&&!/^\w+:/.test(c))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return(function(a,g){var c;const e=new s.AbortController,b=new s.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:qc(),signal:e.signal});let h=!1,i=!1;const f=(c=b.url).indexOf("sku=")>0&&Rf(c);"json"===a.type&&b.headers.set("Accept","application/json");const d=(c,d,e)=>{if(i)return;if(c&&"SecurityError"!==c.message&&gc(c),d&&e)return j(d);const h=Date.now();s.fetch(b).then(b=>{if(b.ok){const c=f?b.clone():null;return j(b,c,h)}return g(new eg(b.statusText,b.status,a.url))}).catch(a=>{20!==a.code&&g(new Error(a.message))})},j=(c,d,e)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{i||(d&&e&&(function(e,a,c){if(bg(),!Zf)return;const d={status:a.status,statusText:a.statusText,headers:new s.Headers};a.headers.forEach((a,b)=>d.headers.set(b,a));const b=Gf(a.headers.get("Cache-Control")||"");b["no-store"]||(b["max-age"]&&d.headers.set("Expires",new Date(c+1e3*b["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||(function(a,b){if(void 0===$f)try{new Response(new ReadableStream),$f=!0}catch(c){$f=!1}$f?b(a.body):a.blob().then(b)})(a,a=>{const b=new s.Response(a,d);bg(),Zf&&Zf.then(a=>a.put(cg(e.url),b)).catch(a=>gc(a.message))}))})(b,d,e),h=!0,g(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{i||g(new Error(a.message))})};return f?(function(b,a){if(bg(),!Zf)return a(null);const c=cg(b.url);Zf.then(b=>{b.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=Gf(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);b.delete(c),e&&b.put(c,d.clone()),a(null,d,e)}).catch(a)}).catch(a)})(b,d):d(null,null),{cancel:()=>{i=!0,h||e.abort()}}})(a,b);if(hc()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return(function(b,d){const a=new s.XMLHttpRequest;for(const c in a.open(b.method||"GET",b.url,!0),"arrayBuffer"===b.type&&(a.responseType="arraybuffer"),b.headers)a.setRequestHeader(c,b.headers[c]);return"json"===b.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===b.credentials,a.onerror=()=>{d(new Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let c=a.response;if("json"===b.type)try{c=JSON.parse(a.response)}catch(e){return d(e)}d(null,c,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else d(new eg(a.statusText,a.status,b.url))},a.send(b.body),{cancel:()=>a.abort()}})(a,b)},fg=function(a,b){return rc(_b(a,{type:"arrayBuffer"}),b)},gg=function(a,b){return rc(_b(a,{method:"POST"}),b)},hg=function(a,b){return rc(_b(a,{method:"GET"}),b)};function ig(b){const a=s.document.createElement("a");return a.href=b,a.protocol===s.document.location.protocol&&a.host===s.document.location.host}const jg="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let sc,tc;sc=[],tc=0;const uc=function(a,c){if(kc.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),tc>=jc.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:a,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return sc.push(b),b}tc++;let d=!1;const e=()=>{if(!d)for(d=!0,tc--;sc.length&&tc{e(),b?c(b):a&&(s.createImageBitmap?(function(a,c){const b=new s.Blob([new Uint8Array(a)],{type:"image/png"});s.createImageBitmap(b).then(a=>{c(null,a)}).catch(a=>{c(new Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})})(a,(a,b)=>c(a,b,d,f)):(function(b,e){const a=new s.Image,c=s.URL;a.onload=()=>{e(null,a),c.revokeObjectURL(a.src),a.onload=null,s.requestAnimationFrame(()=>{a.src=jg})},a.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const d=new s.Blob([new Uint8Array(b)],{type:"image/png"});a.src=b.byteLength?c.createObjectURL(d):jg})(a,(a,b)=>c(a,b,d,f)))});return{cancel:()=>{f.cancel(),e()}}};function kg(a,c,b){b[a]&& -1!==b[a].indexOf(c)||(b[a]=b[a]||[],b[a].push(c))}function lg(b,d,a){if(a&&a[b]){const c=a[b].indexOf(d);-1!==c&&a[b].splice(c,1)}}class Xa{constructor(a,b={}){_b(this,b),this.type=a}}class vc extends Xa{constructor(a,b={}){super("error",_b({error:a},b))}}class S{on(a,b){return this._listeners=this._listeners||{},kg(a,b,this._listeners),this}off(a,b){return lg(a,b,this._listeners),lg(a,b,this._oneTimeListeners),this}once(b,a){return a?(this._oneTimeListeners=this._oneTimeListeners||{},kg(b,a,this._oneTimeListeners),this):new Promise(a=>this.once(b,a))}fire(a,e){"string"==typeof a&&(a=new Xa(a,e||{}));const b=a.type;if(this.listens(b)){a.target=this;const f=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const g of f)g.call(this,a);const h=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const c of h)lg(b,c,this._oneTimeListeners),c.call(this,a);const d=this._eventedParent;d&&(_b(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(a))}else a instanceof vc&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var b=JSON.parse("{\"$version\":8,\"$root\":{\"version\":{\"required\":true,\"type\":\"enum\",\"values\":[8]},\"name\":{\"type\":\"string\"},\"metadata\":{\"type\":\"*\"},\"center\":{\"type\":\"array\",\"value\":\"number\"},\"zoom\":{\"type\":\"number\"},\"bearing\":{\"type\":\"number\",\"default\":0,\"period\":360,\"units\":\"degrees\"},\"pitch\":{\"type\":\"number\",\"default\":0,\"units\":\"degrees\"},\"light\":{\"type\":\"light\"},\"terrain\":{\"type\":\"terrain\"},\"fog\":{\"type\":\"fog\"},\"sources\":{\"required\":true,\"type\":\"sources\"},\"sprite\":{\"type\":\"string\"},\"glyphs\":{\"type\":\"string\"},\"transition\":{\"type\":\"transition\"},\"projection\":{\"type\":\"projection\"},\"layers\":{\"required\":true,\"type\":\"array\",\"value\":\"layer\"}},\"sources\":{\"*\":{\"type\":\"source\"}},\"source\":[\"source_vector\",\"source_raster\",\"source_raster_dem\",\"source_geojson\",\"source_video\",\"source_image\"],\"source_vector\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"vector\":{}}},\"url\":{\"type\":\"string\"},\"tiles\":{\"type\":\"array\",\"value\":\"string\"},\"bounds\":{\"type\":\"array\",\"value\":\"number\",\"length\":4,\"default\":[-180,-85.051129,180,85.051129]},\"scheme\":{\"type\":\"enum\",\"values\":{\"xyz\":{},\"tms\":{}},\"default\":\"xyz\"},\"minzoom\":{\"type\":\"number\",\"default\":0},\"maxzoom\":{\"type\":\"number\",\"default\":22},\"attribution\":{\"type\":\"string\"},\"promoteId\":{\"type\":\"promoteId\"},\"volatile\":{\"type\":\"boolean\",\"default\":false},\"*\":{\"type\":\"*\"}},\"source_raster\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"raster\":{}}},\"url\":{\"type\":\"string\"},\"tiles\":{\"type\":\"array\",\"value\":\"string\"},\"bounds\":{\"type\":\"array\",\"value\":\"number\",\"length\":4,\"default\":[-180,-85.051129,180,85.051129]},\"minzoom\":{\"type\":\"number\",\"default\":0},\"maxzoom\":{\"type\":\"number\",\"default\":22},\"tileSize\":{\"type\":\"number\",\"default\":512,\"units\":\"pixels\"},\"scheme\":{\"type\":\"enum\",\"values\":{\"xyz\":{},\"tms\":{}},\"default\":\"xyz\"},\"attribution\":{\"type\":\"string\"},\"volatile\":{\"type\":\"boolean\",\"default\":false},\"*\":{\"type\":\"*\"}},\"source_raster_dem\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"raster-dem\":{}}},\"url\":{\"type\":\"string\"},\"tiles\":{\"type\":\"array\",\"value\":\"string\"},\"bounds\":{\"type\":\"array\",\"value\":\"number\",\"length\":4,\"default\":[-180,-85.051129,180,85.051129]},\"minzoom\":{\"type\":\"number\",\"default\":0},\"maxzoom\":{\"type\":\"number\",\"default\":22},\"tileSize\":{\"type\":\"number\",\"default\":512,\"units\":\"pixels\"},\"attribution\":{\"type\":\"string\"},\"encoding\":{\"type\":\"enum\",\"values\":{\"terrarium\":{},\"mapbox\":{}},\"default\":\"mapbox\"},\"volatile\":{\"type\":\"boolean\",\"default\":false},\"*\":{\"type\":\"*\"}},\"source_geojson\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"geojson\":{}}},\"data\":{\"type\":\"*\"},\"maxzoom\":{\"type\":\"number\",\"default\":18},\"attribution\":{\"type\":\"string\"},\"buffer\":{\"type\":\"number\",\"default\":128,\"maximum\":512,\"minimum\":0},\"filter\":{\"type\":\"*\"},\"tolerance\":{\"type\":\"number\",\"default\":0.375},\"cluster\":{\"type\":\"boolean\",\"default\":false},\"clusterRadius\":{\"type\":\"number\",\"default\":50,\"minimum\":0},\"clusterMaxZoom\":{\"type\":\"number\"},\"clusterMinPoints\":{\"type\":\"number\"},\"clusterProperties\":{\"type\":\"*\"},\"lineMetrics\":{\"type\":\"boolean\",\"default\":false},\"generateId\":{\"type\":\"boolean\",\"default\":false},\"promoteId\":{\"type\":\"promoteId\"}},\"source_video\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"video\":{}}},\"urls\":{\"required\":true,\"type\":\"array\",\"value\":\"string\"},\"coordinates\":{\"required\":true,\"type\":\"array\",\"length\":4,\"value\":{\"type\":\"array\",\"length\":2,\"value\":\"number\"}}},\"source_image\":{\"type\":{\"required\":true,\"type\":\"enum\",\"values\":{\"image\":{}}},\"url\":{\"required\":true,\"type\":\"string\"},\"coordinates\":{\"required\":true,\"type\":\"array\",\"length\":4,\"value\":{\"type\":\"array\",\"length\":2,\"value\":\"number\"}}},\"layer\":{\"id\":{\"type\":\"string\",\"required\":true},\"type\":{\"type\":\"enum\",\"values\":{\"fill\":{},\"line\":{},\"symbol\":{},\"circle\":{},\"heatmap\":{},\"fill-extrusion\":{},\"raster\":{},\"hillshade\":{},\"background\":{},\"sky\":{}},\"required\":true},\"metadata\":{\"type\":\"*\"},\"source\":{\"type\":\"string\"},\"source-layer\":{\"type\":\"string\"},\"minzoom\":{\"type\":\"number\",\"minimum\":0,\"maximum\":24},\"maxzoom\":{\"type\":\"number\",\"minimum\":0,\"maximum\":24},\"filter\":{\"type\":\"filter\"},\"layout\":{\"type\":\"layout\"},\"paint\":{\"type\":\"paint\"}},\"layout\":[\"layout_fill\",\"layout_line\",\"layout_circle\",\"layout_heatmap\",\"layout_fill-extrusion\",\"layout_symbol\",\"layout_raster\",\"layout_hillshade\",\"layout_background\",\"layout_sky\"],\"layout_background\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_sky\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_fill\":{\"fill-sort-key\":{\"type\":\"number\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_circle\":{\"circle-sort-key\":{\"type\":\"number\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_heatmap\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_fill-extrusion\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_line\":{\"line-cap\":{\"type\":\"enum\",\"values\":{\"butt\":{},\"round\":{},\"square\":{}},\"default\":\"butt\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"line-join\":{\"type\":\"enum\",\"values\":{\"bevel\":{},\"round\":{},\"miter\":{}},\"default\":\"miter\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"line-miter-limit\":{\"type\":\"number\",\"default\":2,\"requires\":[{\"line-join\":\"miter\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-round-limit\":{\"type\":\"number\",\"default\":1.05,\"requires\":[{\"line-join\":\"round\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-sort-key\":{\"type\":\"number\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_symbol\":{\"symbol-placement\":{\"type\":\"enum\",\"values\":{\"point\":{},\"line\":{},\"line-center\":{}},\"default\":\"point\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"symbol-spacing\":{\"type\":\"number\",\"default\":250,\"minimum\":1,\"units\":\"pixels\",\"requires\":[{\"symbol-placement\":\"line\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"symbol-avoid-edges\":{\"type\":\"boolean\",\"default\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"symbol-sort-key\":{\"type\":\"number\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"symbol-z-order\":{\"type\":\"enum\",\"values\":{\"auto\":{},\"viewport-y\":{},\"source\":{}},\"default\":\"auto\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-allow-overlap\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-ignore-placement\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-optional\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"icon-image\",\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-rotation-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{},\"auto\":{}},\"default\":\"auto\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-size\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"units\":\"factor of the original icon size\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-text-fit\":{\"type\":\"enum\",\"values\":{\"none\":{},\"width\":{},\"height\":{},\"both\":{}},\"default\":\"none\",\"requires\":[\"icon-image\",\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-text-fit-padding\":{\"type\":\"array\",\"value\":\"number\",\"length\":4,\"default\":[0,0,0,0],\"units\":\"pixels\",\"requires\":[\"icon-image\",\"text-field\",{\"icon-text-fit\":[\"both\",\"width\",\"height\"]}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-image\":{\"type\":\"resolvedImage\",\"tokens\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-rotate\":{\"type\":\"number\",\"default\":0,\"period\":360,\"units\":\"degrees\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-padding\":{\"type\":\"number\",\"default\":2,\"minimum\":0,\"units\":\"pixels\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-keep-upright\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"icon-image\",{\"icon-rotation-alignment\":\"map\"},{\"symbol-placement\":[\"line\",\"line-center\"]}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-offset\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-anchor\":{\"type\":\"enum\",\"values\":{\"center\":{},\"left\":{},\"right\":{},\"top\":{},\"bottom\":{},\"top-left\":{},\"top-right\":{},\"bottom-left\":{},\"bottom-right\":{}},\"default\":\"center\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"icon-pitch-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{},\"auto\":{}},\"default\":\"auto\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-pitch-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{},\"auto\":{}},\"default\":\"auto\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-rotation-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{},\"auto\":{}},\"default\":\"auto\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-field\":{\"type\":\"formatted\",\"default\":\"\",\"tokens\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-font\":{\"type\":\"array\",\"value\":\"string\",\"default\":[\"Open Sans Regular\",\"Arial Unicode MS Regular\"],\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-size\":{\"type\":\"number\",\"default\":16,\"minimum\":0,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-max-width\":{\"type\":\"number\",\"default\":10,\"minimum\":0,\"units\":\"ems\",\"requires\":[\"text-field\",{\"symbol-placement\":[\"point\"]}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-line-height\":{\"type\":\"number\",\"default\":1.2,\"units\":\"ems\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-letter-spacing\":{\"type\":\"number\",\"default\":0,\"units\":\"ems\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-justify\":{\"type\":\"enum\",\"values\":{\"auto\":{},\"left\":{},\"center\":{},\"right\":{}},\"default\":\"center\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-radial-offset\":{\"type\":\"number\",\"units\":\"ems\",\"default\":0,\"requires\":[\"text-field\"],\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]}},\"text-variable-anchor\":{\"type\":\"array\",\"value\":\"enum\",\"values\":{\"center\":{},\"left\":{},\"right\":{},\"top\":{},\"bottom\":{},\"top-left\":{},\"top-right\":{},\"bottom-left\":{},\"bottom-right\":{}},\"requires\":[\"text-field\",{\"symbol-placement\":[\"point\"]}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-anchor\":{\"type\":\"enum\",\"values\":{\"center\":{},\"left\":{},\"right\":{},\"top\":{},\"bottom\":{},\"top-left\":{},\"top-right\":{},\"bottom-left\":{},\"bottom-right\":{}},\"default\":\"center\",\"requires\":[\"text-field\",{\"!\":\"text-variable-anchor\"}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-max-angle\":{\"type\":\"number\",\"default\":45,\"units\":\"degrees\",\"requires\":[\"text-field\",{\"symbol-placement\":[\"line\",\"line-center\"]}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-writing-mode\":{\"type\":\"array\",\"value\":\"enum\",\"values\":{\"horizontal\":{},\"vertical\":{}},\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-rotate\":{\"type\":\"number\",\"default\":0,\"period\":360,\"units\":\"degrees\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-padding\":{\"type\":\"number\",\"default\":2,\"minimum\":0,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-keep-upright\":{\"type\":\"boolean\",\"default\":true,\"requires\":[\"text-field\",{\"text-rotation-alignment\":\"map\"},{\"symbol-placement\":[\"line\",\"line-center\"]}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-transform\":{\"type\":\"enum\",\"values\":{\"none\":{},\"uppercase\":{},\"lowercase\":{}},\"default\":\"none\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-offset\":{\"type\":\"array\",\"value\":\"number\",\"units\":\"ems\",\"length\":2,\"default\":[0,0],\"requires\":[\"text-field\",{\"!\":\"text-radial-offset\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"text-allow-overlap\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-ignore-placement\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-optional\":{\"type\":\"boolean\",\"default\":false,\"requires\":[\"text-field\",\"icon-image\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_raster\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"layout_hillshade\":{\"visibility\":{\"type\":\"enum\",\"values\":{\"visible\":{},\"none\":{}},\"default\":\"visible\",\"property-type\":\"constant\"}},\"filter\":{\"type\":\"array\",\"value\":\"*\"},\"filter_symbol\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\",\"pitch\",\"distance-from-center\"]}},\"filter_fill\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_line\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_circle\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_fill-extrusion\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_heatmap\":{\"type\":\"boolean\",\"default\":false,\"transition\":false,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]}},\"filter_operator\":{\"type\":\"enum\",\"values\":{\"==\":{},\"!=\":{},\">\":{},\">=\":{},\"<\":{},\"<=\":{},\"in\":{},\"!in\":{},\"all\":{},\"any\":{},\"none\":{},\"has\":{},\"!has\":{},\"within\":{}}},\"geometry_type\":{\"type\":\"enum\",\"values\":{\"Point\":{},\"LineString\":{},\"Polygon\":{}}},\"function\":{\"expression\":{\"type\":\"expression\"},\"stops\":{\"type\":\"array\",\"value\":\"function_stop\"},\"base\":{\"type\":\"number\",\"default\":1,\"minimum\":0},\"property\":{\"type\":\"string\",\"default\":\"$zoom\"},\"type\":{\"type\":\"enum\",\"values\":{\"identity\":{},\"exponential\":{},\"interval\":{},\"categorical\":{}},\"default\":\"exponential\"},\"colorSpace\":{\"type\":\"enum\",\"values\":{\"rgb\":{},\"lab\":{},\"hcl\":{}},\"default\":\"rgb\"},\"default\":{\"type\":\"*\",\"required\":false}},\"function_stop\":{\"type\":\"array\",\"minimum\":0,\"maximum\":24,\"value\":[\"number\",\"color\"],\"length\":2},\"expression\":{\"type\":\"array\",\"value\":\"*\",\"minimum\":1},\"fog\":{\"range\":{\"type\":\"array\",\"default\":[0.5,10],\"minimum\":-20,\"maximum\":20,\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"color\":{\"type\":\"color\",\"property-type\":\"data-constant\",\"default\":\"#ffffff\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"horizon-blend\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":0.1,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true}},\"light\":{\"anchor\":{\"type\":\"enum\",\"default\":\"viewport\",\"values\":{\"map\":{},\"viewport\":{}},\"property-type\":\"data-constant\",\"transition\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]}},\"position\":{\"type\":\"array\",\"default\":[1.15,210,30],\"length\":3,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"color\":{\"type\":\"color\",\"property-type\":\"data-constant\",\"default\":\"#ffffff\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"intensity\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":0.5,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true}},\"projection\":{\"name\":{\"type\":\"enum\",\"values\":{\"albers\":{},\"equalEarth\":{},\"equirectangular\":{},\"lambertConformalConic\":{},\"mercator\":{},\"naturalEarth\":{},\"winkelTripel\":{}},\"default\":\"mercator\",\"required\":true},\"center\":{\"type\":\"array\",\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":false,\"requires\":[{\"name\":[\"albers\",\"lambertConformalConic\"]}]},\"parallels\":{\"type\":\"array\",\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":false,\"requires\":[{\"name\":[\"albers\",\"lambertConformalConic\"]}]}},\"terrain\":{\"source\":{\"type\":\"string\",\"required\":true},\"exaggeration\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":1,\"minimum\":0,\"maximum\":1000,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true}},\"paint\":[\"paint_fill\",\"paint_line\",\"paint_circle\",\"paint_heatmap\",\"paint_fill-extrusion\",\"paint_symbol\",\"paint_raster\",\"paint_hillshade\",\"paint_background\",\"paint_sky\"],\"paint_fill\":{\"fill-antialias\":{\"type\":\"boolean\",\"default\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[{\"!\":\"fill-pattern\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-outline-color\":{\"type\":\"color\",\"transition\":true,\"requires\":[{\"!\":\"fill-pattern\"},{\"fill-antialias\":true}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"fill-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-pattern\":{\"type\":\"resolvedImage\",\"transition\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"cross-faded-data-driven\"}},\"paint_fill-extrusion\":{\"fill-extrusion-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[{\"!\":\"fill-extrusion-pattern\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"fill-extrusion-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-pattern\":{\"type\":\"resolvedImage\",\"transition\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"cross-faded-data-driven\"},\"fill-extrusion-height\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"units\":\"meters\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-base\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"units\":\"meters\",\"transition\":true,\"requires\":[\"fill-extrusion-height\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-vertical-gradient\":{\"type\":\"boolean\",\"default\":true,\"transition\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_line\":{\"line-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[{\"!\":\"line-pattern\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"line-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-width\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-gap-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-offset\":{\"type\":\"number\",\"default\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-dasharray\":{\"type\":\"array\",\"value\":\"number\",\"minimum\":0,\"transition\":true,\"units\":\"line widths\",\"requires\":[{\"!\":\"line-pattern\"}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"cross-faded-data-driven\"},\"line-pattern\":{\"type\":\"resolvedImage\",\"transition\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"cross-faded-data-driven\"},\"line-gradient\":{\"type\":\"color\",\"transition\":false,\"requires\":[{\"!\":\"line-pattern\"},{\"source\":\"geojson\",\"has\":{\"lineMetrics\":true}}],\"expression\":{\"interpolated\":true,\"parameters\":[\"line-progress\"]},\"property-type\":\"color-ramp\"}},\"paint_circle\":{\"circle-radius\":{\"type\":\"number\",\"default\":5,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-blur\":{\"type\":\"number\",\"default\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"circle-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-pitch-scale\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-pitch-alignment\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"viewport\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-stroke-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-stroke-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"circle-stroke-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"}},\"paint_heatmap\":{\"heatmap-radius\":{\"type\":\"number\",\"default\":30,\"minimum\":1,\"transition\":true,\"units\":\"pixels\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"heatmap-weight\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":false,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"heatmap-intensity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"heatmap-color\":{\"type\":\"color\",\"default\":[\"interpolate\",[\"linear\"],[\"heatmap-density\"],0,\"rgba(0, 0, 255, 0)\",0.1,\"royalblue\",0.3,\"cyan\",0.5,\"lime\",0.7,\"yellow\",1,\"red\"],\"transition\":false,\"expression\":{\"interpolated\":true,\"parameters\":[\"heatmap-density\"]},\"property-type\":\"color-ramp\"},\"heatmap-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_symbol\":{\"icon-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-halo-color\":{\"type\":\"color\",\"default\":\"rgba(0, 0, 0, 0)\",\"transition\":true,\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-halo-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-halo-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"icon-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"requires\":[\"icon-image\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"icon-image\",\"icon-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"overridable\":true,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-halo-color\":{\"type\":\"color\",\"default\":\"rgba(0, 0, 0, 0)\",\"transition\":true,\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-halo-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-halo-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"text-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"units\":\"pixels\",\"requires\":[\"text-field\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"map\",\"requires\":[\"text-field\",\"text-translate\"],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_raster\":{\"raster-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-hue-rotate\":{\"type\":\"number\",\"default\":0,\"period\":360,\"transition\":true,\"units\":\"degrees\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-brightness-min\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-brightness-max\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-saturation\":{\"type\":\"number\",\"default\":0,\"minimum\":-1,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-contrast\":{\"type\":\"number\",\"default\":0,\"minimum\":-1,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-resampling\":{\"type\":\"enum\",\"values\":{\"linear\":{},\"nearest\":{}},\"default\":\"linear\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-fade-duration\":{\"type\":\"number\",\"default\":300,\"minimum\":0,\"transition\":false,\"units\":\"milliseconds\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_hillshade\":{\"hillshade-illumination-direction\":{\"type\":\"number\",\"default\":335,\"minimum\":0,\"maximum\":359,\"transition\":false,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-illumination-anchor\":{\"type\":\"enum\",\"values\":{\"map\":{},\"viewport\":{}},\"default\":\"viewport\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-exaggeration\":{\"type\":\"number\",\"default\":0.5,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-shadow-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-highlight-color\":{\"type\":\"color\",\"default\":\"#FFFFFF\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-accent-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_background\":{\"background-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"requires\":[{\"!\":\"background-pattern\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"background-pattern\":{\"type\":\"resolvedImage\",\"transition\":true,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"cross-faded\"},\"background-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_sky\":{\"sky-type\":{\"type\":\"enum\",\"values\":{\"gradient\":{},\"atmosphere\":{}},\"default\":\"atmosphere\",\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-atmosphere-sun\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"units\":\"degrees\",\"minimum\":[0,0],\"maximum\":[360,180],\"transition\":false,\"requires\":[{\"sky-type\":\"atmosphere\"}],\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-atmosphere-sun-intensity\":{\"type\":\"number\",\"requires\":[{\"sky-type\":\"atmosphere\"}],\"default\":10,\"minimum\":0,\"maximum\":100,\"transition\":false,\"property-type\":\"data-constant\"},\"sky-gradient-center\":{\"type\":\"array\",\"requires\":[{\"sky-type\":\"gradient\"}],\"value\":\"number\",\"default\":[0,0],\"length\":2,\"units\":\"degrees\",\"minimum\":[0,0],\"maximum\":[360,180],\"transition\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-gradient-radius\":{\"type\":\"number\",\"requires\":[{\"sky-type\":\"gradient\"}],\"default\":90,\"minimum\":0,\"maximum\":180,\"transition\":false,\"expression\":{\"interpolated\":false,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-gradient\":{\"type\":\"color\",\"default\":[\"interpolate\",[\"linear\"],[\"sky-radial-progress\"],0.8,\"#87ceeb\",1,\"white\"],\"transition\":false,\"requires\":[{\"sky-type\":\"gradient\"}],\"expression\":{\"interpolated\":true,\"parameters\":[\"sky-radial-progress\"]},\"property-type\":\"color-ramp\"},\"sky-atmosphere-halo-color\":{\"type\":\"color\",\"default\":\"white\",\"transition\":false,\"requires\":[{\"sky-type\":\"atmosphere\"}],\"property-type\":\"data-constant\"},\"sky-atmosphere-color\":{\"type\":\"color\",\"default\":\"white\",\"transition\":false,\"requires\":[{\"sky-type\":\"atmosphere\"}],\"property-type\":\"data-constant\"},\"sky-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"transition\":{\"duration\":{\"type\":\"number\",\"default\":300,\"minimum\":0,\"units\":\"milliseconds\"},\"delay\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"units\":\"milliseconds\"}},\"property-type\":{\"data-driven\":{\"type\":\"property-type\"},\"cross-faded\":{\"type\":\"property-type\"},\"cross-faded-data-driven\":{\"type\":\"property-type\"},\"color-ramp\":{\"type\":\"property-type\"},\"data-constant\":{\"type\":\"property-type\"},\"constant\":{\"type\":\"property-type\"}},\"promoteId\":{\"*\":{\"type\":\"string\"}}}");class wc{constructor(b,a,d,c){this.message=(b?`${b}: `:"")+d,c&&(this.identifier=c),null!=a&&a.__line__&&(this.line=a.__line__)}}function xc(a){const b=a.value;return b?[new wc(a.key,b,"constants have been deprecated as of v8")]:[]}function yc(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}function mg(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function ng(a){if(Array.isArray(a))return a.map(ng);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=ng(a[c]);return b}return mg(a)}class og extends Error{constructor(b,a){super(a),this.message=a,this.key=b}}class pg{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new pg(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw new Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const zc={kind:"null"},f={kind:"number"},i={kind:"string"},h={kind:"boolean"},y={kind:"color"},K={kind:"object"},l={kind:"value"},Ac={kind:"collator"},Bc={kind:"formatted"},Cc={kind:"resolvedImage"};function z(a,b){return{kind:"array",itemType:a,N:b}}function qg(a){if("array"===a.kind){const b=qg(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const rg=[zc,f,i,h,y,Bc,K,z(l),Cc];function sg(b,a){if("error"===a.kind)return null;if("array"===b.kind){if("array"===a.kind&&(0===a.N&&"value"===a.itemType.kind||!sg(b.itemType,a.itemType))&&("number"!=typeof b.N||b.N===a.N))return null}else{if(b.kind===a.kind)return null;if("value"===b.kind){for(const c of rg)if(!sg(c,a))return null}}return`Expected ${qg(b)} but found ${qg(a)} instead.`}function tg(b,a){return a.some(a=>a.kind===b.kind)}function ug(b,a){return a.some(a=>"null"===a?null===b:"array"===a?Array.isArray(b):"object"===a?b&&!Array.isArray(b)&&"object"==typeof b:a===typeof b)}function ja(b){var a={exports:{}};return b(a,a.exports),a.exports}var vg=ja(function(b,a){var c={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(b,c,a){return a<0?a+=1:a>1&&(a-=1),6*a<1?b+(c-b)*a*6:2*a<1?c:3*a<2?b+(c-b)*(2/3-a)*6:b}try{a.parseCSSColor=function(q){var a,b=q.replace(/ /g,"").toLowerCase();if(b in c)return c[b].slice();if("#"===b[0])return 4===b.length?(a=parseInt(b.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===b.length&&(a=parseInt(b.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var j=b.indexOf("("),p=b.indexOf(")");if(-1!==j&&p+1===b.length){var r=b.substr(0,j),h=b.substr(j+1,p-(j+1)).split(","),k=1;switch(r){case"rgba":if(4!==h.length)return null;k=f(h.pop());case"rgb":return 3!==h.length?null:[e(h[0]),e(h[1]),e(h[2]),k];case"hsla":if(4!==h.length)return null;k=f(h.pop());case"hsl":if(3!==h.length)return null;var m=(parseFloat(h[0])%360+360)%360/360,n=f(h[1]),i=f(h[2]),l=i<=.5?i*(n+1):i+n-i*n,o=2*i-l;return[d(255*g(o,l,m+1/3)),d(255*g(o,l,m)),d(255*g(o,l,m-1/3)),k];default:return null}}return null}}catch(h){}});class m{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(b){if(!b)return;if(b instanceof m)return b;if("string"!=typeof b)return;const a=vg.parseCSSColor(b);return a?new m(a[0]/255*a[3],a[1]/255*a[3],a[2]/255*a[3],a[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:b,g:c,b:d,a:a}=this;return 0===a?[0,0,0,0]:[255*b/a,255*c/a,255*d/a,a]}}m.black=new m(0,0,0,1),m.white=new m(1,1,1,1),m.transparent=new m(0,0,0,0),m.red=new m(1,0,0,1),m.blue=new m(0,0,1,1);class wg{constructor(b,a,c){this.sensitivity=b?a?"variant":"case":a?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class xg{constructor(a,b,c,d,e){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=e}}class yg{constructor(a){this.sections=a}static fromString(a){return new yg([new xg(a,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof yg?a:yg.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const b=["format"];for(const a of this.sections){if(a.image){b.push(["image",a.image.name]);continue}b.push(a.text);const c={};a.fontStack&&(c["text-font"]=["literal",a.fontStack.split(",")]),a.scale&&(c["font-scale"]=a.scale),a.textColor&&(c["text-color"]=["rgba"].concat(a.textColor.toArray())),b.push(c)}return b}}class Dc{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new Dc({name:a,available:!1}):null}serialize(){return["image",this.name]}}function zg(b,c,d,a){return"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof d&&d>=0&&d<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[b,c,d,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[b,c,d,a]:[b,c,d]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ag(a){if(null===a)return!0;if("string"==typeof a)return!0;if("boolean"==typeof a)return!0;if("number"==typeof a)return!0;if(a instanceof m)return!0;if(a instanceof wg)return!0;if(a instanceof yg)return!0;if(a instanceof Dc)return!0;if(Array.isArray(a)){for(const b of a)if(!Ag(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!Ag(a[c]))return!1;return!0}return!1}function Bg(a){if(null===a)return zc;if("string"==typeof a)return i;if("boolean"==typeof a)return h;if("number"==typeof a)return f;if(a instanceof m)return y;if(a instanceof wg)return Ac;if(a instanceof yg)return Bc;if(a instanceof Dc)return Cc;if(Array.isArray(a)){const d=a.length;let b;for(const e of a){const c=Bg(e);if(b){if(b===c)continue;b=l;break}b=c}return z(b||l,d)}return K}function Cg(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof m||a instanceof yg||a instanceof Dc?a.toString():JSON.stringify(a)}class Ec{constructor(a,b){this.type=a,this.value=b}static parse(b,d){if(2!==b.length)return d.error(`'literal' expression requires exactly one argument, but found ${b.length-1} instead.`);if(!Ag(b[1]))return d.error("invalid value");const e=b[1];let c=Bg(e);const a=d.expectedType;return"array"===c.kind&&0===c.N&&a&&"array"===a.kind&&("number"!=typeof a.N||0===a.N)&&(c=a),new Ec(c,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof m?["rgba"].concat(this.value.toArray()):this.value instanceof yg?this.value.serialize():this.value}}class Dg{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const Eg={string:i,number:f,boolean:h,object:K};class L{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");let e,b=1;const g=a[0];if("array"===g){let f,h;if(a.length>2){const d=a[1];if("string"!=typeof d||!(d in Eg)||"object"===d)return c.error("The item type argument of \"array\" must be one of string, number, boolean",1);f=Eg[d],b++}else f=l;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return c.error("The length argument to \"array\" must be a positive integer literal",2);h=a[2],b++}e=z(f,h)}else e=Eg[g];const i=[];for(;ba.outputDefined())}serialize(){const a=this.type,c=[a.kind];if("array"===a.kind){const b=a.itemType;if("string"===b.kind||"number"===b.kind||"boolean"===b.kind){c.push(b.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&c.push(d)}}return c.concat(this.args.map(a=>a.serialize()))}}class Fc{constructor(a){this.type=Bc,this.sections=a}static parse(c,b){if(c.length<2)return b.error("Expected at least one argument.");const m=c[1];if(!Array.isArray(m)&&"object"==typeof m)return b.error("First argument must be an image or text section.");const d=[];let h=!1;for(let e=1;e<=c.length-1;++e){const a=c[e];if(h&&"object"==typeof a&&!Array.isArray(a)){h=!1;let n=null;if(a["font-scale"]&&!(n=b.parse(a["font-scale"],1,f)))return null;let o=null;if(a["text-font"]&&!(o=b.parse(a["text-font"],1,z(i))))return null;let p=null;if(a["text-color"]&&!(p=b.parse(a["text-color"],1,y)))return null;const j=d[d.length-1];j.scale=n,j.font=o,j.textColor=p}else{const k=b.parse(c[e],1,l);if(!k)return null;const g=k.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,d.push({content:k,scale:null,font:null,textColor:null})}}return new Fc(d)}evaluate(a){return new yg(this.sections.map(b=>{const c=b.content.evaluate(a);return Bg(c)===Cc?new xg("",c,null,null,null):new xg(Cg(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(b){for(const a of this.sections)b(a.content),a.scale&&b(a.scale),a.font&&b(a.font),a.textColor&&b(a.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const a of this.sections){c.push(a.content.serialize());const b={};a.scale&&(b["font-scale"]=a.scale.serialize()),a.font&&(b["text-font"]=a.font.serialize()),a.textColor&&(b["text-color"]=a.textColor.serialize()),c.push(b)}return c}}class Gc{constructor(a){this.type=Cc,this.input=a}static parse(b,a){if(2!==b.length)return a.error("Expected two arguments.");const c=a.parse(b[1],1,i);return c?new Gc(c):a.error("No image name provided.")}evaluate(a){const c=this.input.evaluate(a),b=Dc.fromString(c);return b&&a.availableImages&&(b.available=a.availableImages.indexOf(c)> -1),b}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Fg={"to-boolean":h,"to-color":y,"to-number":f,"to-string":i};class T{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");const d=a[0];if(("to-boolean"===d||"to-string"===d)&&2!==a.length)return c.error("Expected one argument.");const g=Fg[d],e=[];for(let b=1;b4?`Invalid rbga value ${JSON.stringify(a)}: expected an array containing either three or four numeric values.`:zg(a[0],a[1],a[2],a[3])))return new m(a[0]/255,a[1]/255,a[2]/255,a[3])}throw new Dg(c||`Could not parse color from value '${"string"==typeof a?a:String(JSON.stringify(a))}'`)}if("number"===this.type.kind){let d=null;for(const h of this.args){if(null===(d=h.evaluate(b)))return 0;const f=Number(d);if(!isNaN(f))return f}throw new Dg(`Could not convert ${JSON.stringify(d)} to number.`)}return"formatted"===this.type.kind?yg.fromString(Cg(this.args[0].evaluate(b))):"resolvedImage"===this.type.kind?Dc.fromString(Cg(this.args[0].evaluate(b))):Cg(this.args[0].evaluate(b))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Fc([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Gc(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const Gg=["Unknown","Point","LineString","Polygon"];class Hg{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Gg[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=m.parse(a)),b}}class Ya{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(f,c){const j=f[0],b=Ya.definitions[j];if(!b)return c.error(`Unknown expression "${j}". If you wanted a literal array, use ["literal", [...]].`,0);const q=Array.isArray(b)?b[0]:b.type,m=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,h=m.filter(([a])=>!Array.isArray(a)||a.length===f.length-1);let e=null;for(const[a,r]of h){e=new $g(c.registry,c.path,null,c.scope);const d=[];let n=!1;for(let i=1;i{var a;return a=b,Array.isArray(a)?`(${a.map(qg).join(", ")})`:`(${qg(a.type)}...)`}).join(" | "),k=[];for(let l=1;l=b[2]||a[1]<=b[1]||a[3]>=b[3])}function Kg(a,c){const d=(180+a[0])/360,e=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,b=Math.pow(2,c.z);return[Math.round(d*b*8192),Math.round(e*b*8192)]}function Lg(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function Mg(h,i){var d,b,e;let f=!1;for(let g=0,j=i.length;g(d=h)[1]!=(e=c[a+1])[1]>d[1]&&d[0]<(e[0]-b[0])*(d[1]-b[1])/(e[1]-b[1])+b[0]&&(f=!f)}}return f}function Ng(c,b){for(let a=0;a0&&h<0||g<0&&h>0}function Pg(i,j,k){var a,b,c,d,g,h;for(const f of k)for(let e=0;eb[2]){const d=.5*c;let e=a[0]-b[0]>d?-c:b[0]-a[0]>d?c:0;0===e&&(e=a[0]-b[2]>d?-c:b[2]-a[0]>d?c:0),a[0]+=e}Ig(f,a)}function Vg(f,g,h,a){const i=8192*Math.pow(2,a.z),b=[8192*a.x,8192*a.y],c=[];for(const j of f)for(const d of j){const e=[d.x+b[0],d.y+b[1]];Ug(e,g,h,i),c.push(e)}return c}function Wg(j,a,k,c){var b;const e=8192*Math.pow(2,c.z),f=[8192*c.x,8192*c.y],d=[];for(const l of j){const g=[];for(const h of l){const i=[h.x+f[0],h.y+f[1]];Ig(a,i),g.push(i)}d.push(g)}if(a[2]-a[0]<=e/2)for(const m of((b=a)[0]=b[1]=1/0,b[2]=b[3]=-1/0,d))for(const n of m)Ug(n,a,k,e);return d}class Ic{constructor(a,b){this.type=h,this.geojson=a,this.geometries=b}static parse(b,d){if(2!==b.length)return d.error(`'within' expression requires exactly one argument, but found ${b.length-1} instead.`);if(Ag(b[1])){const a=b[1];if("FeatureCollection"===a.type)for(let c=0;c{b&&!Xg(a)&&(b=!1)}),b}function Yg(a){if(a instanceof Ya&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!Yg(a)&&(b=!1)}),b}function Zg(a,b){if(a instanceof Ya&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!Zg(a,b)&&(c=!1)}),c}class Jc{constructor(b,a){this.type=a.type,this.name=b,this.boundExpression=a}static parse(c,b){if(2!==c.length||"string"!=typeof c[1])return b.error("'var' expression requires exactly one string literal argument.");const a=c[1];return b.scope.has(a)?new Jc(a,b.scope.get(a)):b.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class $g{constructor(b,a=[],c,d=new pg,e=[]){this.registry=b,this.path=a,this.key=a.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=e,this.expectedType=c}parse(a,b,d,e,c={}){return b?this.concat(b,d,e)._parse(a,c):this._parse(a,c)}_parse(a,f){function g(a,b,c){return"assert"===c?new L(b,[a]):"coerce"===c?new T(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error("Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].");const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[d];if(h){let b=h.parse(a,this);if(!b)return null;if(this.expectedType){const c=this.expectedType,e=b.type;if("string"!==c.kind&&"number"!==c.kind&&"boolean"!==c.kind&&"object"!==c.kind&&"array"!==c.kind||"value"!==e.kind)if("color"!==c.kind&&"formatted"!==c.kind&&"resolvedImage"!==c.kind||"value"!==e.kind&&"string"!==e.kind){if(this.checkSubtype(c,e))return null}else b=g(b,c,f.typeAnnotation||"coerce");else b=g(b,c,f.typeAnnotation||"assert")}if(!(b instanceof Ec)&&"resolvedImage"!==b.type.kind&&_g(b)){const i=new Hg;try{b=new Ec(b.type,b.evaluate(i))}catch(j){return this.error(j.message),null}}return b}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?"Bare objects invalid. Use [\"literal\", {...}] instead.":`Expected an array, but found ${typeof a} instead.`)}concat(a,c,b){const d="number"==typeof a?this.path.concat(a):this.path,e=b?this.scope.concat(b):this.scope;return new $g(this.registry,d,c||null,e,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new og(c,a))}checkSubtype(b,c){const a=sg(b,c);return a&&this.error(a),a}}function _g(a){if(a instanceof Jc)return _g(a.boundExpression);if(a instanceof Ya&&"error"===a.name)return!1;if(a instanceof Hc)return!1;if(a instanceof Ic)return!1;const c=a instanceof T||a instanceof L;let b=!0;return a.eachChild(a=>{b=c?b&&_g(a):b&&a instanceof Ec}),!!b&&Xg(a)&&Zg(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function ah(b,c){const g=b.length-1;let d,h,e=0,f=g,a=0;for(;e<=f;)if(d=b[a=Math.floor((e+f)/2)],h=b[a+1],d<=c){if(a===g||cc))throw new Dg("Input is not a number.");f=a-1}return 0}class Kc{constructor(a,b,c){for(const[d,e]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(e)}static parse(b,a){if(b.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if((b.length-1)%2!=0)return a.error("Expected an even number of arguments.");const i=a.parse(b[1],1,f);if(!i)return null;const d=[];let e=null;a.expectedType&&"value"!==a.expectedType.kind&&(e=a.expectedType);for(let c=1;c=g)return a.error("Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.",j);const h=a.parse(k,l,e);if(!h)return null;e=e||h.type,d.push([g,h])}return new Kc(e,i,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const e=b.length;return d>=b[e-1]?c[e-1].evaluate(a):c[ah(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const b=["step",this.input.serialize()];for(let a=0;a0&&b.push(this.labels[a]),b.push(this.outputs[a].serialize());return b}}function Za(b,c,a){return b*(1-a)+c*a}var bh=Object.freeze({__proto__:null,number:Za,color:function(a,b,c){return new m(Za(a.r,b.r,c),Za(a.g,b.g,c),Za(a.b,b.b,c),Za(a.a,b.a,c))},array:function(a,b,c){return a.map((a,d)=>Za(a,b[d],c))}});const ch=4/29,$a=6/29,dh=3*$a*$a,eh=Math.PI/180,fh=180/Math.PI;function gh(a){return a>.008856451679035631?Math.pow(a,1/3):a/dh+ch}function hh(a){return a>$a?a*a*a:dh*(a-ch)}function ih(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function jh(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function Lc(a){const b=jh(a.r),c=jh(a.g),d=jh(a.b),f=gh((.4124564*b+.3575761*c+.1804375*d)/.95047),e=gh((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*e-16,a:500*(f-e),b:200*(e-gh((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function Mc(b){let a=(b.l+16)/116,c=isNaN(b.a)?a:a+b.a/500,d=isNaN(b.b)?a:a-b.b/200;return a=1*hh(a),c=.95047*hh(c),d=1.08883*hh(d),new m(ih(3.2404542*c-1.5371385*a-.4985314*d),ih(-0.969266*c+1.8760108*a+.041556*d),ih(.0556434*c-.2040259*a+1.0572252*d),b.alpha)}const Nc={forward:Lc,reverse:Mc,interpolate:function(a,b,c){return{l:Za(a.l,b.l,c),a:Za(a.a,b.a,c),b:Za(a.b,b.b,c),alpha:Za(a.alpha,b.alpha,c)}}},Oc={forward:function(d){const{l:e,a:a,b:b}=Lc(d),c=Math.atan2(b,a)*fh;return{h:c<0?c+360:c,c:Math.sqrt(a*a+b*b),l:e,alpha:d.a}},reverse:function(a){const b=a.h*eh,c=a.c;return Mc({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){return{h:(function(b,c,d){const a=c-b;return b+d*(a>180||a< -180?a-360*Math.round(a/360):a)})(a.h,b.h,c),c:Za(a.c,b.c,c),l:Za(a.l,b.l,c),alpha:Za(a.alpha,b.alpha,c)}}};var kh=Object.freeze({__proto__:null,lab:Nc,hcl:Oc});class ka{constructor(a,b,c,d,e){for(const[f,g]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],e))this.labels.push(f),this.outputs.push(g)}static interpolationFactor(a,d,e,f){let b=0;if("exponential"===a.name)b=lh(d,a.base,e,f);else if("linear"===a.name)b=lh(d,1,e,f);else if("cubic-bezier"===a.name){const c=a.controlPoints;b=new sf(c[0],c[1],c[2],c[3]).solve(lh(d,1,e,f))}return b}static parse(g,a){let[h,b,i,...j]=g;if(!Array.isArray(b)||0===b.length)return a.error("Expected an interpolation type expression.",1);if("linear"===b[0])b={name:"linear"};else if("exponential"===b[0]){const n=b[1];if("number"!=typeof n)return a.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:n}}else{if("cubic-bezier"!==b[0])return a.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const k=b.slice(1);if(4!==k.length||k.some(a=>"number"!=typeof a||a<0||a>1))return a.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:k}}}if(g.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${g.length-1}.`);if((g.length-1)%2!=0)return a.error("Expected an even number of arguments.");if(!(i=a.parse(i,2,f)))return null;const e=[];let c=null;"interpolate-hcl"===h||"interpolate-lab"===h?c=y:a.expectedType&&"value"!==a.expectedType.kind&&(c=a.expectedType);for(let d=0;d=l)return a.error("Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.",o);const m=a.parse(p,q,c);if(!m)return null;c=c||m.type,e.push([l,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new ka(c,h,b,i,e):a.error(`Type ${qg(c)} is not interpolatable.`)}evaluate(b){const a=this.labels,c=this.outputs;if(1===a.length)return c[0].evaluate(b);const d=this.input.evaluate(b);if(d<=a[0])return c[0].evaluate(b);const i=a.length;if(d>=a[i-1])return c[i-1].evaluate(b);const e=ah(a,d),f=ka.interpolationFactor(this.interpolation,d,a[e],a[e+1]),g=c[e].evaluate(b),h=c[e+1].evaluate(b);return"interpolate"===this.operator?bh[this.type.kind.toLowerCase()](g,h,f):"interpolate-hcl"===this.operator?Oc.reverse(Oc.interpolate(Oc.forward(g),Oc.forward(h),f)):Nc.reverse(Nc.interpolate(Nc.forward(g),Nc.forward(h),f))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let b;b="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const c=[this.operator,b,this.input.serialize()];for(let a=0;asg(b,a.type));return new Pc(h?l:a,c)}evaluate(d){let b,a=null,c=0;for(const e of this.args){if(c++,(a=e.evaluate(d))&&a instanceof Dc&&!a.available&&(b||(b=a),a=null,c===this.args.length))return b;if(null!==a)break}return a}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class Qc{constructor(b,a){this.type=a.type,this.bindings=[].concat(b),this.result=a}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,c){if(a.length<4)return c.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const e=[];for(let b=1;b=b.length)throw new Dg(`Array index out of bounds: ${a} > ${b.length-1}.`);if(a!==Math.floor(a))throw new Dg(`Array index must be an integer, but found ${a} instead.`);return b[a]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Sc{constructor(a,b){this.type=h,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);return c&&d?tg(c.type,[h,i,f,zc,l])?new Sc(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${qg(c.type)} instead`):null}evaluate(c){const b=this.needle.evaluate(c),a=this.haystack.evaluate(c);if(!a)return!1;if(!ug(b,["boolean","string","number","null"]))throw new Dg(`Expected first argument to be of type boolean, string, number or null, but found ${qg(Bg(b))} instead.`);if(!ug(a,["string","array"]))throw new Dg(`Expected second argument to be of type array or string, but found ${qg(Bg(a))} instead.`);return a.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Tc{constructor(a,b,c){this.type=f,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);if(!c||!d)return null;if(!tg(c.type,[h,i,f,zc,l]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${qg(c.type)} instead`);if(4===a.length){const e=b.parse(a[3],3,f);return e?new Tc(c,d,e):null}return new Tc(c,d)}evaluate(c){const a=this.needle.evaluate(c),b=this.haystack.evaluate(c);if(!ug(a,["boolean","string","number","null"]))throw new Dg(`Expected first argument to be of type boolean, string, number or null, but found ${qg(Bg(a))} instead.`);if(!ug(b,["string","array"]))throw new Dg(`Expected second argument to be of type array or string, but found ${qg(Bg(b))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(c);return b.indexOf(a,d)}return b.indexOf(a)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Uc{constructor(a,b,c,d,e,f){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=e,this.otherwise=f}static parse(b,c){if(b.length<5)return c.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if(b.length%2!=1)return c.error("Expected an even number of arguments.");let g,d;c.expectedType&&"value"!==c.expectedType.kind&&(d=c.expectedType);const j={},k=[];for(let e=2;eNumber.MAX_SAFE_INTEGER)return f.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof a&&Math.floor(a)!==a)return f.error("Numeric branch labels must be integer values.");if(g){if(f.checkSubtype(g,Bg(a)))return null}else g=Bg(a);if(void 0!==j[String(a)])return f.error("Branch labels must be unique.");j[String(a)]=k.length}const m=c.parse(o,e,d);if(!m)return null;d=d||m.type,k.push(m)}const i=c.parse(b[1],1,l);if(!i)return null;const n=c.parse(b[b.length-1],b.length-1,d);return n?"value"!==i.type.kind&&c.concat(1).checkSubtype(g,i.type)?null:new Uc(g,d,i,j,k,n):null}evaluate(a){const b=this.input.evaluate(a);return(Bg(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const b=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),c=[],e={};for(const a of h){const f=e[this.cases[a]];void 0===f?(e[this.cases[a]]=c.length,c.push([this.cases[a],[a]])):c[f][1].push(a)}const g=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,d]of c)b.push(1===d.length?g(d[0]):d.map(g)),b.push(this.outputs[i].serialize());return b.push(this.otherwise.serialize()),b}}class Vc{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const f=[];for(let d=1;da.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class Wc{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,c){if(a.length<=2||a.length>=5)return c.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const b=c.parse(a[1],1,l),d=c.parse(a[2],2,f);if(!b||!d)return null;if(!tg(b.type,[z(l),i,l]))return c.error(`Expected first argument to be of type array or string, but found ${qg(b.type)} instead`);if(4===a.length){const e=c.parse(a[3],3,f);return e?new Wc(b.type,b,d,e):null}return new Wc(b.type,b,d)}evaluate(b){const a=this.input.evaluate(b),c=this.beginIndex.evaluate(b);if(!ug(a,["string","array"]))throw new Dg(`Expected first argument to be of type array or string, but found ${qg(Bg(a))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(b);return a.slice(c,d)}return a.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function mh(b,a){return"=="===b||"!="===b?"boolean"===a.kind||"string"===a.kind||"number"===a.kind||"null"===a.kind||"value"===a.kind:"string"===a.kind||"number"===a.kind||"value"===a.kind}function Xc(d,a,b,c){return 0===c.compare(a,b)}function A(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(a,b,c){this.type=h,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(f,c){if(3!==f.length&&4!==f.length)return c.error("Expected two or three arguments.");const g=f[0];let a=c.parse(f[1],1,l);if(!a)return null;if(!mh(g,a.type))return c.concat(1).error(`"${g}" comparisons are not supported for type '${qg(a.type)}'.`);let b=c.parse(f[2],2,l);if(!b)return null;if(!mh(g,b.type))return c.concat(2).error(`"${g}" comparisons are not supported for type '${qg(b.type)}'.`);if(a.type.kind!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error(`Cannot compare types '${qg(a.type)}' and '${qg(b.type)}'.`);d&&("value"===a.type.kind&&"value"!==b.type.kind?a=new L(b.type,[a]):"value"!==a.type.kind&&"value"===b.type.kind&&(b=new L(a.type,[b])));let h=null;if(4===f.length){if("string"!==a.type.kind&&"string"!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error("Cannot use collator to compare non-string types.");if(!(h=c.parse(f[3],3,Ac)))return null}return new e(a,b,h)}evaluate(e){const f=this.lhs.evaluate(e),g=this.rhs.evaluate(e);if(d&&this.hasUntypedArgument){const h=Bg(f),i=Bg(g);if(h.kind!==i.kind||"string"!==h.kind&&"number"!==h.kind)throw new Dg(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${h.kind}, ${i.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const j=Bg(f),k=Bg(g);if("string"!==j.kind||"string"!==k.kind)return b(e,f,g)}return this.collator?c(e,f,g,this.collator.evaluate(e)):b(e,f,g)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const Yc=A("==",function(c,a,b){return a===b},Xc),Zc=A("!=",function(c,a,b){return a!==b},function(d,a,b,c){return!Xc(0,a,b,c)}),$c=A("<",function(c,a,b){return ac.compare(a,b)}),_c=A(">",function(c,a,b){return a>b},function(d,a,b,c){return c.compare(a,b)>0}),ad=A("<=",function(c,a,b){return a<=b},function(d,a,b,c){return 0>=c.compare(a,b)}),bd=A(">=",function(c,a,b){return a>=b},function(d,a,b,c){return c.compare(a,b)>=0});class cd{constructor(a,b,c,d,e){this.type=i,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=e}static parse(c,b){if(3!==c.length)return b.error("Expected two arguments.");const d=b.parse(c[1],1,f);if(!d)return null;const a=c[2];if("object"!=typeof a||Array.isArray(a))return b.error("NumberFormat options argument must be an object.");let e=null;if(a.locale&&!(e=b.parse(a.locale,1,i)))return null;let g=null;if(a.currency&&!(g=b.parse(a.currency,1,i)))return null;let h=null;if(a["min-fraction-digits"]&&!(h=b.parse(a["min-fraction-digits"],1,f)))return null;let j=null;return!a["max-fraction-digits"]||(j=b.parse(a["max-fraction-digits"],1,f))?new cd(d,e,g,h,j):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a]}}class dd{constructor(a){this.type=f,this.input=a}static parse(b,c){if(2!==b.length)return c.error(`Expected 1 argument, but found ${b.length-1} instead.`);const a=c.parse(b[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?c.error(`Expected argument of type string or array, but found ${qg(a.type)} instead.`):new dd(a):null}evaluate(b){const a=this.input.evaluate(b);if("string"==typeof a)return a.length;if(Array.isArray(a))return a.length;throw new Dg(`Expected value to be of type string or array, but found ${qg(Bg(a))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const U={"==":Yc,"!=":Zc,">":_c,"<":$c,">=":bd,"<=":ad,array:L,at:Rc,boolean:L,case:Vc,coalesce:Pc,collator:Hc,format:Fc,image:Gc,in:Sc,"index-of":Tc,interpolate:ka,"interpolate-hcl":ka,"interpolate-lab":ka,length:dd,let:Qc,literal:Ec,match:Uc,number:L,"number-format":cd,object:L,slice:Wc,step:Kc,string:L,"to-boolean":T,"to-color":T,"to-number":T,"to-string":T,var:Jc,within:Ic};function _a(b,[c,d,e,f]){c=c.evaluate(b),d=d.evaluate(b),e=e.evaluate(b);const a=f?f.evaluate(b):1,g=zg(c,d,e,a);if(g)throw new Dg(g);return new m(c/255*a,d/255*a,e/255*a,a)}function nh(a,b){return a in b}function oh(b,c){const a=c[b];return void 0===a?null:a}function x(a){return{type:a}}function ph(a){return{result:"success",value:a}}function qh(a){return{result:"error",value:a}}function rh(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function sh(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function th(a){return!!a.expression&&a.expression.interpolated}function uh(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function vh(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function wh(a){return a}function xh(a,e){const r="color"===e.type,g=a.stops&&"object"==typeof a.stops[0][0],s=g||!(g|| void 0!==a.property),b=a.type||(th(e)?"exponential":"interval");if(r&&((a=yc({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],m.parse(a[1])])),a.default=m.parse(a.default?a.default:e.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!kh[a.colorSpace])throw new Error(`Unknown color space: ${a.colorSpace}`);let f,j,t;if("exponential"===b)f=Bh;else if("interval"===b)f=Ah;else if("categorical"===b){for(const k of(f=zh,j=Object.create(null),a.stops))j[k[0]]=k[1];t=typeof a.stops[0][0]}else{if("identity"!==b)throw new Error(`Unknown function type "${b}"`);f=Ch}if(g){const c={},l=[];for(let h=0;ha[0]),evaluate:({zoom:b},c)=>Bh({stops:n,base:a.base},e,b).evaluate(b,c)}}if(s){const q="exponential"===b?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:ka.interpolationFactor.bind(void 0,q),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:b})=>f(a,e,b,j,t)}}return{kind:"source",evaluate(d,b){const c=b&&b.properties?b.properties[a.property]:void 0;return void 0===c?yh(a.default,e.default):f(a,e,c,j,t)}}}function yh(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function zh(b,c,a,d,e){return yh(typeof a===e?d[a]:void 0,b.default,c.default)}function Ah(a,d,b){if("number"!==uh(b))return yh(a.default,d.default);const c=a.stops.length;if(1===c)return a.stops[0][1];if(b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[c-1][0])return a.stops[c-1][1];const e=ah(a.stops.map(a=>a[0]),b);return a.stops[e][1]}function Bh(a,e,b){const h=void 0!==a.base?a.base:1;if("number"!==uh(b))return yh(a.default,e.default);const d=a.stops.length;if(1===d)return a.stops[0][1];if(b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[d-1][0])return a.stops[d-1][1];const c=ah(a.stops.map(a=>a[0]),b),i=function(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}(b,h,a.stops[c][0],a.stops[c+1][0]),f=a.stops[c][1],j=a.stops[c+1][1];let g=bh[e.type]||wh;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=kh[a.colorSpace];g=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),i))}return"function"==typeof f.evaluate?{evaluate(...a){const b=f.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return g(b,c,i)}}:g(f,j,i)}function Ch(c,b,a){return"color"===b.type?a=m.parse(a):"formatted"===b.type?a=yg.fromString(a.toString()):"resolvedImage"===b.type?a=Dc.fromString(a.toString()):uh(a)===b.type||"enum"===b.type&&b.values[a]||(a=void 0),yh(a,c.default,b.default)}Ya.register(U,{error:[{kind:"error"},[i],(a,[b])=>{throw new Dg(b.evaluate(a))}],typeof:[i,[l],(a,[b])=>qg(Bg(b.evaluate(a)))],"to-rgba":[z(f,4),[y],(a,[b])=>b.evaluate(a).toArray()],rgb:[y,[f,f,f],_a],rgba:[y,[f,f,f,f],_a],has:{type:h,overloads:[[[i],(a,[b])=>nh(b.evaluate(a),a.properties())],[[i,K],(a,[b,c])=>nh(b.evaluate(a),c.evaluate(a))]]},get:{type:l,overloads:[[[i],(a,[b])=>oh(b.evaluate(a),a.properties())],[[i,K],(a,[b,c])=>oh(b.evaluate(a),c.evaluate(a))]]},"feature-state":[l,[i],(a,[b])=>oh(b.evaluate(a),a.featureState||{})],properties:[K,[],a=>a.properties()],"geometry-type":[i,[],a=>a.geometryType()],id:[l,[],a=>a.id()],zoom:[f,[],a=>a.globals.zoom],pitch:[f,[],a=>a.globals.pitch||0],"distance-from-center":[f,[],a=>a.distanceFromCenter()],"heatmap-density":[f,[],a=>a.globals.heatmapDensity||0],"line-progress":[f,[],a=>a.globals.lineProgress||0],"sky-radial-progress":[f,[],a=>a.globals.skyRadialProgress||0],accumulated:[l,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated],"+":[f,x(f),(b,c)=>{let a=0;for(const d of c)a+=d.evaluate(b);return a}],"*":[f,x(f),(b,c)=>{let a=1;for(const d of c)a*=d.evaluate(b);return a}],"-":{type:f,overloads:[[[f,f],(a,[b,c])=>b.evaluate(a)-c.evaluate(a)],[[f],(a,[b])=>-b.evaluate(a)]]},"/":[f,[f,f],(a,[b,c])=>b.evaluate(a)/c.evaluate(a)],"%":[f,[f,f],(a,[b,c])=>b.evaluate(a)%c.evaluate(a)],ln2:[f,[],()=>Math.LN2],pi:[f,[],()=>Math.PI],e:[f,[],()=>Math.E],"^":[f,[f,f],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a))],sqrt:[f,[f],(a,[b])=>Math.sqrt(b.evaluate(a))],log10:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10],ln:[f,[f],(a,[b])=>Math.log(b.evaluate(a))],log2:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2],sin:[f,[f],(a,[b])=>Math.sin(b.evaluate(a))],cos:[f,[f],(a,[b])=>Math.cos(b.evaluate(a))],tan:[f,[f],(a,[b])=>Math.tan(b.evaluate(a))],asin:[f,[f],(a,[b])=>Math.asin(b.evaluate(a))],acos:[f,[f],(a,[b])=>Math.acos(b.evaluate(a))],atan:[f,[f],(a,[b])=>Math.atan(b.evaluate(a))],min:[f,x(f),(b,a)=>Math.min(...a.map(a=>a.evaluate(b)))],max:[f,x(f),(b,a)=>Math.max(...a.map(a=>a.evaluate(b)))],abs:[f,[f],(a,[b])=>Math.abs(b.evaluate(a))],round:[f,[f],(b,[c])=>{const a=c.evaluate(b);return a<0?-Math.round(-a):Math.round(a)}],floor:[f,[f],(a,[b])=>Math.floor(b.evaluate(a))],ceil:[f,[f],(a,[b])=>Math.ceil(b.evaluate(a))],"filter-==":[h,[i,l],(a,[b,c])=>a.properties()[b.value]===c.value],"filter-id-==":[h,[l],(a,[b])=>a.id()===b.value],"filter-type-==":[h,[i],(a,[b])=>a.geometryType()===b.value],"filter-<":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a{const a=c.id(),b=d.value;return typeof a==typeof b&&a":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>b}],"filter-id->":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>b}],"filter-<=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<=b}],"filter-id-<=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<=b}],"filter->=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>=b}],"filter-id->=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>=b}],"filter-has":[h,[l],(a,[b])=>b.value in a.properties()],"filter-has-id":[h,[],a=>null!==a.id()&& void 0!==a.id()],"filter-type-in":[h,[z(i)],(a,[b])=>b.value.indexOf(a.geometryType())>=0],"filter-id-in":[h,[z(l)],(a,[b])=>b.value.indexOf(a.id())>=0],"filter-in-small":[h,[i,z(l)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0],"filter-in-large":[h,[i,z(l)],(b,[c,a])=>(function(d,e,b,c){for(;b<=c;){const a=b+c>>1;if(e[a]===d)return!0;e[a]>d?c=a-1:b=a+1}return!1})(b.properties()[c.value],a.value,0,a.value.length-1)],all:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0}]]},any:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)||c.evaluate(a)],[x(h),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1}]]},"!":[h,[h],(a,[b])=>!b.evaluate(a)],"is-supported-script":[h,[i],(a,[c])=>{const b=a.globals&&a.globals.isSupportedScript;return!b||b(c.evaluate(a))}],upcase:[i,[i],(a,[b])=>b.evaluate(a).toUpperCase()],downcase:[i,[i],(a,[b])=>b.evaluate(a).toLowerCase()],concat:[i,x(l),(b,a)=>a.map(a=>Cg(a.evaluate(b))).join("")],"resolved-locale":[i,[Ac],(a,[b])=>b.evaluate(a).resolvedLocale()]});class ed{constructor(c,b){var a;this.expression=c,this._warningHistory={},this._evaluator=new Hg,this._defaultValue=b?"color"===(a=b).type&&vh(a.default)?new m(0,0,0,0):"color"===a.type?m.parse(a.default)||null:void 0===a.default?null:a.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,e,f,g,h){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=e||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=g||null,this._evaluator.featureDistanceData=h||null,this.expression.evaluate(this._evaluator)}evaluate(c,d,e,f,g,h,i,j){this._evaluator.globals=c,this._evaluator.feature=d||null,this._evaluator.featureState=e||null,this._evaluator.canonical=f,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=i||null,this._evaluator.featureDistanceData=j||null;try{const a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new Dg(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(a)} instead.`);return a}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,"undefined"!=typeof console&&console.warn(b.message)),this._defaultValue}}}function Dh(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in U}function fd(d,a){const b=new $g(U,[],a?function(a){const b={color:y,string:i,number:f,enum:i,boolean:h,formatted:Bc,resolvedImage:Cc};return"array"===a.type?z(b[a.value]||l,a.length):b[a.type]}(a):void 0),c=b.parse(d,void 0,void 0,void 0,a&&"string"===a.type?{typeAnnotation:"coerce"}:void 0);return c?ph(new ed(c,a)):qh(b.errors)}class gd{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!Yg(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}}class hd{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!Yg(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}interpolationFactor(a,b,c){return this.interpolationType?ka.interpolationFactor(this.interpolationType,a,b,c):0}}function Eh(b,c){if("error"===(b=fd(b,c)).result)return b;const d=b.value.expression,e=Xg(d);if(!e&&!rh(c))return qh([new og("","data expressions not supported")]);const f=Zg(d,["zoom","pitch","distance-from-center"]);if(!f&&!sh(c))return qh([new og("","zoom expressions not supported")]);const a=Fh(d);return a||f?a instanceof og?qh([a]):a instanceof ka&&!th(c)?qh([new og("","\"interpolate\" expressions cannot be used with this property")]):ph(a?new hd(e?"camera":"composite",b.value,a.labels,a instanceof ka?a.interpolation:void 0):new gd(e?"constant":"source",b.value)):qh([new og("","\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.")])}class id{constructor(a,b){this._parameters=a,this._specification=b,yc(this,xh(this._parameters,this._specification))}static deserialize(a){return new id(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function Fh(a){let b=null;if(a instanceof Qc)b=Fh(a.result);else if(a instanceof Pc){for(const c of a.args)if(b=Fh(c))break}else(a instanceof Kc||a instanceof ka)&&a.input instanceof Ya&&"zoom"===a.input.name&&(b=a);return b instanceof og||a.eachChild(c=>{const a=Fh(c);a instanceof og?b=a:!b&&a?b=new og("","\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression."):b&&a&&b!==a&&(b=new og("","Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression."))}),b}function jd(c){const d=c.key,a=c.value,b=c.valueSpec||{},f=c.objectElementValidators||{},l=c.style,m=c.styleSpec;let g=[];const k=uh(a);if("object"!==k)return[new wc(d,a,`object expected, ${k} found`)];for(const e in a){const j=e.split(".")[0],n=b[j]||b["*"];let h;if(f[j])h=f[j];else if(b[j])h=Zh;else if(f["*"])h=f["*"];else{if(!b["*"]){g.push(new wc(d,a[e],`unknown property "${e}"`));continue}h=Zh}g=g.concat(h({key:(d?`${d}.`:d)+e,value:a[e],valueSpec:n,style:l,styleSpec:m,object:a,objectKey:e},a))}for(const i in b)f[i]||b[i].required&& void 0===b[i].default&& void 0===a[i]&&g.push(new wc(d,a,`missing required property "${i}"`));return g}function kd(c){const b=c.value,a=c.valueSpec,i=c.style,h=c.styleSpec,e=c.key,j=c.arrayElementValidator||Zh;if("array"!==uh(b))return[new wc(e,b,`array expected, ${uh(b)} found`)];if(a.length&&b.length!==a.length)return[new wc(e,b,`array length ${a.length} expected, length ${b.length} found`)];if(a["min-length"]&&b.lengthg)return[new wc(e,a,`${a} is greater than the maximum value ${g}`)]}return[]}function md(a){const f=a.valueSpec,c=mg(a.value.type);let g,h,i,j={};const d="categorical"!==c&& void 0===a.value.property,e="array"===uh(a.value.stops)&&"array"===uh(a.value.stops[0])&&"object"===uh(a.value.stops[0][0]),b=jd({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(a){if("identity"===c)return[new wc(a.key,a.value,"identity function may not have a \"stops\" property")];let b=[];const d=a.value;return b=b.concat(kd({key:a.key,value:d,valueSpec:a.valueSpec,style:a.style,styleSpec:a.styleSpec,arrayElementValidator:k})),"array"===uh(d)&&0===d.length&&b.push(new wc(a.key,d,"array must have at least one stop")),b},default:function(a){return Zh({key:a.key,value:a.value,valueSpec:f,style:a.style,styleSpec:a.styleSpec})}}});return"identity"===c&&d&&b.push(new wc(a.key,a.value,"missing required property \"property\"")),"identity"===c||a.value.stops||b.push(new wc(a.key,a.value,"missing required property \"stops\"")),"exponential"===c&&a.valueSpec.expression&&!th(a.valueSpec)&&b.push(new wc(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(d||rh(a.valueSpec)?d&&!sh(a.valueSpec)&&b.push(new wc(a.key,a.value,"zoom functions not supported")):b.push(new wc(a.key,a.value,"property functions not supported"))),("categorical"===c||e)&& void 0===a.value.property&&b.push(new wc(a.key,a.value,"\"property\" property is required")),b;function k(c){let d=[];const a=c.value,b=c.key;if("array"!==uh(a))return[new wc(b,a,`array expected, ${uh(a)} found`)];if(2!==a.length)return[new wc(b,a,`array length 2 expected, length ${a.length} found`)];if(e){if("object"!==uh(a[0]))return[new wc(b,a,`object expected, ${uh(a[0])} found`)];if(void 0===a[0].zoom)return[new wc(b,a,"object stop key must have zoom")];if(void 0===a[0].value)return[new wc(b,a,"object stop key must have value")];if(i&&i>mg(a[0].zoom))return[new wc(b,a[0].zoom,"stop zoom values must appear in ascending order")];mg(a[0].zoom)!==i&&(i=mg(a[0].zoom),h=void 0,j={}),d=d.concat(jd({key:`${b}[0]`,value:a[0],valueSpec:{zoom:{}},style:c.style,styleSpec:c.styleSpec,objectElementValidators:{zoom:ld,value:l}}))}else d=d.concat(l({key:`${b}[0]`,value:a[0],valueSpec:{},style:c.style,styleSpec:c.styleSpec},a));return Dh(ng(a[1]))?d.concat([new wc(`${b}[1]`,a[1],"expressions are not allowed in function stops.")]):d.concat(Zh({key:`${b}[1]`,value:a[1],valueSpec:f,style:c.style,styleSpec:c.styleSpec}))}function l(a,k){const b=uh(a.value),d=mg(a.value),e=null!==a.value?a.value:k;if(g){if(b!==g)return[new wc(a.key,e,`${b} stop domain type must match previous stop domain type ${g}`)]}else g=b;if("number"!==b&&"string"!==b&&"boolean"!==b)return[new wc(a.key,e,"stop domain value must be a number, string, or boolean")];if("number"!==b&&"categorical"!==c){let i=`number expected, ${b} found`;return rh(f)&& void 0===c&&(i+="\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`."),[new wc(a.key,e,i)]}return"categorical"!==c||"number"!==b||isFinite(d)&&Math.floor(d)===d?"categorical"!==c&&"number"===b&& void 0!==h&&dnew wc(`${a.key}${b.key}`,a.value,b.message));const b=c.value.expression||c.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!b.outputDefined())return[new wc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===a.expressionContext&&"layout"===a.propertyType&&!Yg(b))return[new wc(a.key,a.value,"\"feature-state\" data expressions are not supported with layout properties.")];if("filter"===a.expressionContext)return Hh(b,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!Zg(b,["zoom","feature-state"]))return[new wc(a.key,a.value,"\"zoom\" and \"feature-state\" expressions are not supported with cluster properties.")];if("cluster-initial"===a.expressionContext&&!Xg(b))return[new wc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Hh(b,a){const c=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const d of a.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return b instanceof Ya&&c.has(b.name)?[new wc(a.key,a.value,`["${b.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`)]:(b.eachChild(b=>{e.push(...Hh(b,a))}),e)}function nd(c){const e=c.key,a=c.value,b=c.valueSpec,d=[];return Array.isArray(b.values)?-1===b.values.indexOf(mg(a))&&d.push(new wc(e,a,`expected one of [${b.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(b.values).indexOf(mg(a))&&d.push(new wc(e,a,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(a)} found`)),d}function Ih(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!Ih(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function Jh(a,k="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Ih(a)||(a=Qh(a));const c=a;let d=!0;try{d=(function(a){if(!Mh(a))return a;let b=ng(a);return Lh(b),b=Kh(b)})(c)}catch(l){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(c,null,2)}\n `)}const f=b[`filter_${k}`],g=fd(d,f);let h=null;if("error"===g.result)throw new Error(g.value.map(a=>`${a.key}: ${a.message}`).join(", "));h=(a,b,c)=>g.value.evaluate(a,b,{},c);let i=null,j=null;if(d!==c){const e=fd(c,f);if("error"===e.result)throw new Error(e.value.map(a=>`${a.key}: ${a.message}`).join(", "));i=(a,b,c,d,f)=>e.value.evaluate(a,b,{},c,void 0,void 0,d,f),j=!Xg(e.value.expression)}return{filter:h,dynamicFilter:i||void 0,needGeometry:Ph(d),needFeature:!!j}}function Kh(a){if(!Array.isArray(a))return a;const b=function(a){if(Nh.has(a[0])){for(let b=1;bKh(a))}function Lh(a){let b=!1;const c=[];if("case"===a[0]){for(let d=1;d",">=","<","<=","to-boolean"]);function Oh(a,b){return ab?1:0}function Ph(a){if(!Array.isArray(a))return!1;if("within"===a[0])return!0;for(let b=1;b"===b||"<="===b||">="===b?Rh(a[1],a[2],b):"any"===b?(c=a.slice(1),["any"].concat(c.map(Qh))):"all"===b?["all"].concat(a.slice(1).map(Qh)):"none"===b?["all"].concat(a.slice(1).map(Qh).map(Uh)):"in"===b?Sh(a[1],a.slice(2)):"!in"===b?Uh(Sh(a[1],a.slice(2))):"has"===b?Th(a[1]):"!has"===b?Uh(Th(a[1])):"within"!==b||a}function Rh(c,a,b){switch(c){case"$type":return[`filter-type-${b}`,a];case"$id":return[`filter-id-${b}`,a];default:return[`filter-${b}`,c,a]}}function Sh(b,a){if(0===a.length)return!1;switch(b){case"$type":return["filter-type-in",["literal",a]];case"$id":return["filter-id-in",["literal",a]];default:return a.length>200&&!a.some(b=>typeof b!=typeof a[0])?["filter-in-large",b,["literal",a.sort(Oh)]]:["filter-in-small",b,["literal",a]]}}function Th(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function Uh(a){return["!",a]}function ab(a){if(Ih(ng(a.value))){const b=ng(a.layerType);return Gh(yc({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${b||"fill"}`]}))}return Vh(a)}function Vh(e){const a=e.value,c=e.key;if("array"!==uh(a))return[new wc(c,a,`array expected, ${uh(a)} found`)];const h=e.styleSpec;let d,b=[];if(a.length<1)return[new wc(c,a,"filter array must have at least 1 element")];switch(b=b.concat(nd({key:`${c}[0]`,value:a[0],valueSpec:h.filter_operator,style:e.style,styleSpec:e.styleSpec})),mg(a[0])){case"<":case"<=":case">":case">=":a.length>=2&&"$type"===mg(a[1])&&b.push(new wc(c,a,`"$type" cannot be use with operator "${a[0]}"`));case"==":case"!=":3!==a.length&&b.push(new wc(c,a,`filter array for operator "${a[0]}" must have 3 elements`));case"in":case"!in":a.length>=2&&"string"!==(d=uh(a[1]))&&b.push(new wc(`${c}[1]`,a[1],`string expected, ${d} found`));for(let f=2;f{d in a&&b.push(new wc(c,a[d],`"${d}" is prohibited for ref layers`))}),g.layers.forEach(a=>{mg(a.id)===m&&(j=a)}),j?j.ref?b.push(new wc(c,a.ref,"ref cannot reference another ref layer")):e=mg(j.type):b.push(new wc(c,a.ref,`ref layer "${m}" not found`))}else if("background"!==e&&"sky"!==e)if(a.source){const h=g.sources&&g.sources[a.source],f=h&&mg(h.type);h?"vector"===f&&"raster"===e?b.push(new wc(c,a.source,`layer "${a.id}" requires a raster source`)):"raster"===f&&"raster"!==e?b.push(new wc(c,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==f||a["source-layer"]?"raster-dem"===f&&"hillshade"!==e?b.push(new wc(c,a.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===e&&a.paint&&a.paint["line-gradient"]&&("geojson"!==f||!h.lineMetrics)&&b.push(new wc(c,a,`layer "${a.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):b.push(new wc(c,a,`layer "${a.id}" must specify a "source-layer"`)):b.push(new wc(c,a.source,`source "${a.source}" not found`))}else b.push(new wc(c,a,"missing required property \"source\""));return b=b.concat(jd({key:c,value:a,valueSpec:l.layer,style:d.style,styleSpec:d.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Zh({key:`${c}.type`,value:a.type,valueSpec:l.layer.type,style:d.style,styleSpec:d.styleSpec,object:a,objectKey:"type"}),filter:a=>ab(yc({layerType:e},a)),layout:b=>jd({layer:a,key:b.key,value:b.value,style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":a=>pd(yc({layerType:e},a))}}),paint:b=>jd({layer:a,key:b.key,value:b.value,style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":a=>od(yc({layerType:e},a))}})}}))}function qd(a){const b=a.value,d=a.key,c=uh(b);return"string"!==c?[new wc(d,b,`string expected, ${c} found`)]:[]}const Xh={promoteId:function({key:b,value:a}){if("string"===uh(a))return qd({key:b,value:a});{const c=[];for(const d in a)c.push(...qd({key:`${b}.${d}`,value:a[d]}));return c}}};function cb(d){const a=d.value,b=d.key,c=d.styleSpec,f=d.style;if(!a.type)return[new wc(b,a,"\"type\" is required")];const i=mg(a.type);let e;switch(i){case"vector":case"raster":case"raster-dem":return e=jd({key:b,value:a,valueSpec:c[`source_${i.replace("-","_")}`],style:d.style,styleSpec:c,objectElementValidators:Xh});case"geojson":if(e=jd({key:b,value:a,valueSpec:c.source_geojson,style:f,styleSpec:c,objectElementValidators:Xh}),a.cluster)for(const g in a.clusterProperties){const[h,j]=a.clusterProperties[g],k="string"==typeof h?[h,["accumulated"],["get",g]]:h;e.push(...Gh({key:`${b}.${g}.map`,value:j,expressionContext:"cluster-map"})),e.push(...Gh({key:`${b}.${g}.reduce`,value:k,expressionContext:"cluster-reduce"}))}return e;case"video":return jd({key:b,value:a,valueSpec:c.source_video,style:f,styleSpec:c});case"image":return jd({key:b,value:a,valueSpec:c.source_image,style:f,styleSpec:c});case"canvas":return[new wc(b,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return nd({key:`${b}.type`,value:a.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:f,styleSpec:c})}}function db(f){const b=f.value,d=f.styleSpec,e=d.light,h=f.style;let c=[];const i=uh(b);if(void 0===b)return c;if("object"!==i)return c=c.concat([new wc("light",b,`object expected, ${i} found`)]);for(const a in b){const g=a.match(/^(.*)-transition$/);c=c.concat(g&&e[g[1]]&&e[g[1]].transition?Zh({key:a,value:b[a],valueSpec:d.transition,style:h,styleSpec:d}):e[a]?Zh({key:a,value:b[a],valueSpec:e[a],style:h,styleSpec:d}):[new wc(a,b[a],`unknown property "${a}"`)])}return c}function eb(d){const a=d.value,h=d.key,e=d.style,f=d.styleSpec,g=f.terrain;let c=[];const k=uh(a);if(void 0===a)return c;if("object"!==k)return c=c.concat([new wc("terrain",a,`object expected, ${k} found`)]);for(const b in a){const i=b.match(/^(.*)-transition$/);c=c.concat(i&&g[i[1]]&&g[i[1]].transition?Zh({key:b,value:a[b],valueSpec:f.transition,style:e,styleSpec:f}):g[b]?Zh({key:b,value:a[b],valueSpec:g[b],style:e,styleSpec:f}):[new wc(b,a[b],`unknown property "${b}"`)])}if(a.source){const j=e.sources&&e.sources[a.source],l=j&&mg(j.type);j?"raster-dem"!==l&&c.push(new wc(h,a.source,`terrain cannot be used with a source of type ${l}, it only be used with a "raster-dem" source type`)):c.push(new wc(h,a.source,`source "${a.source}" not found`))}else c.push(new wc(h,a,"terrain is missing required property \"source\""));return c}function fb(f){const b=f.value,h=f.style,d=f.styleSpec,e=d.fog;let c=[];const i=uh(b);if(void 0===b)return c;if("object"!==i)return c=c.concat([new wc("fog",b,`object expected, ${i} found`)]);for(const a in b){const g=a.match(/^(.*)-transition$/);c=c.concat(g&&e[g[1]]&&e[g[1]].transition?Zh({key:a,value:b[a],valueSpec:d.transition,style:h,styleSpec:d}):e[a]?Zh({key:a,value:b[a],valueSpec:e[a],style:h,styleSpec:d}):[new wc(a,b[a],`unknown property "${a}"`)])}return c}const Yh={"*":()=>[],array:kd,boolean:function(a){const b=a.value,d=a.key,c=uh(b);return"boolean"!==c?[new wc(d,b,`boolean expected, ${c} found`)]:[]},number:ld,color:function(b){const c=b.key,a=b.value,d=uh(a);return"string"!==d?[new wc(c,a,`color expected, ${d} found`)]:null===vg.parseCSSColor(a)?[new wc(c,a,`color expected, "${a}" found`)]:[]},constants:xc,enum:nd,filter:ab,function:md,layer:bb,object:jd,source:cb,light:db,terrain:eb,fog:fb,string:qd,formatted:function(a){return 0===qd(a).length?[]:Gh(a)},resolvedImage:function(a){return 0===qd(a).length?[]:Gh(a)},projection:function(c){const b=c.value,f=c.styleSpec,g=f.projection,h=c.style;let a=[];const d=uh(b);if("object"===d)for(const e in b)a=a.concat(Zh({key:e,value:b[e],valueSpec:g[e],style:h,styleSpec:f}));else"string"!==d&&(a=a.concat([new wc("projection",b,`object or string expected, ${d} found`)]));return a}};function Zh(b){const c=b.value,a=b.valueSpec,d=b.styleSpec;return a.expression&&vh(mg(c))?md(b):a.expression&&Dh(ng(c))?Gh(b):a.type&&Yh[a.type]?Yh[a.type](b):jd(yc({},b,{valueSpec:a.type?d[a.type]:a}))}function $h(c){const a=c.value,d=c.key,b=qd(c);return b.length||(-1===a.indexOf("{fontstack}")&&b.push(new wc(d,a,"\"glyphs\" url must include a \"{fontstack}\" token")),-1===a.indexOf("{range}")&&b.push(new wc(d,a,"\"glyphs\" url must include a \"{range}\" token"))),b}function t(a,d=b){let c=[];return c=c.concat(Zh({key:"",value:a,valueSpec:d.$root,styleSpec:d,style:a,objectElementValidators:{glyphs:$h,"*":()=>[]}})),a.constants&&(c=c.concat(xc({key:"constants",value:a.constants,style:a,styleSpec:d}))),_h(c)}function _h(a){return[].concat(a).sort((a,b)=>a.line-b.line)}function v(a){return function(...b){return _h(a.apply(this,b))}}t.source=v(cb),t.light=v(db),t.terrain=v(eb),t.fog=v(fb),t.layer=v(bb),t.filter=v(ab),t.paintProperty=v(od),t.layoutProperty=v(pd);const M=t,rd=M.light,sd=M.fog,ai=M.paintProperty,bi=M.layoutProperty;function td(c,a){let b=!1;if(a&&a.length)for(const d of a)c.fire(new vc(new Error(d.message))),b=!0;return b}var la=u;function u(b,c,d){var e=this.cells=[];if(b instanceof ArrayBuffer){this.arrayBuffer=b;var a=new Int32Array(this.arrayBuffer);b=a[0],this.d=(c=a[1])+2*(d=a[2]);for(var f=0;f=a[b+0]&&k>=a[b+1])?(d[c]=!0,m.push(n[c])):d[c]=!1}}},u.prototype._forEachCell=function(d,e,f,g,h,i,j,c){for(var k=this._convertToCellCoord(d),l=this._convertToCellCoord(e),m=this._convertToCellCoord(f),n=this._convertToCellCoord(g),a=k;a<=m;a++)for(var b=l;b<=n;b++){var o=this.d*b+a;if((!c||c(this._convertFromCellCoord(a),this._convertFromCellCoord(b),this._convertFromCellCoord(a+1),this._convertFromCellCoord(b+1)))&&h.call(this,d,e,f,g,o,i,j,c))return}},u.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},u.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},u.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var c=this.cells,f=3+this.cells.length+1+1,g=0,e=0;e=0)continue;const i=a[e];d[e]=ei[c].shallow.indexOf(e)>=0?i:hi(i,b)}a instanceof Error&&(d.message=a.message)}if(d.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==c&&(d.$name=c),d}throw new Error("can't serialize object of type "+typeof a)}function ii(a){if(null==a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||fi(a)||gi(a)||ArrayBuffer.isView(a)||a instanceof ci)return a;if(Array.isArray(a))return a.map(ii);if("object"==typeof a){const d=a.$name||"Object",{klass:b}=ei[d];if(!b)throw new Error(`can't deserialize unregistered class ${d}`);if(b.deserialize)return b.deserialize(a);const e=Object.create(b.prototype);for(const c of Object.keys(a)){if("$name"===c)continue;const f=a[c];e[c]=ei[d].shallow.indexOf(c)>=0?f:ii(f)}return e}throw new Error("can't deserialize object of type "+typeof a)}class ud{constructor(){this.first=!0}update(b,c){const a=Math.floor(b);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=b,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=c):this.lastFloorZooma>=1536&&a<=1791,ki=a=>a>=1872&&a<=1919,li=a=>a>=2208&&a<=2303,mi=a=>a>=11904&&a<=12031,ni=a=>a>=12032&&a<=12255,oi=a=>a>=12272&&a<=12287,pi=a=>a>=12288&&a<=12351,qi=a=>a>=12352&&a<=12447,ri=a=>a>=12448&&a<=12543,si=a=>a>=12544&&a<=12591,ti=a=>a>=12704&&a<=12735,ui=a=>a>=12736&&a<=12783,vi=a=>a>=12784&&a<=12799,wi=a=>a>=12800&&a<=13055,xi=a=>a>=13056&&a<=13311,yi=a=>a>=13312&&a<=19903,zi=a=>a>=19968&&a<=40959,Ai=a=>a>=40960&&a<=42127,Bi=a=>a>=42128&&a<=42191,Ci=a=>a>=44032&&a<=55215,Di=a=>a>=63744&&a<=64255,Ei=a=>a>=64336&&a<=65023,Fi=a=>a>=65040&&a<=65055,Gi=a=>a>=65072&&a<=65103,Hi=a=>a>=65104&&a<=65135,Ii=a=>a>=65136&&a<=65279,Ji=a=>a>=65280&&a<=65519;function Ki(a){for(const b of a)if(Ni(b.charCodeAt(0)))return!0;return!1}function Li(a){for(const b of a)if(!Mi(b.charCodeAt(0)))return!1;return!0}function Mi(a){return!(ji(a)||ki(a)||li(a)||Ei(a)||Ii(a))}function Ni(a){var b,c,d,e,f,g,h,i;return!(746!==a&&747!==a&&(a<4352||!(ti(a)||si(a)||Gi(a)&&!(a>=65097&&a<=65103)||Di(a)||xi(a)||mi(a)||ui(a)||!(!pi(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||12336===a)||yi(a)||zi(a)||wi(a)||(b=a)>=12592&&b<=12687||(c=a)>=43360&&c<=43391||(d=a)>=55216&&d<=55295||(e=a)>=4352&&e<=4607||Ci(a)||qi(a)||oi(a)||(f=a)>=12688&&f<=12703||ni(a)||vi(a)||ri(a)&&12540!==a||!(!Ji(a)||65288===a||65289===a||65293===a||a>=65306&&a<=65310||65339===a||65341===a||65343===a||a>=65371&&a<=65503||65507===a||a>=65512&&a<=65519)||!(!Hi(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(g=a)>=5120&&g<=5759||(h=a)>=6320&&h<=6399||Fi(a)||(i=a)>=19904&&i<=19967||Ai(a)||Bi(a))))}function Oi(b){var a,c,d,e,f,g,h,i,j,k,l,m,n;return!(Ni(b)||(c=a=b)>=128&&c<=255&&(167===a||169===a||174===a||177===a||188===a||189===a||190===a||215===a||247===a)||(d=a)>=8192&&d<=8303&&(8214===a||8224===a||8225===a||8240===a||8241===a||8251===a||8252===a||8258===a||8263===a||8264===a||8265===a||8273===a)||(e=a)>=8448&&e<=8527||(f=a)>=8528&&f<=8591||(g=a)>=8960&&g<=9215&&(a>=8960&&a<=8967||a>=8972&&a<=8991||a>=8996&&a<=9e3||9003===a||a>=9085&&a<=9114||a>=9150&&a<=9165||9167===a||a>=9169&&a<=9179||a>=9186&&a<=9215)||(h=a)>=9216&&h<=9279&&9251!==a||(i=a)>=9280&&i<=9311||(j=a)>=9312&&j<=9471||(k=a)>=9632&&k<=9727||(l=a)>=9728&&l<=9983&&!(a>=9754&&a<=9759)||(m=a)>=11008&&m<=11263&&(a>=11026&&a<=11055||a>=11088&&a<=11097||a>=11192&&a<=11243)||pi(a)||ri(a)||(n=a)>=57344&&n<=63743||Gi(a)||Hi(a)||Ji(a)||8734===a||8756===a||8757===a||a>=9984&&a<=10087||a>=10102&&a<=10131||65532===a||65533===a)}function Pi(a){return a>=1424&&a<=2303||Ei(a)||Ii(a)}function Qi(a,c){var b;return!(!c&&Pi(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(b=a)>=6016&&b<=6143)}function Ri(a){for(const b of a)if(Pi(b.charCodeAt(0)))return!0;return!1}const Si="deferred",Ti="loading",Ui="loaded";let Vi=null,Wi="unavailable",Xi=null;const vd=function(a){a&&"string"==typeof a&&a.indexOf("NetworkError")> -1&&(Wi="error"),Vi&&Vi(a)};function Yi(){wd.fire(new Xa("pluginStateChange",{pluginStatus:Wi,pluginURL:Xi}))}const wd=new S,xd=function(){return Wi},Zi=function(){if(Wi!==Si||!Xi)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Wi=Ti,Yi(),Xi&&fg({url:Xi},a=>{a?vd(a):(Wi=Ui,Yi())})},yd={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Wi===Ui||null!=yd.applyArabicShaping,isLoading:()=>Wi===Ti,setState(a){Wi=a.pluginStatus,Xi=a.pluginURL},isParsed:()=>null!=yd.applyArabicShaping&&null!=yd.processBidirectionalText&&null!=yd.processStyledBidirectionalText,getPluginURL:()=>Xi};class zd{constructor(b,a){this.zoom=b,a?(this.now=a.now,this.fadeDuration=a.fadeDuration,this.zoomHistory=a.zoomHistory,this.transition=a.transition,this.pitch=a.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ud,this.transition={},this.pitch=0)}isSupportedScript(a){return(function(a,b){for(const c of a)if(!Qi(c.charCodeAt(0),b))return!1;return!0})(a,yd.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const a=this.zoom,b=a-Math.floor(a),c=this.crossFadingFactor();return a>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:b+(1-b)*c}:{fromScale:.5,toScale:1,t:1-(1-c)*b}}}class $i{constructor(a,b){this.property=a,this.value=b,this.expression=(function(a,b){if(vh(a))return new id(a,b);if(Dh(a)){const c=Eh(a,b);if("error"===c.result)throw new Error(c.value.map(a=>`${a.key}: ${a.message}`).join(", "));return c.value}{let d=a;return"string"==typeof a&&"color"===b.type&&(d=m.parse(a)),{kind:"constant",evaluate:()=>d}}})(void 0===b?a.specification.default:b,a.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(a,b,c){return this.property.possiblyEvaluate(this,a,b,c)}}class _i{constructor(a){this.property=a,this.value=new $i(a,void 0)}transitioned(a,b){return new aj(this.property,this.value,b,_b({},a.transition,this.transition),a.now)}untransitioned(){return new aj(this.property,this.value,null,{},0)}}class Ad{constructor(a){this._properties=a,this._values=Object.create(a.defaultTransitionablePropertyValues)}getValue(a){return fc(this._values[a].value.value)}setValue(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new _i(this._values[a].property)),this._values[a].value=new $i(this._values[a].property,null===b?void 0:fc(b))}getTransition(a){return fc(this._values[a].transition)}setTransition(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new _i(this._values[a].property)),this._values[a].transition=fc(b)||void 0}serialize(){const b={};for(const a of Object.keys(this._values)){const c=this.getValue(a);void 0!==c&&(b[a]=c);const d=this.getTransition(a);void 0!==d&&(b[`${a}-transition`]=d)}return b}transitioned(c,d){const b=new bj(this._properties);for(const a of Object.keys(this._values))b._values[a]=this._values[a].transitioned(c,d._values[a]);return b}untransitioned(){const a=new bj(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].untransitioned();return a}}class aj{constructor(c,d,e,a,b){const f=a.delay||0,g=a.duration||0;b=b||0,this.property=c,this.value=d,this.begin=b+f,this.end=this.begin+g,c.specification.transition&&(a.delay||a.duration)&&(this.prior=e)}possiblyEvaluate(a,c,d){const e=a.now||0,b=this.value.possiblyEvaluate(a,c,d),f=this.prior;if(f){if(e>this.end)return this.prior=null,b;if(this.value.isDataDriven())return this.prior=null,b;if(ed.zoomHistory.lastIntegerZoom?{from:a,to:b,other:c}:{from:c,to:b,other:a}}interpolate(a){return a}}class gb{constructor(a){this.specification=a}possiblyEvaluate(b,a,d,e){if(void 0!==b.value){if("constant"===b.expression.kind){const c=b.expression.evaluate(a,null,{},d,e);return this._calculate(c,c,c,a)}return this._calculate(b.expression.evaluate(new zd(Math.floor(a.zoom-1),a)),b.expression.evaluate(new zd(Math.floor(a.zoom),a)),b.expression.evaluate(new zd(Math.floor(a.zoom+1),a)),a)}}_calculate(c,a,d,b){return b.zoom>b.zoomHistory.lastIntegerZoom?{from:c,to:a}:{from:d,to:a}}interpolate(a){return a}}class V{constructor(a){this.specification=a}possiblyEvaluate(a,b,c,d){return!!a.expression.evaluate(b,null,{},c,d)}interpolate(){return!1}}class n{constructor(b){for(const a in this.properties=b,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],b){const c=b[a];c.specification.overridable&&this.overridableProperties.push(a);const d=this.defaultPropertyValues[a]=new $i(c,void 0),e=this.defaultTransitionablePropertyValues[a]=new _i(c);this.defaultTransitioningPropertyValues[a]=e.untransitioned(),this.defaultPossiblyEvaluatedValues[a]=d.possiblyEvaluate({})}}}function ej(a,b){return 256*(a=Wb(Math.floor(a),0,255))+Wb(Math.floor(b),0,255)}c("DataDrivenProperty",g),c("DataConstantProperty",e),c("CrossFadedDataDrivenProperty",N),c("CrossFadedProperty",gb),c("ColorRampProperty",V);const fj={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class O{constructor(a,b){this._structArray=a,this._pos1=b*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class k{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(a,b){return a._trim(),b&&(a.isTransferred=!0,b.push(a.arrayBuffer)),{length:a.length,arrayBuffer:a.arrayBuffer}}static deserialize(b){const a=Object.create(this.prototype);return a.arrayBuffer=b.arrayBuffer,a.length=b.length,a.capacity=b.arrayBuffer.byteLength/a.bytesPerElement,a._refreshViews(),a}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(a){this.reserve(a),this.length=a}reserve(a){if(a>this.capacity){this.capacity=Math.max(a,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const b=this.uint8;this._refreshViews(),b&&this.uint8.set(b)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function j(b,a=1){let c=0,d=0;return{members:b.map(b=>{const e=fj[b.type].BYTES_PER_ELEMENT,g=c=gj(c,Math.max(a,e)),f=b.components||1;return d=Math.max(d,e),c+=e*f,{name:b.name,type:b.type,components:f,offset:g}}),size:gj(c,Math.max(d,a)),alignment:a}}function gj(b,a){return Math.ceil(b/a)*a}class na extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.int16[b+0]=c,this.int16[b+1]=d,a}}na.prototype.bytesPerElement=4,c("StructArrayLayout2i4",na);class oa extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(b,c,d,e,f){const a=4*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+3]=f,b}}oa.prototype.bytesPerElement=8,c("StructArrayLayout4i8",oa);class hb extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(a,d,e,f,g,h,i,j){const c=6*a,b=12*a,k=3*a;return this.int16[c+0]=d,this.int16[c+1]=e,this.uint8[b+4]=f,this.uint8[b+5]=g,this.uint8[b+6]=h,this.uint8[b+7]=i,this.float32[k+2]=j,a}}hb.prototype.bytesPerElement=12,c("StructArrayLayout2i4ub1f12",hb);class pa extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,b}}pa.prototype.bytesPerElement=12,c("StructArrayLayout3f12",pa);class w extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k)}emplace(b,c,d,e,f,g,h,i,j,k,l){const a=10*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,this.uint16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,this.uint16[a+8]=k,this.uint16[a+9]=l,b}}w.prototype.bytesPerElement=20,c("StructArrayLayout10ui20",w);class W extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i)}emplace(b,c,d,e,f,g,h,i,j){const a=8*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,this.uint16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,b}}W.prototype.bytesPerElement=16,c("StructArrayLayout8ui16",W);class ib extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q)}emplace(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){const a=16*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,this.int16[a+8]=k,this.int16[a+9]=l,this.int16[a+10]=m,this.int16[a+11]=n,this.int16[a+12]=o,this.int16[a+13]=p,this.int16[a+14]=q,this.int16[a+15]=r,b}}ib.prototype.bytesPerElement=32,c("StructArrayLayout4i4ui4i4i32",ib);class jb extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.uint32[1*a+0]=b,a}}jb.prototype.bytesPerElement=4,c("StructArrayLayout1ul4",jb);class qa extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k,l,m,n){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n)}emplace(c,d,e,f,g,h,i,j,k,l,m,n,o,p){const a=20*c,b=10*c;return this.int16[a+0]=d,this.int16[a+1]=e,this.int16[a+2]=f,this.int16[a+3]=g,this.int16[a+4]=h,this.float32[b+3]=i,this.float32[b+4]=j,this.float32[b+5]=k,this.float32[b+6]=l,this.int16[a+14]=m,this.uint32[b+8]=n,this.uint16[a+18]=o,this.uint16[a+19]=p,c}}qa.prototype.bytesPerElement=40,c("StructArrayLayout5i4f1i1ul2ui40",qa);class kb extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(b,c,d,e,f,g,h,i){const a=8*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+4]=f,this.int16[a+5]=g,this.int16[a+6]=h,this.int16[a+7]=i,b}}kb.prototype.bytesPerElement=16,c("StructArrayLayout3i2i2i16",kb);class ra extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f)}emplace(a,d,e,f,g,h){const b=4*a,c=8*a;return this.float32[b+0]=d,this.float32[b+1]=e,this.float32[b+2]=f,this.int16[c+6]=g,this.int16[c+7]=h,a}}ra.prototype.bytesPerElement=16,c("StructArrayLayout2f1f2i16",ra);class lb extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(a,d,e,f,g){const b=12*a,c=3*a;return this.uint8[b+0]=d,this.uint8[b+1]=e,this.float32[c+1]=f,this.float32[c+2]=g,a}}lb.prototype.bytesPerElement=12,c("StructArrayLayout2ub2f12",lb);class sa extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,b}}sa.prototype.bytesPerElement=6,c("StructArrayLayout3ui6",sa);class ta extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v)}emplace(c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y){const a=30*c,b=15*c,d=60*c;return this.int16[a+0]=e,this.int16[a+1]=f,this.int16[a+2]=g,this.float32[b+2]=h,this.float32[b+3]=i,this.uint16[a+8]=j,this.uint16[a+9]=k,this.uint32[b+5]=l,this.uint32[b+6]=m,this.uint32[b+7]=n,this.uint16[a+16]=o,this.uint16[a+17]=p,this.uint16[a+18]=q,this.float32[b+10]=r,this.float32[b+11]=s,this.uint8[d+48]=t,this.uint8[d+49]=u,this.uint8[d+50]=v,this.uint32[b+13]=w,this.int16[a+28]=x,this.uint8[d+58]=y,c}}ta.prototype.bytesPerElement=60,c("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ta);class ua extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E)}emplace(c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G){const a=38*c,b=19*c;return this.int16[a+0]=d,this.int16[a+1]=e,this.int16[a+2]=f,this.float32[b+2]=g,this.float32[b+3]=h,this.int16[a+8]=i,this.int16[a+9]=j,this.int16[a+10]=k,this.int16[a+11]=l,this.int16[a+12]=m,this.int16[a+13]=n,this.uint16[a+14]=o,this.uint16[a+15]=p,this.uint16[a+16]=q,this.uint16[a+17]=r,this.uint16[a+18]=s,this.uint16[a+19]=t,this.uint16[a+20]=u,this.uint16[a+21]=v,this.uint16[a+22]=w,this.uint16[a+23]=x,this.uint16[a+24]=y,this.uint16[a+25]=z,this.uint16[a+26]=A,this.uint16[a+27]=B,this.uint16[a+28]=C,this.uint32[b+15]=D,this.float32[b+16]=E,this.float32[b+17]=F,this.float32[b+18]=G,c}}ua.prototype.bytesPerElement=76,c("StructArrayLayout3i2f6i15ui1ul3f76",ua);class X extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.float32[1*a+0]=b,a}}X.prototype.bytesPerElement=4,c("StructArrayLayout1f4",X);class va extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,b}}va.prototype.bytesPerElement=6,c("StructArrayLayout3i6",va);class mb extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(b,c,d,e,f,g,h,i){const a=7*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,this.float32[a+3]=f,this.float32[a+4]=g,this.float32[a+5]=h,this.float32[a+6]=i,b}}mb.prototype.bytesPerElement=28,c("StructArrayLayout7f28",mb);class wa extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(a,c,d,e,f){const b=6*a;return this.uint32[3*a+0]=c,this.uint16[b+2]=d,this.uint16[b+3]=e,this.uint16[b+4]=f,a}}wa.prototype.bytesPerElement=12,c("StructArrayLayout1ul3ui12",wa);class Y extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.uint16[b+0]=c,this.uint16[b+1]=d,a}}Y.prototype.bytesPerElement=4,c("StructArrayLayout2ui4",Y);class xa extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.uint16[1*a+0]=b,a}}xa.prototype.bytesPerElement=2,c("StructArrayLayout1ui2",xa);class Z extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.float32[b+0]=c,this.float32[b+1]=d,a}}Z.prototype.bytesPerElement=8,c("StructArrayLayout2f8",Z);class ya extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(b,c,d,e,f){const a=4*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,this.float32[a+3]=f,b}}ya.prototype.bytesPerElement=16,c("StructArrayLayout4f16",ya);class Bd extends O{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Bd.prototype.size=40;class Cd extends qa{get(a){return new Bd(this,a)}}c("CollisionBoxArray",Cd);class Dd extends O{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(a){this._structArray.uint8[this._pos1+49]=a}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(a){this._structArray.uint8[this._pos1+50]=a}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(a){this._structArray.uint32[this._pos4+13]=a}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(a){this._structArray.uint8[this._pos1+58]=a}}Dd.prototype.size=60;class Ed extends ta{get(a){return new Dd(this,a)}}c("PlacedSymbolArray",Ed);class Fd extends O{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(a){this._structArray.uint32[this._pos4+15]=a}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}Fd.prototype.size=76;class Gd extends ua{get(a){return new Fd(this,a)}}c("SymbolInstanceArray",Gd);class Hd extends X{getoffsetX(a){return this.float32[1*a+0]}}c("GlyphOffsetArray",Hd);class Id extends va{getx(a){return this.int16[3*a+0]}gety(a){return this.int16[3*a+1]}gettileUnitDistanceFromAnchor(a){return this.int16[3*a+2]}}c("SymbolLineVertexArray",Id);class Jd extends O{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Jd.prototype.size=12;class Kd extends wa{get(a){return new Jd(this,a)}}c("FeatureIndexArray",Kd);class Ld extends O{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Ld.prototype.size=4;class Md extends Y{get(a){return new Ld(this,a)}}c("FillExtrusionCentroidArray",Md);const hj=j([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),ij=j([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var nb=ja(function(a){a.exports=function(c,j){var g,h,a,i,e,f,b,d;for(h=c.length-(g=3&c.length),a=j,e=3432918353,f=461845907,d=0;d>>16)*e&65535)<<16)&4294967295)<<15|b>>>17))*f+(((b>>>16)*f&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+((58964+(i>>>16)&65535)<<16);switch(b=0,g){case 3:b^=(255&c.charCodeAt(d+2))<<16;case 2:b^=(255&c.charCodeAt(d+1))<<8;case 1:a^=b=(65535&(b=(b=(65535&(b^=255&c.charCodeAt(d)))*e+(((b>>>16)*e&65535)<<16)&4294967295)<<15|b>>>17))*f+(((b>>>16)*f&65535)<<16)&4294967295}return a^=c.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0}}),Nd=ja(function(a){a.exports=function(b,f){for(var d,e=b.length,a=f^e,c=0;e>=4;)d=1540483477*(65535&(d=255&b.charCodeAt(c)|(255&b.charCodeAt(++c))<<8|(255&b.charCodeAt(++c))<<16|(255&b.charCodeAt(++c))<<24))+((1540483477*(d>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(d=1540483477*(65535&(d^=d>>>24))+((1540483477*(d>>>16)&65535)<<16)),e-=4,++c;switch(e){case 3:a^=(255&b.charCodeAt(c+2))<<16;case 2:a^=(255&b.charCodeAt(c+1))<<8;case 1:a=1540483477*(65535&(a^=255&b.charCodeAt(c)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0}}),ob=nb;ob.murmur3=nb,ob.murmur2=Nd;class Od{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(a,b,c,d){this.ids.push(jj(a)),this.positions.push(b,c,d)}getPositions(f){const d=jj(f);let a=0,b=this.ids.length-1;for(;a>1;this.ids[c]>=d?b=c:a=c+1}const e=[];for(;this.ids[a]===d;)e.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return e}static serialize(c,d){const a=new Float64Array(c.ids),b=new Uint32Array(c.positions);return kj(a,b,0,a.length-1),d&&d.push(a.buffer,b.buffer),{ids:a,positions:b}}static deserialize(b){const a=new Od;return a.ids=b.ids,a.positions=b.positions,a.indexed=!0,a}}function jj(b){const a=+b;return!isNaN(a)&&Number.MIN_SAFE_INTEGER<=a&&a<=Number.MAX_SAFE_INTEGER?a:ob(String(b))}function kj(c,f,d,e){for(;d>1];let b=d-1,a=e+1;for(;;){do b++;while(c[b]g)if(b>=a)break;lj(c,b,a),lj(f,3*b,3*a),lj(f,3*b+1,3*a+1),lj(f,3*b+2,3*a+2)}a-d`u_${a}`),this.type=c}setUniform(a,c,b){a.set(b.constantOr(this.value))}getBinding(a,b,c){return"color"===this.type?new Rd(a,b):new Pd(a,b)}}class Td{constructor(b,a){this.uniformNames=a.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(a,b){this.pixelRatioFrom=b.pixelRatio,this.pixelRatioTo=a.pixelRatio,this.patternFrom=b.tl.concat(b.br),this.patternTo=a.tl.concat(a.br)}setUniform(c,d,e,a){const b="u_pattern_to"===a||"u_dash_to"===a?this.patternTo:"u_pattern_from"===a||"u_dash_from"===a?this.patternFrom:"u_pixel_ratio_to"===a?this.pixelRatioTo:"u_pixel_ratio_from"===a?this.pixelRatioFrom:null;b&&c.set(b)}getBinding(b,c,a){return"u_pattern_from"===a||"u_pattern_to"===a||"u_dash_from"===a||"u_dash_to"===a?new Qd(b,c):new Pd(b,c)}}class Ud{constructor(a,b,c,d){this.expression=a,this.type=c,this.maxValue=0,this.paintVertexAttributes=b.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?2:1,offset:0})),this.paintVertexArray=new d}populatePaintArray(a,b,h,c,d,e){const f=this.paintVertexArray.length,g=this.expression.evaluate(new zd(0),b,{},d,c,e);this.paintVertexArray.resize(a),this._setPaintValue(f,a,g)}updatePaintArray(a,b,c,d,e){const f=this.expression.evaluate({zoom:0},c,d,void 0,e);this._setPaintValue(a,b,f)}_setPaintValue(d,e,a){if("color"===this.type){const f=pj(a);for(let b=d;b`u_${a}_t`),this.type=c,this.useIntegerZoom=d,this.zoom=e,this.maxValue=0,this.paintVertexAttributes=a.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?4:2,offset:0})),this.paintVertexArray=new f}populatePaintArray(a,b,i,c,d,e){const f=this.expression.evaluate(new zd(this.zoom),b,{},d,c,e),g=this.expression.evaluate(new zd(this.zoom+1),b,{},d,c,e),h=this.paintVertexArray.length;this.paintVertexArray.resize(a),this._setPaintValue(h,a,f,g)}updatePaintArray(d,e,a,b,c){const f=this.expression.evaluate({zoom:this.zoom},a,b,void 0,c),g=this.expression.evaluate({zoom:this.zoom+1},a,b,void 0,c);this._setPaintValue(d,e,f,g)}_setPaintValue(e,f,a,b){if("color"===this.type){const g=pj(a),h=pj(b);for(let c=e;c!0){this.binders={},this._buffers=[];const g=[];for(const a in e.paint._values){if(!n(a))continue;const c=e.paint.get(a);if(!(c instanceof cj&&rh(c.property.specification)))continue;const f=rj(a,e.type),b=c.value,d=c.property.specification.type,j=c.property.useIntegerZoom,k=c.property.specification["property-type"],h="cross-faded"===k||"cross-faded-data-driven"===k,l="line-dasharray"===String(a)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==b.kind||l)if("source"===b.kind||l||h){const m=uj(a,d,"source");this.binders[a]=h?new Wd(b,f,d,j,i,m,e.id):new Ud(b,f,d,m),g.push(`/a_${a}`)}else{const o=uj(a,d,"composite");this.binders[a]=new Vd(b,f,d,j,i,o),g.push(`/z_${a}`)}else this.binders[a]=h?new Td(b.value,f):new Sd(b.value,f,d),g.push(`/u_${a}`)}this.cacheKey=g.sort().join("")}getMaxValue(b){const a=this.binders[b];return a instanceof Ud||a instanceof Vd?a.maxValue:0}populatePaintArrays(b,c,d,e,f,g){for(const h in this.binders){const a=this.binders[h];(a instanceof Ud||a instanceof Vd||a instanceof Wd)&&a.populatePaintArray(b,c,d,e,f,g)}}setConstantPatternPositions(b,c){for(const d in this.binders){const a=this.binders[d];a instanceof Td&&a.setConstantPatternPositions(b,c)}}updatePaintArrays(c,g,h,i,j,k){let d=!1;for(const e in c){const l=g.getPositions(e);for(const b of l){const m=h.feature(b.index);for(const f in this.binders){const a=this.binders[f];if((a instanceof Ud||a instanceof Vd||a instanceof Wd)&& !0===a.expression.isStateDependent){const n=i.paint.get(f);a.expression=n.value,a.updatePaintArray(b.start,b.end,m,c[e],j,k),d=!0}}}}return d}defines(){const b=[];for(const c in this.binders){const a=this.binders[c];(a instanceof Sd||a instanceof Td)&&b.push(...a.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return b}getBinderAttributes(){const c=[];for(const d in this.binders){const a=this.binders[d];if(a instanceof Ud||a instanceof Vd||a instanceof Wd)for(let b=0;b!0){for(const a of(this.programConfigurations={},b))this.programConfigurations[a.id]=new Xd(a,c,d);this.needsUpload=!1,this._featureMap=new Od,this._bufferOffset=0}populatePaintArrays(a,b,c,d,e,f,g){for(const h in this.programConfigurations)this.programConfigurations[h].populatePaintArrays(a,b,d,e,f,g);void 0!==b.id&&this._featureMap.add(b.id,c,this._bufferOffset,a),this._bufferOffset=a,this.needsUpload=!0}updatePaintArrays(b,c,d,e,f){for(const a of d)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(b,this._featureMap,c,a,e,f)||this.needsUpload}get(a){return this.programConfigurations[a]}upload(a){if(this.needsUpload){for(const b in this.programConfigurations)this.programConfigurations[b].upload(a);this.needsUpload=!1}}destroy(){for(const a in this.programConfigurations)this.programConfigurations[a].destroy()}}const qj={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function rj(a,b){return qj[a]||[a.replace(`${b}-`,"").replace(/-/g,"_")]}const sj={"line-pattern":{source:w,composite:w},"fill-pattern":{source:w,composite:w},"fill-extrusion-pattern":{source:w,composite:w},"line-dasharray":{source:W,composite:W}},tj={color:{source:Z,composite:ya},number:{source:X,composite:Z}};function uj(c,d,a){const b=sj[c];return b&&b[a]||tj[d][a]}c("ConstantBinder",Sd),c("CrossFadedConstantBinder",Td),c("SourceExpressionBinder",Ud),c("CrossFadedCompositeBinder",Wd),c("CompositeExpressionBinder",Vd),c("ProgramConfiguration",Xd,{omit:["_buffers"]}),c("ProgramConfigurationSet",Yd);const vj="-transition";class pb extends S{constructor(a,b){if(super(),this.id=a.id,this.type=a.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==a.type&&(this.metadata=(a=a).metadata,this.minzoom=a.minzoom,this.maxzoom=a.maxzoom,"background"!==a.type&&"sky"!==a.type&&(this.source=a.source,this.sourceLayer=a["source-layer"],this.filter=a.filter),b.layout&&(this._unevaluatedLayout=new class{constructor(a){this._properties=a,this._values=Object.create(a.defaultPropertyValues)}getValue(a){return fc(this._values[a].value)}setValue(a,b){this._values[a]=new $i(this._values[a].property,null===b?void 0:fc(b))}serialize(){const a={};for(const b of Object.keys(this._values)){const c=this.getValue(b);void 0!==c&&(a[b]=c)}return a}possiblyEvaluate(c,d,e){const a=new dj(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].possiblyEvaluate(c,d,e);return a}}(b.layout)),b.paint)){for(const c in this._transitionablePaint=new Ad(b.paint),a.paint)this.setPaintProperty(c,a.paint[c],{validate:!1});for(const d in a.layout)this.setLayoutProperty(d,a.layout[d],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new dj(b.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(a){return"visibility"===a?this.visibility:this._unevaluatedLayout.getValue(a)}setLayoutProperty(a,b,c={}){null!=b&&this._validate(bi,`layers.${this.id}.layout.${a}`,a,b,c)||("visibility"!==a?this._unevaluatedLayout.setValue(a,b):this.visibility=b)}getPaintProperty(a){return dc(a,vj)?this._transitionablePaint.getTransition(a.slice(0,-vj.length)):this._transitionablePaint.getValue(a)}setPaintProperty(a,b,e={}){if(null!=b&&this._validate(ai,`layers.${this.id}.paint.${a}`,a,b,e))return!1;if(dc(a,vj))return this._transitionablePaint.setTransition(a.slice(0,-vj.length),b||void 0),!1;{const c=this._transitionablePaint._values[a],f="cross-faded-data-driven"===c.property.specification["property-type"],g=c.value.isDataDriven(),h=c.value;this._transitionablePaint.setValue(a,b),this._handleSpecialPaintPropertyUpdate(a);const d=this._transitionablePaint._values[a].value;return d.isDataDriven()||g||f||this._handleOverridablePaintPropertyUpdate(a,h,d)}}_handleSpecialPaintPropertyUpdate(a){}getProgramIds(){return null}getProgramConfiguration(a){return null}_handleOverridablePaintPropertyUpdate(a,b,c){return!1}isHidden(a){return!!(this.minzoom&&a=this.maxzoom)||"none"===this.visibility}updateTransitions(a){this._transitioningPaint=this._transitionablePaint.transitioned(a,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(a,b){a.getCrossfadeParameters&&(this._crossfadeParameters=a.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(a,void 0,b)),this.paint=this._transitioningPaint.possiblyEvaluate(a,void 0,b)}serialize(){const a={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(a.layout=a.layout||{},a.layout.visibility=this.visibility),ec(a,(a,b)=>!(void 0===a||"layout"===b&&!Object.keys(a).length||"paint"===b&&!Object.keys(a).length))}_validate(c,d,e,f,a={}){return(!a|| !1!==a.validate)&&td(this,c.call(M,{key:d,layerType:this.type,objectKey:e,value:f,styleSpec:b,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const b in this.paint._values){const a=this.paint.get(b);if(a instanceof cj&&rh(a.property.specification)&&("source"===a.value.kind||"composite"===a.value.kind)&&a.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Jh(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const Zd=j([{name:"a_pos",components:2,type:"Int16"}],4),{members:wj}=Zd;class Aa{constructor(a=[]){this.segments=a}prepareSegment(b,d,e,c){let a=this.segments[this.segments.length-1];return b>Aa.MAX_VERTEX_ARRAY_LENGTH&&gc(`Max vertices per segment is ${Aa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${b}`),(!a||a.vertexLength+b>Aa.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==c)&&(a={vertexOffset:d.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0},void 0!==c&&(a.sortKey=c),this.segments.push(a)),a}get(){return this.segments}destroy(){for(const a of this.segments)for(const b in a.vaos)a.vaos[b].destroy()}static simpleSegment(a,b,c,d){return new Aa([{vertexOffset:a,primitiveOffset:b,vertexLength:c,primitiveLength:d,vaos:{},sortKey:0}])}}Aa.MAX_VERTEX_ARRAY_LENGTH=65535,c("SegmentVector",Aa);class $d{constructor(a,b){a&&(b?this.setSouthWest(a).setNorthEast(b):4===a.length?this.setSouthWest([a[0],a[1]]).setNorthEast([a[2],a[3]]):this.setSouthWest(a[0]).setNorthEast(a[1]))}setNorthEast(a){return this._ne=a instanceof _d?new _d(a.lng,a.lat):_d.convert(a),this}setSouthWest(a){return this._sw=a instanceof _d?new _d(a.lng,a.lat):_d.convert(a),this}extend(a){const d=this._sw,e=this._ne;let b,c;if(a instanceof _d)b=a,c=a;else{if(!(a instanceof $d))return Array.isArray(a)?4===a.length||a.every(Array.isArray)?this.extend($d.convert(a)):this.extend(_d.convert(a)):this;if(b=a._sw,c=a._ne,!b||!c)return this}return d||e?(d.lng=Math.min(b.lng,d.lng),d.lat=Math.min(b.lat,d.lat),e.lng=Math.max(c.lng,e.lng),e.lat=Math.max(c.lat,e.lat)):(this._sw=new _d(b.lng,b.lat),this._ne=new _d(c.lng,c.lat)),this}getCenter(){return new _d((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new _d(this.getWest(),this.getNorth())}getSouthEast(){return new _d(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(d){const{lng:a,lat:b}=_d.convert(d);let c=this._sw.lng<=a&&a<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=a&&a>=this._ne.lng),this._sw.lat<=b&&b<=this._ne.lat&&c}static convert(a){return!a||a instanceof $d?a:new $d(a)}}class _d{constructor(a,b){if(isNaN(a)||isNaN(b))throw new Error(`Invalid LngLat object: (${a}, ${b})`);if(this.lng=+a,this.lat=+b,this.lat>90||this.lat< -90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new _d(Yb(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(b){const a=Math.PI/180,c=this.lat*a,d=b.lat*a,e=Math.sin(c)*Math.sin(d)+Math.cos(c)*Math.cos(d)*Math.cos((b.lng-this.lng)*a);return 6371008.8*Math.acos(Math.min(e,1))}toBounds(c=0){const a=360*c/40075017,b=a/Math.cos(Math.PI/180*this.lat);return new $d(new _d(this.lng-b,this.lat-a),new _d(this.lng+b,this.lat+a))}static convert(a){if(a instanceof _d)return a;if(Array.isArray(a)&&(2===a.length||3===a.length))return new _d(Number(a[0]),Number(a[1]));if(!Array.isArray(a)&&"object"==typeof a&&null!==a)return new _d(Number("lng"in a?a.lng:a.lon),Number(a.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const xj=2*Math.PI*6371008.8;function yj(a){return xj*Math.cos(a*Math.PI/180)}function ae(a){return(180+a)/360}function be(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function ce(a,b){return a/yj(b)}function zj(a){return 360*a-180}function de(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function Aj(a,b){return a*yj(de(b))}class ee{constructor(a,b,c=0){this.x=+a,this.y=+b,this.z=+c}static fromLngLat(b,c=0){const a=_d.convert(b);return new ee(ae(a.lng),be(a.lat),ce(c,a.lat))}toLngLat(){return new _d(zj(this.x),de(this.y))}toAltitude(){return Aj(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/xj*(1/Math.cos(de(this.y)*Math.PI/180))}}function Bj(c,i,j,k,l,d,b,e,f){const g=(i+k)/2,h=(j+l)/2,a=new Ha(g,h);e(a),(function(e,f,a,b,g,h){const c=a-g,d=b-h;return Math.abs((b-f)*c-(a-e)*d)/Math.hypot(c,d)})(a.x,a.y,d.x,d.y,b.x,b.y)>=f?(Bj(c,i,j,g,h,d,a,e,f),Bj(c,g,h,k,l,a,b,e,f)):c.push(b)}function Cj(i,d,j){const b=[];let e,f,c;for(const a of i){const{x:g,y:h}=a;d(a),c?Bj(b,e,f,g,h,c,a,d,j):b.push(a),e=g,f=h,c=a}return b}function Dj(a,d){const b=Math.round(a.x*d),c=Math.round(a.y*d);return a.x=Wb(b,-16384,16383),a.y=Wb(c,-16384,16383),(ba.x+1||ca.y+1)&&gc("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function Ej(d,g,e){const a=d.loadGeometry(),f=d.extent,j=8192/f;if(g&&e&&e.projection.isReprojectedInTileSpace){const m=1<{const c=zj((g.x+a.x/f)/m),d=de((g.y+a.y/f)/m),b=q.project(c,d);a.x=(b.x*n-o)*f,a.y=(b.y*n-p)*f};for(let b=0;b=f||c.y<0||c.y>=f||(h(c),i.push(c));a[b]=i}}for(const k of a)for(const l of k)Dj(l,j);return a}function Fj(a,b){return{type:a.type,id:a.id,properties:a.properties,geometry:b?Ej(a):[]}}function Gj(a,b,c,d,e){a.emplaceBack(2*b+(d+1)/2,2*c+(e+1)/2)}class qb{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new na,this.indexArray=new sa,this.segments=new Aa,this.programConfigurations=new Yd(a.layers,a.zoom),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(g,h,a,m){const i=this.layers[0],d=[];let b=null;for(const{feature:c,id:n,index:o,sourceLayerIndex:p}of("circle"===i.type&&(b=i.layout.get("circle-sort-key")),g)){const j=this.layers[0]._featureFilter.needGeometry,e=Fj(c,j);if(!this.layers[0]._featureFilter.filter(new zd(this.zoom),e,a))continue;const q=b?b.evaluate(e,{},a):void 0,r={id:n,properties:c.properties,type:c.type,sourceLayerIndex:p,index:o,geometry:j?e.geometry:Ej(c,a,m),patterns:{},sortKey:q};d.push(r)}for(const k of(b&&d.sort((a,b)=>a.sortKey-b.sortKey),d)){const{geometry:l,index:f,sourceLayerIndex:s}=k,t=g[f].feature;this.addFeature(k,l,f,h.availableImages,a),h.featureIndex.insert(t,l,f,s,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,wj),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,g,h,i,j){for(const k of g)for(const f of k){const a=f.x,b=f.y;if(a<0||a>=8192||b<0||b>=8192)continue;const d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),c=d.vertexLength;Gj(this.layoutVertexArray,a,b,-1,-1),Gj(this.layoutVertexArray,a,b,1,-1),Gj(this.layoutVertexArray,a,b,1,1),Gj(this.layoutVertexArray,a,b,-1,1),this.indexArray.emplaceBack(c,c+1,c+2),this.indexArray.emplaceBack(c,c+3,c+2),d.vertexLength+=4,d.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,h,{},i,j)}}function fe(a,b){for(let c=0;c1){if(Kj(a,b))return!0;for(let c=0;c1?b:b.sub(a)._mult(d)._add(a))}function Oj(h,c){let b,a,d,e=!1;for(let f=0;fc.y!=d.y>c.y&&c.x<(d.x-a.x)*(c.y-a.y)/(d.y-a.y)+a.x&&(e=!e)}return e}function Pj(b,c){let d=!1;for(let e=0,g=b.length-1;ec.y!=f.y>c.y&&c.x<(f.x-a.x)*(c.y-a.y)/(f.y-a.y)+a.x&&(d=!d)}return d}function ge(a,d,e,f,g){for(const b of a)if(d<=b.x&&e<=b.y&&f>=b.x&&g>=b.y)return!0;const h=[new Ha(d,e),new Ha(d,g),new Ha(f,g),new Ha(f,e)];if(a.length>2){for(const i of h)if(Pj(a,i))return!0}for(let c=0;ce.x&&b.x>e.x||a.ye.y&&b.y>e.y)return!1;const f=Ef(a,b,c[0]);return f!==Ef(a,b,c[1])||f!==Ef(a,b,c[2])||f!==Ef(a,b,c[3])}function Rj(a,b,d){const c=b.paint.get(a).value;return"constant"===c.kind?c.value:d.programConfigurations.get(b.id).getMaxValue(a)}function Sj(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function Tj(a,b,f,g,h){if(!b[0]&&!b[1])return a;const d=Ha.convert(b)._mult(h);"viewport"===f&&d._rotate(-g);const e=[];for(let c=0;c{var a,b,c;const h=Qb([],j,d),i=1/h[3]/e*g;return a=h,b=h,c=[i,i,f?1/h[3]:i,i],a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a[3]=b[3]*c[3],a}),c=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(a=>{const c=Kb([],Mb([],Pb([],b[a[0]],b[a[1]]),Pb([],b[a[2]],b[a[1]]))),d=-Lb(c,b[a[1]]);return c.concat(d)});return new ie(b,c)}}class B{constructor(a,b){this.min=a,this.max=b,this.center=Ib([],Hb([],this.min,this.max),.5)}quadrant(d){const b=[d%2==0,d<2],e=tf(this.min),c=tf(this.max);for(let a=0;a=0;if(0===e)return 0;e!==c.length&&(j=!1)}if(j)return 2;for(let a=0;a<3;a++){let g=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let i=0;ithis.max[a]-this.min[a])return 0}return 1}}function Wj(b,l,c,g,h,a,i,m,d){if(a&&b.queryGeometry.isAboveHorizon)return!1;for(const n of(a&&(d*=b.pixelToTileUnitsFactor),l))for(const f of n){const e=f.add(m),j=h&&c.elevation?c.elevation.exaggeration()*h.getElevationAt(e.x,e.y,!0):0,o=a?e:Xj(e,j,g),p=a?b.tilespaceRays.map(a=>$j(a,j)):b.queryGeometry.screenGeometry,k=Qb([],[f.x,f.y,j,1],g);if(!i&&a?d*=k[3]/c.cameraToCenterDistance:i&&!a&&(d*=c.cameraToCenterDistance/k[3]),Hj(p,o,d))return!0}return!1}function Xj(b,c,d){const a=Qb([],[b.x,b.y,c,1],d);return new Ha(a[0]/a[3],a[1]/a[3])}const Yj=Q(0,0,0),Zj=Q(0,0,1);function $j(b,c){const a=Ma();return Yj[2]=c,b.intersectsPlane(Yj,Zj,a),new Ha(a[0],a[1])}class je extends qb{}function _j(b,{width:c,height:d},e,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==c*d*e)throw new RangeError("mismatched image size")}else a=new Uint8Array(c*d*e);return b.width=c,b.height=d,b.data=a,b}function ak(a,{width:b,height:c},d){if(b===a.width&&c===a.height)return;const e=_j({},{width:b,height:c},d);bk(a,e,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,b),height:Math.min(a.height,c)},d),a.width=b,a.height=c,a.data=e.data}function bk(c,b,d,e,a,h){if(0===a.width||0===a.height)return b;if(a.width>c.width||a.height>c.height||d.x>c.width-a.width||d.y>c.height-a.height)throw new RangeError("out of range source coordinates for image copy");if(a.width>b.width||a.height>b.height||e.x>b.width-a.width||e.y>b.height-a.height)throw new RangeError("out of range destination coordinates for image copy");const i=c.data,j=b.data;for(let f=0;f{o[a.evaluationKey]=e;const b=a.expression.evaluate(o);l.data[c+d+0]=Math.floor(255*b.r/b.a),l.data[c+d+1]=Math.floor(255*b.g/b.a),l.data[c+d+2]=Math.floor(255*b.b/b.a),l.data[c+d+3]=Math.floor(255*b.a)};if(a.clips)for(let c=0,h=0;c80*a){d=g=b[0],e=h=b[1];for(var l=a;lg&&(g=i),j>h&&(h=j);k=0!==(k=Math.max(g-d,h-e))?1/k:0}return hk(c,m,a,d,e,k),m}function fk(c,e,f,d,g){var a,b;if(g===Dk(c,e,f,d)>0)for(a=e;a=e;a-=d)b=Ak(a,c[a],c[a+1],b);return b&&uk(b,b.next)&&(Bk(b),b=b.next),b}function gk(c,b){if(!c)return c;b||(b=c);var d,a=c;do if(d=!1,a.steiner|| !uk(a,a.next)&&0!==tk(a.prev,a,a.next))a=a.next;else{if(Bk(a),(a=b=a.prev)===a.next)break;d=!0}while(d||a!==b)return b}function hk(a,b,c,e,f,d,h){if(a){!h&&d&&(function(b,c,d,e){var a=b;do null===a.z&&(a.z=pk(a.x,a.y,c,d,e)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==b)a.prevZ.nextZ=null,a.prevZ=null,(function(g){var h,b,a,c,d,i,e,f,j=1;do{for(b=g,g=null,d=null,i=0;b;){for(i++,a=b,e=0,h=0;h0||f>0&&a;)0!==e&&(0===f||!a||b.z<=a.z)?(c=b,b=b.nextZ,e--):(c=a,a=a.nextZ,f--),d?d.nextZ=c:g=c,c.prevZ=d,d=c;b=a}d.nextZ=null,j*=2}while(i>1)})(a)})(a,e,f,d);for(var i,g,j=a;a.prev!==a.next;)if(i=a.prev,g=a.next,d?jk(a,e,f,d):ik(a))b.push(i.i/c),b.push(a.i/c),b.push(g.i/c),Bk(a),a=g.next,j=g.next;else if((a=g)===j){h?1===h?hk(a=kk(gk(a),b,c),b,c,e,f,d,2):2===h&&lk(a,b,c,e,f,d):hk(gk(a),b,c,e,f,d,1);break}}}function ik(b){var c=b.prev,d=b,e=b.next;if(tk(c,d,e)>=0)return!1;for(var a=b.next.next;a!==b.prev;){if(rk(c.x,c.y,d.x,d.y,e.x,e.y,a.x,a.y)&&tk(a.prev,a,a.next)>=0)return!1;a=a.next}return!0}function jk(f,g,h,i){var d=f.prev,e=f,a=f.next;if(tk(d,e,a)>=0)return!1;for(var l=d.x>e.x?d.x>a.x?d.x:a.x:e.x>a.x?e.x:a.x,m=d.y>e.y?d.y>a.y?d.y:a.y:e.y>a.y?e.y:a.y,j=pk(d.x=j&&c&&c.z<=k;){if(b!==f.prev&&b!==f.next&&rk(d.x,d.y,e.x,e.y,a.x,a.y,b.x,b.y)&&tk(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,c!==f.prev&&c!==f.next&&rk(d.x,d.y,e.x,e.y,a.x,a.y,c.x,c.y)&&tk(c.prev,c,c.next)>=0)return!1;c=c.nextZ}for(;b&&b.z>=j;){if(b!==f.prev&&b!==f.next&&rk(d.x,d.y,e.x,e.y,a.x,a.y,b.x,b.y)&&tk(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;c&&c.z<=k;){if(c!==f.prev&&c!==f.next&&rk(d.x,d.y,e.x,e.y,a.x,a.y,c.x,c.y)&&tk(c.prev,c,c.next)>=0)return!1;c=c.nextZ}return!0}function kk(d,e,f){var a=d;do{var c=a.prev,b=a.next.next;!uk(c,b)&&vk(c,a,a.next,b)&&yk(c,b)&&yk(b,c)&&(e.push(c.i/f),e.push(a.i/f),e.push(b.i/f),Bk(a),Bk(a.next),a=d=b),a=a.next}while(a!==d)return gk(a)}function lk(d,e,f,g,h,i){var a=d;do{for(var b=a.next.next;b!==a.prev;){if(a.i!==b.i&&sk(a,b)){var c=zk(a,b);return a=gk(a,a.next),c=gk(c,c.next),hk(a,e,f,g,h,i),void hk(c,e,f,g,h,i)}b=b.next}a=a.next}while(a!==d)}function mk(a,b){return a.x-b.x}function nk(c,b){var a=function(h,k){var b,a=k,d=h.x,c=h.y,e=-1/0;do{if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){var f=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(f<=d&&f>e){if(e=f,f===d){if(c===a.y)return a;if(c===a.next.y)return a.next}b=a.x=a.x&&a.x>=l&&d!==a.x&&rk(cb.x||a.x===b.x&&ok(b,a)))&&(b=a,j=g)),a=a.next;while(a!==m)return b}(c,b);if(!a)return b;var d=zk(a,c),e=gk(a,a.next);return gk(d,d.next),b===a?e:b}function ok(a,b){return 0>tk(a.prev,a,b.prev)&&0>tk(b.next,a,a.next)}function pk(a,b,d,e,c){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-d)*c)|a<<8))|a<<4))|a<<2))|a<<1))|(b=1431655765&((b=858993459&((b=252645135&((b=16711935&((b=32767*(b-e)*c)|b<<8))|b<<4))|b<<2))|b<<1))<<1}function qk(c){var a=c,b=c;do(a.x=0&&(c-a)*(f-b)-(e-a)*(d-b)>=0&&(e-a)*(h-b)-(g-a)*(f-b)>=0}function sk(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(b,c){var a=b;do{if(a.i!==b.i&&a.next.i!==b.i&&a.i!==c.i&&a.next.i!==c.i&&vk(a,a.next,b,c))return!0;a=a.next}while(a!==b)return!1}(a,b)&&(yk(a,b)&&yk(b,a)&&(function(b,e){var a=b,c=!1,f=(b.x+e.x)/2,d=(b.y+e.y)/2;do a.y>d!=a.next.y>d&&a.next.y!==a.y&&f<(a.next.x-a.x)*(d-a.y)/(a.next.y-a.y)+a.x&&(c=!c),a=a.next;while(a!==b)return c})(a,b)&&(tk(a.prev,a,b.prev)||tk(a,b.prev,b))||uk(a,b)&&tk(a.prev,a,a.next)>0&&tk(b.prev,b,b.next)>0)}function tk(b,a,c){return(a.y-b.y)*(c.x-a.x)-(a.x-b.x)*(c.y-a.y)}function uk(a,b){return a.x===b.x&&a.y===b.y}function vk(a,b,c,d){var e=xk(tk(a,b,c)),f=xk(tk(a,b,d)),g=xk(tk(c,d,a)),h=xk(tk(c,d,b));return e!==f&&g!==h||!(0!==e||!wk(a,c,b))||!(0!==f||!wk(a,d,b))||!(0!==g||!wk(c,a,d))||!(0!==h||!wk(c,b,d))}function wk(a,b,c){return b.x<=Math.max(a.x,c.x)&&b.x>=Math.min(a.x,c.x)&&b.y<=Math.max(a.y,c.y)&&b.y>=Math.min(a.y,c.y)}function xk(a){return a>0?1:a<0?-1:0}function yk(a,b){return 0>tk(a.prev,a,a.next)?tk(a,b,a.next)>=0&&tk(a,a.prev,b)>=0:0>tk(a,b,a.prev)||0>tk(a,a.next,b)}function zk(a,b){var d=new Ck(a.i,a.x,a.y),c=new Ck(b.i,b.x,b.y),e=a.next,f=b.prev;return a.next=b,b.prev=a,d.next=e,e.prev=d,c.next=d,d.prev=c,f.next=c,c.prev=f,c}function Ak(c,d,e,b){var a=new Ck(c,d,e);return b?(a.next=b.next,a.prev=b,b.next.prev=a,b.next=a):(a.prev=a,a.next=a),a}function Bk(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function Ck(a,b,c){this.i=a,this.x=b,this.y=c,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Dk(b,g,d,e){for(var f=0,a=g,c=d-e;ab;){if(d-b>600){var f=d-b+1,k=e-b+1,l=Math.log(f),i=.5*Math.exp(2*l/3),m=.5*Math.sqrt(l*i*(f-i)/f)*(k-f/2<0?-1:1);Fk(a,e,Math.max(b,Math.floor(e-k*i/f+m)),Math.min(d,Math.floor(e+(f-k)*i/f+m)),g)}var j=a[e],h=b,c=d;for(Gk(a,b,e),g(a[d],j)>0&&Gk(a,b,d);hg(a[h],j);)h++;for(;g(a[c],j)>0;)c--}0===g(a[b],j)?Gk(a,b,c):Gk(a,++c,d),c<=e&&(b=c+1),e<=c&&(d=c-1)}}function Gk(a,b,c){var d=a[b];a[b]=a[c],a[c]=d}function Hk(a,b){return ab?1:0}function Ik(c,f){const i=c.length;if(i<=1)return[c];const a=[];let d,h;for(let e=0;e1)for(let b=0;b0&&c.holes.push(g+=b[a-1].length)}return c},ne.default=Ba;class oe{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new na,this.indexArray=new sa,this.indexArray2=new Y,this.programConfigurations=new Yd(a.layers,a.zoom),this.segments=new Aa,this.segments2=new Aa,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(i,a,b,l){this.hasPattern=Kk("fill",this.layers,a);const d=this.layers[0].layout.get("fill-sort-key"),e=[];for(const{feature:c,id:m,index:n,sourceLayerIndex:o}of i){const j=this.layers[0]._featureFilter.needGeometry,f=Fj(c,j);if(!this.layers[0]._featureFilter.filter(new zd(this.zoom),f,b))continue;const p=d?d.evaluate(f,{},b,a.availableImages):void 0,q={id:m,properties:c.properties,type:c.type,sourceLayerIndex:o,index:n,geometry:j?f.geometry:Ej(c,b,l),patterns:{},sortKey:p};e.push(q)}for(const g of(d&&e.sort((a,b)=>a.sortKey-b.sortKey),e)){const{geometry:k,index:h,sourceLayerIndex:r}=g;if(this.hasPattern){const s=Lk("fill",this.layers,g,this.zoom,a);this.patternFeatures.push(s)}else this.addFeature(g,k,h,b,{},a.availableImages);a.featureIndex.insert(i[h].feature,k,h,r,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(e,b,c,d){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,ek),this.indexBuffer=a.createIndexBuffer(this.indexArray),this.indexBuffer2=a.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(m,n,o,p,q,r=[]){for(const g of Ik(n,500)){let h=0;for(const s of g)h+=s.length;const i=this.segments.prepareSegment(h,this.layoutVertexArray,this.indexArray),j=i.vertexLength,c=[],l=[];for(const a of g){if(0===a.length)continue;a!==g[0]&&l.push(c.length/2);const k=this.segments2.prepareSegment(a.length,this.layoutVertexArray,this.indexArray2),f=k.vertexLength;this.layoutVertexArray.emplaceBack(a[0].x,a[0].y),this.indexArray2.emplaceBack(f+a.length-1,f),c.push(a[0].x),c.push(a[0].y);for(let b=1;b>3}if(d--,1===c||2===c)f+=b.readSVarint(),g+=b.readSVarint(),1===c&&(a&&e.push(a),a=[]),a.push(new Ha(f,g));else{if(7!==c)throw new Error("unknown command "+c);a&&a.push(a[0].clone())}}return a&&e.push(a),e},$.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var k=a.readVarint()+a.pos,b=1,e=0,c=0,d=0,f=1/0,g=-1/0,h=1/0,i=-1/0;a.pos>3}if(e--,1===b||2===b)(c+=a.readSVarint())g&&(g=c),(d+=a.readSVarint())i&&(i=d);else if(7!==b)throw new Error("unknown command "+b)}return[f,h,g,i]},$.prototype.toGeoJSON=function(h,i,j){var a,c,k=this.extent*Math.pow(2,j),l=this.extent*h,m=this.extent*i,b=this.loadGeometry(),d=$.types[this.type];function e(b){for(var a=0;a>3;c=1===b?a.readString():2===b?a.readFloat():3===b?a.readDouble():4===b?a.readVarint64():5===b?a.readVarint():6===b?a.readSVarint():7===b?a.readBoolean():null}return c}(c))}function Sk(c,d,a){if(3===c){var b=new se(a,a.readVarint()+a.pos);b.length&&(d[b.name]=b)}}te.prototype.feature=function(a){if(a<0||a>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[a];var b=this._pbf.readVarint()+this._pbf.pos;return new re(this._pbf,b,this.extent,this._keys,this._values)};var _={VectorTile:function(a,b){this.layers=a.readFields(Sk,{},b)},VectorTileFeature:re,VectorTileLayer:se};const Tk=_.VectorTileFeature.types;function Uk(a,b,c,d,e,f,g,h){a.emplaceBack((b<<1)+g,(c<<1)+f,(Math.floor(8192*d)<<1)+e,Math.round(h))}class ue{constructor(){this.acc=new Ha(0,0),this.polyCount=[]}startRing(a){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new Ha(a.x,a.y),this.max=new Ha(a.x,a.y))}append(a,c){this.currentPolyCount.edges++,this.acc._add(a);let b=!!this.borders;const d=this.min,e=this.max;a.xe.x&&(e.x=a.x,b=!0),a.ye.y&&(e.y=a.y,b=!0),((0===a.x||8192===a.x)&&a.x===c.x)!=((0===a.y||8192===a.y)&&a.y===c.y)&&this.processBorderOverlap(a,c),b&&this.checkBorderIntersection(a,c)}checkBorderIntersection(b,a){a.x<0!=b.x<0&&this.addBorderIntersection(0,Za(a.y,b.y,(0-a.x)/(b.x-a.x))),a.x>8192!=b.x>8192&&this.addBorderIntersection(1,Za(a.y,b.y,(8192-a.x)/(b.x-a.x))),a.y<0!=b.y<0&&this.addBorderIntersection(2,Za(a.x,b.x,(0-a.y)/(b.y-a.y))),a.y>8192!=b.y>8192&&this.addBorderIntersection(3,Za(a.x,b.x,(8192-a.y)/(b.y-a.y)))}addBorderIntersection(c,a){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const b=this.borders[c];ab[1]&&(b[1]=a)}processBorderOverlap(a,b){if(a.x===b.x){if(a.y===b.y)return;const c=0===a.x?0:1;this.addBorderIntersection(c,b.y),this.addBorderIntersection(c,a.y)}else{const d=0===a.y?2:3;this.addBorderIntersection(d,b.x),this.addBorderIntersection(d,a.x)}}centroid(){const a=this.polyCount.reduce((a,b)=>a+b.edges,0);return 0!==a?this.acc.div(a)._round():new Ha(0,0)}span(){return new Ha(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((a,b)=>a+ +(b[0]!==Number.MAX_VALUE),0)}}class ve{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new oa,this.centroidVertexArray=new Md,this.indexArray=new sa,this.programConfigurations=new Yd(a.layers,a.zoom),this.segments=new Aa,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.enableTerrain=a.enableTerrain}populate(i,b,c,j){for(const{feature:a,id:k,index:e,sourceLayerIndex:f}of(this.features=[],this.hasPattern=Kk("fill-extrusion",this.layers,b),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=(function(a){const b=Math.exp(Math.PI*(1-a.y/(1<a.x<=0)||l.every(a=>a.x>=8192)||l.every(a=>a.y<=0)||l.every(a=>a.y>=8192))continue;for(let u=0;u=1){const d=g[i-1];if(!Vk(c,d)){a&&a.append(c,d),b.vertexLength+4>Aa.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const n=c.sub(d)._perp(),o=n.x/(Math.abs(n.x)+Math.abs(n.y)),p=n.y>0?1:0,z=d.dist(c);f+z>32768&&(f=0),Uk(this.layoutVertexArray,c.x,c.y,o,p,0,0,f),Uk(this.layoutVertexArray,c.x,c.y,o,p,0,1,f),f+=z,Uk(this.layoutVertexArray,d.x,d.y,o,p,0,0,f),Uk(this.layoutVertexArray,d.x,d.y,o,p,0,1,f);const h=b.vertexLength;this.indexArray.emplaceBack(h,h+2,h+1),this.indexArray.emplaceBack(h+1,h+2,h+3),b.vertexLength+=4,b.primitiveLength+=2}}}}if(b.vertexLength+m>Aa.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray)),"Polygon"!==Tk[y.type])continue;const q=[],A=[],v=b.vertexLength;for(let w=0;w0){if(a.borders){a.vertexArrayOffset=this.centroidVertexArray.length;const G=a.borders,H=this.featuresOnBorder.push(a)-1;for(let t=0;t<4;t++)G[t][0]!==Number.MAX_VALUE&&this.borders[t].push(H)}this.encodeCentroid(a.borders?void 0:a.centroid(),a)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,y,C,E,F,D)}sortBorders(){for(let a=0;a<4;a++)this.borders[a].sort((b,c)=>this.featuresOnBorder[b].borders[a][0]-this.featuresOnBorder[c].borders[a][0])}encodeCentroid(b,e,f=!0){let c,a;if(b)if(0!==b.y){const h=e.span()._mult(this.tileToMeter);c=(Math.max(b.x,1)<<3)+Math.min(7,Math.round(h.x/10)),a=(Math.max(b.y,1)<<3)+Math.min(7,Math.round(h.y/10))}else c=Math.ceil(7*(b.x+450)),a=0;else c=0,a=+f;let g=f?this.centroidVertexArray.length:e.vertexArrayOffset;for(const d of e.polyCount){f&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*d.edges+d.top);for(let i=0;i<2*d.edges;i++)this.centroidVertexArray.emplace(g++,0,a),this.centroidVertexArray.emplace(g++,c,a);for(let j=0;j8192)||a.y===b.y&&(a.y<0||a.y>8192)}c("FillExtrusionBucket",ve,{omit:["layers","features"]}),c("PartMetadata",ue);var Wk={paint:new n({"fill-extrusion-opacity":new e(b["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new g(b["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new e(b["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new e(b["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new N(b["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new g(b["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new g(b["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new e(b["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Xk(a,b){return a.x*b.x+a.y*b.y}function Yk(i,a){if(1===i.length){let b=0;const c=a[b++];let d;for(;!d||c.equals(d);)if(!(d=a[b++]))return 1/0;for(;ba.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(a=>{this.gradients[a.id]={}}),this.layoutVertexArray=new hb,this.layoutVertexArray2=new pa,this.indexArray=new sa,this.programConfigurations=new Yd(a.layers,a.zoom),this.segments=new Aa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(j,a,b,m){this.hasPattern=Kk("line",this.layers,a);const e=this.layers[0].layout.get("line-sort-key"),f=[];for(const{feature:c,id:n,index:o,sourceLayerIndex:p}of j){const k=this.layers[0]._featureFilter.needGeometry,g=Fj(c,k);if(!this.layers[0]._featureFilter.filter(new zd(this.zoom),g,b))continue;const q=e?e.evaluate(g,{},b):void 0,r={id:n,properties:c.properties,type:c.type,sourceLayerIndex:p,index:o,geometry:k?g.geometry:Ej(c,b,m),patterns:{},sortKey:q};f.push(r)}e&&f.sort((a,b)=>a.sortKey-b.sortKey);const{lineAtlas:h,featureIndex:s}=a,t=this.addConstantDashes(h);for(const d of f){const{geometry:l,index:i,sourceLayerIndex:u}=d;if(t&&this.addFeatureDashes(d,h),this.hasPattern){const v=Lk("line",this.layers,d,this.zoom,a);this.patternFeatures.push(v)}else this.addFeature(d,l,i,b,h.positions,a.availableImages);s.insert(j[i].feature,l,i,u,this.index)}}addConstantDashes(b){let d=!1;for(const e of this.layers){const f=e.paint.get("line-dasharray").value,g=e.layout.get("line-cap").value;if("constant"!==f.kind||"constant"!==g.kind)d=!0;else{const c=g.value,a=f.value;if(!a)continue;b.addDash(a.from,c),b.addDash(a.to,c),a.other&&b.addDash(a.other,c)}}return d}addFeatureDashes(a,b){const c=this.zoom;for(const m of this.layers){const d=m.paint.get("line-dasharray").value,e=m.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===e.kind)continue;let g,h,i,j,k,l;if("constant"===d.kind){const f=d.value;if(!f)continue;g=f.other||f.to,h=f.to,i=f.from}else g=d.evaluate({zoom:c-1},a),h=d.evaluate({zoom:c},a),i=d.evaluate({zoom:c+1},a);"constant"===e.kind?j=k=l=e.value:(j=e.evaluate({zoom:c-1},a),k=e.evaluate({zoom:c},a),l=e.evaluate({zoom:c+1},a)),b.addDash(g,j),b.addDash(h,k),b.addDash(i,l);const n=b.getKey(g,j),o=b.getKey(h,k),p=b.getKey(i,l);a.patterns[m.id]={min:n,mid:o,max:p}}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(e,b,c,d){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=a.createVertexBuffer(this.layoutVertexArray2,al)),this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,_k),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(a){if(a.properties&&a.properties.hasOwnProperty("mapbox_clip_start")&&a.properties.hasOwnProperty("mapbox_clip_end"))return{start:+a.properties.mapbox_clip_start,end:+a.properties.mapbox_clip_end}}addFeature(a,c,d,e,f,g){const b=this.layers[0].layout,h=b.get("line-join").evaluate(a,{}),i=b.get("line-cap").evaluate(a,{}),j=b.get("line-miter-limit"),k=b.get("line-round-limit");for(const l of(this.lineClips=this.lineFeatureClips(a),c))this.addLine(l,a,h,i,j,k);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,a,d,f,g,e)}addLine(g,K,A,L,v,M){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let q=0;q=2&&g[i-1].equals(g[i-2]);)i--;let l=0;for(;l0;if(B&&m>l){const C=a.dist(h);if(C>2*s){const w=a.sub(a.sub(h)._mult(s/C)._round());this.updateDistance(h,w),this.addCurrentVertex(w,d,0,0,c),h=w}}const D=h&&j;let e=D?A:r?"butt":L;if(D&&"round"===e&&(kv&&(e="bevel"),"bevel"===e&&(k>2&&(e="flipbevel"),k100)f=b.mult(-1);else{const O=k*d.add(b).mag()/d.sub(b).mag();f._perp()._mult(O*(p?-1:1))}this.addCurrentVertex(a,f,0,0,c),this.addCurrentVertex(a,f.mult(-1),0,0,c)}else if("bevel"===e||"fakeround"===e){const E=-Math.sqrt(k*k-1),F=p?E:0,G=p?0:E;if(h&&this.addCurrentVertex(a,d,F,G,c),"fakeround"===e){const H=Math.round(180*N/Math.PI/20);for(let x=1;x2*s){const z=a.add(j.sub(a)._mult(s/J)._round());this.updateDistance(a,z),this.addCurrentVertex(z,b,0,0,c),a=z}}}}addCurrentVertex(d,a,b,c,e,f=!1){const g=a.y*c-a.x,h=-a.y-a.x*c;this.addHalfVertex(d,a.x+a.y*b,a.y-a.x*b,f,!1,b,e),this.addHalfVertex(d,g,h,f,!0,-c,e)}addHalfVertex({x:e,y:f},g,h,i,b,c,d){this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(f<<1)+(b?1:0),Math.round(63*g)+128,Math.round(63*h)+128,1+(0===c?0:c<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const a=d.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,a),d.primitiveLength++),b?this.e2=a:this.e1=a}updateScaledDistance(){if(this.lineClips){const a=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=a*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(a,b){this.distance+=a.dist(b),this.updateScaledDistance()}}c("LineBucket",ye,{omit:["layers","patternFeatures"]});const ze=new n({"line-cap":new g(b.layout_line["line-cap"]),"line-join":new g(b.layout_line["line-join"]),"line-miter-limit":new e(b.layout_line["line-miter-limit"]),"line-round-limit":new e(b.layout_line["line-round-limit"]),"line-sort-key":new g(b.layout_line["line-sort-key"])});var Ae={paint:new n({"line-opacity":new g(b.paint_line["line-opacity"]),"line-color":new g(b.paint_line["line-color"]),"line-translate":new e(b.paint_line["line-translate"]),"line-translate-anchor":new e(b.paint_line["line-translate-anchor"]),"line-width":new g(b.paint_line["line-width"]),"line-gap-width":new g(b.paint_line["line-gap-width"]),"line-offset":new g(b.paint_line["line-offset"]),"line-blur":new g(b.paint_line["line-blur"]),"line-dasharray":new N(b.paint_line["line-dasharray"]),"line-pattern":new N(b.paint_line["line-pattern"]),"line-gradient":new V(b.paint_line["line-gradient"])}),layout:ze};const Be=new class extends g{possiblyEvaluate(b,a){return a=new zd(Math.floor(a.zoom),{now:a.now,fadeDuration:a.fadeDuration,zoomHistory:a.zoomHistory,transition:a.transition}),super.possiblyEvaluate(b,a)}evaluate(b,a,c,d){return a=_b({},a,{zoom:Math.floor(a.zoom)}),super.evaluate(b,a,c,d)}}(Ae.paint.properties["line-width"].specification);function dl(a,b){return b>0?b+2*a:a}Be.useIntegerZoom=!0;const el=j([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),fl=j([{name:"a_projected_pos",components:3,type:"Float32"}],4);j([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const gl=j([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),hl=j([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);j([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const il=j([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ce=j([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function De(e,i){const{expression:a}=i;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new zd(e+1))};if("source"===a.kind)return{kind:"source"};{const{zoomStops:b,interpolationType:h}=a;let c=0;for(;c{a.text=(function(a,c,d){const b=c.layout.get("text-transform").evaluate(d,{});return"uppercase"===b?a=a.toLocaleUpperCase():"lowercase"===b&&(a=a.toLocaleLowerCase()),yd.applyArabicShaping&&(a=yd.applyArabicShaping(a)),a})(a.text,b,c)}),a}const kl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","\xa2":"¢","\xa3":"£","\xa5":"¥","\xa6":"¦","\xac":"¬","\xaf":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function ll(a){return"︶"===a||"﹈"===a||"︸"===a||"﹄"===a||"﹂"===a||"︾"===a||"︼"===a||"︺"===a||"︘"===a||"﹀"===a||"︐"===a||"︓"===a||"︔"===a||"`"===a||" ̄"===a||"︑"===a||"︒"===a}function ml(a){return"︵"===a||"﹇"===a||"︷"===a||"﹃"===a||"﹁"===a||"︽"===a||"︻"===a||"︹"===a||"︗"===a||"︿"===a}var nl=function(g,h,j,e,k){var a,c,l=8*k-e-1,m=(1<>1,b=-7,d=j?k-1:0,i=j?-1:1,f=g[h+d];for(d+=i,a=f&(1<< -b)-1,f>>=-b,b+=l;b>0;a=256*a+g[h+d],d+=i,b-=8);for(c=a&(1<< -b)-1,a>>=-b,b+=e;b>0;c=256*c+g[h+d],d+=i,b-=8);if(0===a)a=1-n;else{if(a===m)return c?NaN:1/0*(f?-1:1);c+=Math.pow(2,e),a-=n}return(f?-1:1)*c*Math.pow(2,a-e)},ol=function(j,b,k,m,c,n){var a,d,e,h=8*n-c-1,i=(1<>1,o=23===c?5960464477539062e-23:0,g=m?0:n-1,l=m?1:-1,p=b<0||0===b&&1/b<0?1:0;for(isNaN(b=Math.abs(b))||b===1/0?(d=isNaN(b)?1:0,a=i):(a=Math.floor(Math.log(b)/Math.LN2),b*(e=Math.pow(2,-a))<1&&(a--,e*=2),(b+=a+f>=1?o/e:o*Math.pow(2,1-f))*e>=2&&(a++,e/=2),a+f>=i?(d=0,a=i):a+f>=1?(d=(b*e-1)*Math.pow(2,c),a+=f):(d=b*Math.pow(2,f-1)*Math.pow(2,c),a=0));c>=8;j[k+g]=255&d,g+=l,d/=256,c-=8);for(a=a<0;j[k+g]=255&a,g+=l,a/=256,h-=8);j[k+g-l]|=128*p},Fe=P;function P(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}P.Varint=0,P.Fixed64=1,P.Bytes=2,P.Fixed32=5;var pl="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function ql(a){return a.type===P.Bytes?a.readVarint()+a.pos:a.pos+1}function rl(a,b,c){return c?4294967296*b+(a>>>0):4294967296*(b>>>0)+(a>>>0)}function sl(e,a,b){var d=a<=16383?1:a<=2097151?2:a<=268435455?3:Math.floor(Math.log(a)/(7*Math.LN2));b.realloc(d);for(var c=b.pos-1;c>=e;c--)b.buf[c+d]=b.buf[c]}function tl(b,c){for(var a=0;a>>8,a[c+2]=b>>>16,a[c+3]=b>>>24}function El(a,b){return(a[b]|a[b+1]<<8|a[b+2]<<16)+(a[b+3]<<24)}function Fl(b,a,c){a.glyphs=[],1===b&&c.readMessage(Gl,a)}function Gl(a,b,c){if(3===a){const{id:f,bitmap:g,width:d,height:e,left:h,top:i,advance:j}=c.readMessage(Hl,{});b.glyphs.push({id:f,bitmap:new ke({width:d+6,height:e+6},g),metrics:{width:d,height:e,left:h,top:i,advance:j}})}else 4===a?b.ascender=c.readSVarint():5===a&&(b.descender=c.readSVarint())}function Hl(a,b,c){1===a?b.id=c.readVarint():2===a?b.bitmap=c.readBytes():3===a?b.width=c.readVarint():4===a?b.height=c.readVarint():5===a?b.left=c.readSVarint():6===a?b.top=c.readSVarint():7===a&&(b.advance=c.readVarint())}function Ge(g){let h=0,i=0;for(const j of g)h+=j.w*j.h,i=Math.max(i,j.w);g.sort((a,b)=>b.h-a.h);const c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(h/.95)),i),h:1/0}];let e=0,f=0;for(const a of g)for(let d=c.length-1;d>=0;d--){const b=c[d];if(!(a.w>b.w||a.h>b.h)){if(a.x=b.x,a.y=b.y,f=Math.max(f,a.y+a.h),e=Math.max(e,a.x+a.w),a.w===b.w&&a.h===b.h){const k=c.pop();d>3,f=this.pos;this.type=7&b,d(e,c,this),this.pos===f&&this.skip(b)}return c},readMessage:function(a,b){return this.readFields(a,b,this.readVarint()+this.pos)},readFixed32:function(){var a=Cl(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=El(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=Cl(this.buf,this.pos)+4294967296*Cl(this.buf,this.pos+4);return this.pos+=8,a},readSFixed64:function(){var a=Cl(this.buf,this.pos)+4294967296*El(this.buf,this.pos+4);return this.pos+=8,a},readFloat:function(){var a=nl(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=nl(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(d){var a,b,c=this.buf;return a=127&(b=c[this.pos++]),b<128?a:(a|=(127&(b=c[this.pos++]))<<7,b<128?a:(a|=(127&(b=c[this.pos++]))<<14,b<128?a:(a|=(127&(b=c[this.pos++]))<<21,b<128?a:(function(d,e,c){var a,b,f=c.buf;if(a=(112&(b=f[c.pos++]))>>4,b<128)return rl(d,a,e);if(a|=(127&(b=f[c.pos++]))<<3,b<128)return rl(d,a,e);if(a|=(127&(b=f[c.pos++]))<<10,b<128)return rl(d,a,e);if(a|=(127&(b=f[c.pos++]))<<17,b<128)return rl(d,a,e);if(a|=(127&(b=f[c.pos++]))<<24,b<128)return rl(d,a,e);if(a|=(1&(b=f[c.pos++]))<<31,b<128)return rl(d,a,e);throw new Error("Expected varint not more than 10 bytes")})(a|=(15&(b=c[this.pos]))<<28,d,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?-((a+1)/2):a/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var c,d,e,a=this.readVarint()+this.pos,b=this.pos;return this.pos=a,a-b>=12&&pl?(c=this.buf,d=b,e=a,pl.decode(c.subarray(d,e))):(function(d,k,j){for(var h="",b=k;b239?4:c>223?3:c>191?2:1;if(b+e>j)break;1===e?c<128&&(a=c):2===e?128==(192&(f=d[b+1]))&&(a=(31&c)<<6|63&f)<=127&&(a=null):3===e?(g=d[b+2],128==(192&(f=d[b+1]))&&128==(192&g)&&((a=(15&c)<<12|(63&f)<<6|63&g)<=2047||a>=55296&&a<=57343)&&(a=null)):4===e&&(g=d[b+2],i=d[b+3],128==(192&(f=d[b+1]))&&128==(192&g)&&128==(192&i)&&((a=(15&c)<<18|(63&f)<<12|(63&g)<<6|63&i)<=65535||a>=1114112)&&(a=null)),null===a?(a=65533,e=1):a>65535&&(a-=65536,h+=String.fromCharCode(a>>>10&1023|55296),a=56320|1023&a),h+=String.fromCharCode(a),b+=e}return h})(this.buf,b,a)},readBytes:function(){var a=this.readVarint()+this.pos,b=this.buf.subarray(this.pos,a);return this.pos=a,b},readPackedVarint:function(a,b){if(this.type!==P.Bytes)return a.push(this.readVarint(b));var c=ql(this);for(a=a||[];this.pos127;);else if(a===P.Bytes)this.pos=this.readVarint()+this.pos;else if(a===P.Fixed32)this.pos+=4;else{if(a!==P.Fixed64)throw new Error("Unimplemented type: "+a);this.pos+=8}},writeTag:function(a,b){this.writeVarint(a<<3|b)},realloc:function(c){for(var a=this.length||16;a268435455||a<0?(function(e,h){var f,g,d,c,a,b,i;if(e>=0?(f=e%4294967296|0,g=e/4294967296|0):(g=~(-e/4294967296),4294967295^(f=~(-e%4294967296))?f=f+1|0:(f=0,g=g+1|0)),e>=0x7fffffffffffffff||e< 0x8000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");h.realloc(10),d=f,(c=h).buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,c.buf[c.pos]=127&(d>>>=7),a=g,b=h,i=(7&a)<<4,b.buf[b.pos++]|=i|((a>>>=3)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a)))))})(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?-(2*a)-1:2*a)},writeBoolean:function(a){this.writeVarint(Boolean(a))},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var c=this.pos;this.pos=(function(c,f,b){for(var a,d,e=0;e55295&&a<57344){if(!d){a>56319||e+1===f.length?(c[b++]=239,c[b++]=191,c[b++]=189):d=a;continue}if(a<56320){c[b++]=239,c[b++]=191,c[b++]=189,d=a;continue}a=d-55296<<10|a-56320|65536,d=null}else d&&(c[b++]=239,c[b++]=191,c[b++]=189,d=null);a<128?c[b++]=a:(a<2048?c[b++]=a>>6|192:(a<65536?c[b++]=a>>12|224:(c[b++]=a>>18|240,c[b++]=a>>12&63|128),c[b++]=a>>6&63|128),c[b++]=63&a|128)}return b})(this.buf,a,this.pos);var b=this.pos-c;b>=128&&sl(c,b,this),this.pos=c-1,this.writeVarint(b),this.pos+=b},writeFloat:function(a){this.realloc(4),ol(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),ol(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(c){var a=c.length;this.writeVarint(a),this.realloc(a);for(var b=0;b=128&&sl(b,a,this),this.pos=b-1,this.writeVarint(a),this.pos+=a},writeMessage:function(a,b,c){this.writeTag(a,P.Bytes),this.writeRawMessage(b,c)},writePackedVarint:function(b,a){a.length&&this.writeMessage(b,tl,a)},writePackedSVarint:function(b,a){a.length&&this.writeMessage(b,ul,a)},writePackedBoolean:function(b,a){a.length&&this.writeMessage(b,xl,a)},writePackedFloat:function(b,a){a.length&&this.writeMessage(b,vl,a)},writePackedDouble:function(b,a){a.length&&this.writeMessage(b,wl,a)},writePackedFixed32:function(b,a){a.length&&this.writeMessage(b,yl,a)},writePackedSFixed32:function(b,a){a.length&&this.writeMessage(b,zl,a)},writePackedFixed64:function(b,a){a.length&&this.writeMessage(b,Al,a)},writePackedSFixed64:function(b,a){a.length&&this.writeMessage(b,Bl,a)},writeBytesField:function(a,b){this.writeTag(a,P.Bytes),this.writeBytes(b)},writeFixed32Field:function(a,b){this.writeTag(a,P.Fixed32),this.writeFixed32(b)},writeSFixed32Field:function(a,b){this.writeTag(a,P.Fixed32),this.writeSFixed32(b)},writeFixed64Field:function(a,b){this.writeTag(a,P.Fixed64),this.writeFixed64(b)},writeSFixed64Field:function(a,b){this.writeTag(a,P.Fixed64),this.writeSFixed64(b)},writeVarintField:function(a,b){this.writeTag(a,P.Varint),this.writeVarint(b)},writeSVarintField:function(a,b){this.writeTag(a,P.Varint),this.writeSVarint(b)},writeStringField:function(a,b){this.writeTag(a,P.Bytes),this.writeString(b)},writeFloatField:function(a,b){this.writeTag(a,P.Fixed32),this.writeFloat(b)},writeDoubleField:function(a,b){this.writeTag(a,P.Fixed64),this.writeDouble(b)},writeBooleanField:function(a,b){this.writeVarintField(a,Boolean(b))}};class ub{constructor(a,{pixelRatio:b,version:c,stretchX:d,stretchY:e,content:f}){this.paddedRect=a,this.pixelRatio=b,this.stretchX=d,this.stretchY=e,this.content=f,this.version=c}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class He{constructor(g,h){const i={},j={};this.haveRenderCallbacks=[];const k=[];this.addImages(g,i,k),this.addImages(h,j,k);const{w:q,h:r}=Ge(k),b=new rb({width:q||1,height:r||1});for(const l in g){const m=g[l],n=i[l].paddedRect;rb.copy(m.data,b,{x:0,y:0},{x:n.x+1,y:n.y+1},m.data)}for(const o in h){const a=h[o],p=j[o].paddedRect,c=p.x+1,d=p.y+1,e=a.data.width,f=a.data.height;rb.copy(a.data,b,{x:0,y:0},{x:c,y:d},a.data),rb.copy(a.data,b,{x:0,y:f-1},{x:c,y:d-1},{width:e,height:1}),rb.copy(a.data,b,{x:0,y:0},{x:c,y:d+f},{width:e,height:1}),rb.copy(a.data,b,{x:e-1,y:0},{x:c-1,y:d},{width:1,height:f}),rb.copy(a.data,b,{x:0,y:0},{x:c+e,y:d},{width:1,height:f})}this.image=b,this.iconPositions=i,this.patternPositions=j}addImages(c,e,f){for(const b in c){const a=c[b],d={x:0,y:0,w:a.data.width+2,h:a.data.height+2};f.push(d),e[b]=new ub(d,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(b)}}patchUpdatedImages(a,c){for(const b in a.dispatchRenderCallbacks(this.haveRenderCallbacks),a.updatedImages)this.patchUpdatedImage(this.iconPositions[b],a.getImage(b),c),this.patchUpdatedImage(this.patternPositions[b],a.getImage(b),c)}patchUpdatedImage(a,b,c){if(!a||!b)return;if(a.version===b.version)return;a.version=b.version;const[d,e]=a.tl;c.update(b.data,void 0,{x:d,y:e})}}c("ImagePosition",ub),c("ImageAtlas",He);const Ie={horizontal:1,vertical:2,horizontalOnly:3};class Il{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(b,c){const a=new Il;return a.scale=b||1,a.fontStack=c,a}static forImage(b){const a=new Il;return a.imageName=b,a}}class Jl{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(d,e){const a=new Jl;for(let b=0;b=0&&b>=a&&Ll[this.text.charCodeAt(b)];b--)d--;this.text=this.text.substring(a,d),this.sectionIndex=this.sectionIndex.slice(a,d)}substring(b,c){const a=new Jl;return a.text=this.text.substring(b,c),a.sectionIndex=this.sectionIndex.slice(b,c),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((a,b)=>Math.max(a,this.sections[b].scale),0)}addTextSection(a,c){this.text+=a.text,this.sections.push(Il.forText(a.scale,a.fontStack||c));const d=this.sections.length-1;for(let b=0;b=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Kl(u,c,v,d,w,i,x,y,z,e,f,j,m,k,l,A){const a=Jl.fromFeature(u,w);let b;j===Ie.vertical&&a.verticalizePunctuation(m);const{processBidirectionalText:n,processStyledBidirectionalText:o}=yd;if(n&&1===a.sections.length){b=[];const B=n(a.toString(),Sl(a,e,i,c,d,k,l));for(const p of B){const g=new Jl;g.text=p,g.sections=a.sections;for(let q=0;q0&&D>k&&(k=D)}else{const E=U[e.fontStack];if(!E)continue;E[c]&&(u=E[c]);const l=H[e.fontStack];if(!l)continue;const P=l.glyphs[c];if(!P)continue;if(d=P.metrics,B=8203!==c?24:0,i){const F=void 0!==l.ascender?Math.abs(l.ascender):0,Q=void 0!==l.descender?Math.abs(l.descender):0,R=(F+Q)*a;M=0;let f=0;for(let c=0;c -j/2;){if(a--,a<0)return!1;c-=b[a].dist(k),k=b[a]}c+=b[a].dist(b[a+1]),a++;const f=[];let g=0;for(;cl;)g-=f.shift().angleDelta;if(g>m)return!1;a++,c+=h.dist(i)}return!0}function Xl(b){let c=0;for(let a=0;aj){const k=(j-e)/f,q=Za(c.x,d.x,k),r=Za(c.y,d.y,k),l=new Ke(q,r,0,d.angleTo(c),b);return!i||Wl(a,l,p,i,m)?l:void 0}e+=f}}function _l(b,a,k,f,l,g,c,h,d){const m=Yl(f,g,c),i=Zl(f,l),e=i*c,j=0===b[0].x||b[0].x===d||0===b[0].y||b[0].y===d;return a-e=0&&m=0&&n=0&&b+r<=v){const o=new Ke(m,n,0,w,c);o._round(),i&&!Wl(a,o,j,i,p)||f.push(o)}}e+=l}return u||f.length||q||(f=am(a,e/2,d,i,p,j,q,!0,k)),f}function Le(k,c,d,e,f){const l=[];for(let i=0;i=e&&b.x>=e||(a.x>=e?a=new Ha(e,a.y+(e-a.x)/(b.x-a.x)*(b.y-a.y))._round():b.x>=e&&(b=new Ha(e,a.y+(e-a.x)/(b.x-a.x)*(b.y-a.y))._round()),a.y>=f&&b.y>=f||(a.y>=f?a=new Ha(a.x+(f-a.y)/(b.y-a.y)*(b.x-a.x),f)._round():b.y>=f&&(b=new Ha(a.x+(f-a.y)/(b.y-a.y)*(b.x-a.x),f)._round()),g&&a.equals(g[g.length-1])||(g=[a],l.push(g)),g.push(b)))))}}return l}function bm(f,a,b,g,h,c,i,j,k){for(let d=a;d -1)b++,f[b]=a,c[b]=j,c[b+1]=1e20}for(let e=0,k=0;e{let a=this.entries[b];a||(a=this.entries[b]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let d=a.glyphs[c];if(void 0!==d)return void f(null,{stack:b,id:c,glyph:d});if(d=this._tinySDF(a,b,c))return a.glyphs[c]=d,void f(null,{stack:b,id:c,glyph:d});const e=Math.floor(c/256);if(256*e>65535)return void f(new Error("glyphs > 65535 not supported"));if(a.ranges[e])return void f(null,{stack:b,id:c,glyph:d});let g=a.requests[e];g||(g=a.requests[e]=[],Ca.loadGlyphRange(b,e,this.url,this.requestManager,(d,b)=>{if(b){for(const c in a.ascender=b.ascender,a.descender=b.descender,b.glyphs)this._doesCharSupportLocalGlyph(+c)||(a.glyphs[+c]=b.glyphs[+c]);a.ranges[e]=!0}for(const f of g)f(d,b);delete a.requests[e]})),g.push((a,d)=>{a?f(a):d&&f(null,{stack:b,id:c,glyph:d.glyphs[c]||null})})},(d,f)=>{if(d)e(d);else if(f){const b={};for(const{stack:a,id:g,glyph:c}of f)void 0===b[a]&&(b[a]={}),void 0===b[a].glyphs&&(b[a].glyphs={}),b[a].glyphs[g]=c&&{id:c.id,bitmap:c.bitmap.clone(),metrics:c.metrics},b[a].ascender=this.entries[a].ascender,b[a].descender=this.entries[a].descender;e(null,b)}})}_doesCharSupportLocalGlyph(a){return this.localGlyphMode!==Me.none&&(this.localGlyphMode===Me.all?!!this.localFontFamily:!!this.localFontFamily&&(zi(a)||Ci(a)||qi(a)||ri(a))||pi(a))}_tinySDF(e,d,a){const f=this.localFontFamily;if(!f||!this._doesCharSupportLocalGlyph(a))return;let b=e.tinySDF;if(!b){let c="400";/bold/i.test(d)?c="900":/medium/i.test(d)?c="500":/light/i.test(d)&&(c="200"),(b=e.tinySDF=new Ca.TinySDF({fontFamily:f,fontWeight:c,fontSize:48,buffer:6,radius:16})).fontWeight=c}if(this.localGlyphs[b.fontWeight][a])return this.localGlyphs[b.fontWeight][a];const g=String.fromCharCode(a),{data:h,width:i,height:j,glyphWidth:k,glyphHeight:l,glyphLeft:m,glyphTop:n,glyphAdvance:o}=b.draw(g);return this.localGlyphs[b.fontWeight][a]={id:a,bitmap:new ke({width:i,height:j},h),metrics:{width:k/2,height:l/2,left:m/2,top:n/2-27,advance:o/2,localGlyph:!0}}}}function dm(c,D,E,o){const h=[],b=c.image,F=b.pixelRatio,i=b.paddedRect.w-2,j=b.paddedRect.h-2,G=c.right-c.left,H=c.bottom-c.top,d=b.stretchX||[[0,i]],e=b.stretchY||[[0,j]],p=(b,a)=>b+a[1]-a[0],k=d.reduce(p,0),l=e.reduce(p,0),q=i-k,r=j-l;let s=0,t=k,u=0,v=l,x=0,y=q,z=0,A=r;if(b.content&&o){const a=b.content;s=em(d,0,a[0]),u=em(e,0,a[1]),t=em(d,a[0],a[2]),v=em(e,a[1],a[3]),x=a[0]-s,z=a[1]-u,y=a[2]-a[0]-t,A=a[3]-a[1]-v}const w=(a,d,e,f)=>{const i=gm(a.stretch-s,t,G,c.left),J=hm(a.fixed-x,y,a.stretch,k),j=gm(d.stretch-u,v,H,c.top),K=hm(d.fixed-z,A,d.stretch,l),m=gm(e.stretch-s,t,G,c.left),L=hm(e.fixed-x,y,e.stretch,k),n=gm(f.stretch-u,v,H,c.top),M=hm(f.fixed-z,A,f.stretch,l),o=new Ha(i,j),p=new Ha(m,j),q=new Ha(m,n),r=new Ha(i,n),N=new Ha(J/F,K/F),O=new Ha(L/F,M/F),h=D*Math.PI/180;if(h){const w=Math.sin(h),B=Math.cos(h),g=[B,-w,w,B];o._matMult(g),p._matMult(g),r._matMult(g),q._matMult(g)}const C=a.stretch+a.fixed,I=d.stretch+d.fixed;return{tl:o,tr:p,bl:r,br:q,tex:{x:b.paddedRect.x+1+C,y:b.paddedRect.y+1+I,w:e.stretch+e.fixed-C,h:f.stretch+f.fixed-I},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:N,pixelOffsetBR:O,minFontScaleX:y/F/G,minFontScaleY:A/F/H,isSDF:E}};if(o&&(b.stretchX||b.stretchY)){const m=fm(d,q,k),n=fm(e,r,l);for(let f=0;f{if(b)g(b);else if(c){var d;const e={},a=(d=c,new Fe(d).readFields(Fl,{}));for(const f of a.glyphs)e[f.id]=f;g(null,{glyphs:e,ascender:a.ascender,descender:a.descender})}})},Ca.TinySDF=class{constructor({fontSize:c=24,buffer:d=3,radius:e=8,cutoff:f=.25,fontFamily:g="sans-serif",fontWeight:h="normal",fontStyle:i="normal"}){this.buffer=d,this.cutoff=f,this.radius=e;const a=this.size=c+4*d,j=this._createCanvas(a),b=this.ctx=j.getContext("2d",{willReadFrequently:!0});b.font=`${i} ${h} ${c}px ${g}`,b.textBaseline="alphabetic",b.textAlign="left",b.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(b){const a=document.createElement("canvas");return a.width=a.height=b,a}draw(p){const{width:u,actualBoundingBoxAscent:q,actualBoundingBoxDescent:v,actualBoundingBoxLeft:w,actualBoundingBoxRight:x}=this.ctx.measureText(p),r=Math.floor(q),b=Math.min(this.size-this.buffer,Math.ceil(x-w)),c=Math.min(this.size-this.buffer,Math.ceil(q)+Math.ceil(v)),d=b+2*this.buffer,m=c+2*this.buffer,i=d*m,s=new Uint8ClampedArray(i),t={data:s,width:d,height:m,glyphWidth:b,glyphHeight:c,glyphTop:r,glyphLeft:0,glyphAdvance:u};if(0===b||0===c)return t;const{ctx:n,buffer:a,gridInner:f,gridOuter:g}=this;n.clearRect(a,a,b,c),n.fillText(p,a,a+r+1);const y=n.getImageData(a,a,b,c);g.fill(1e20,0,i),f.fill(0,0,i);for(let j=0;j0?e*e:0,f[l]=e<0?e*e:0}}bm(g,0,0,d,m,d,this.f,this.v,this.z),bm(f,a,a,b,c,d,this.f,this.v,this.z);for(let h=0;hb?1:0}){if(this.data=b,this.length=this.data.length,this.compare=c,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(a){this.data.push(a),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const a=this.data[0],b=this.data.pop();return this.length--,this.length>0&&(this.data[0]=b,this._down(0)),a}peek(){return this.data[0]}_up(a){const{data:b,compare:f}=this,c=b[a];for(;a>0;){const d=a-1>>1,e=b[d];if(f(c,e)>=0)break;b[a]=e,a=d}b[a]=c}_down(a){const{data:b,compare:f}=this,h=this.length>>1,g=b[a];for(;af(b[e],d)&&(c=e,d=b[e]),f(d,g)>=0)break;b[a]=d,a=c}b[a]=g}}function km(e,r=1,p=!1){let h=1/0,i=1/0,j=-1/0,k=-1/0;const q=e[0];for(let f=0;fj)&&(j=c.x),(!f||c.y>k)&&(k=c.y)}const l=Math.min(j-h,k-i);let a=l/2;const d=new jm([],lm);if(0===l)return new Ha(h,i);for(let m=h;mg.d||!g.d)&&(g=b,p&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,o)),b.max-g.d<=r||(a=b.h/2,d.push(new mm(b.p.x-a,b.p.y-a,a,e)),d.push(new mm(b.p.x+a,b.p.y-a,a,e)),d.push(new mm(b.p.x-a,b.p.y+a,a,e)),d.push(new mm(b.p.x+a,b.p.y+a,a,e)),o+=4)}return p&&(console.log(`num probes: ${o}`),console.log(`best distance: ${g.d}`)),g.p}function lm(a,b){return b.max-a.max}function mm(a,b,c,d){this.p=new Ha(a,b),this.h=c,this.d=(function(b,i){let d=!1,e=1/0;for(let f=0;fb.y!=c.y>b.y&&b.x<(c.x-a.x)*(b.y-a.y)/(c.y-a.y)+a.x&&(d=!d),e=Math.min(e,Nj(b,a,c))}}return(d?1:-1)*Math.sqrt(e)})(this.p,d),this.max=this.d+this.h*Math.SQRT2}const nm=Number.POSITIVE_INFINITY,om=Math.sqrt(2);function Ne(b,a){return a[1]!==nm?(function(e,a,b){let c=0,d=0;switch(a=Math.abs(a),b=Math.abs(b),e){case"top-right":case"top-left":case"top":d=b-7;break;case"bottom-right":case"bottom-left":case"bottom":d=7-b}switch(e){case"top-right":case"bottom-right":case"right":c=-a;break;case"top-left":case"bottom-left":case"left":c=a}return[c,d]})(b,a[0],a[1]):(function(e,a){let b=0,c=0;a<0&&(a=0);const d=a/om;switch(e){case"top-right":case"top-left":c=d-7;break;case"bottom-right":case"bottom-left":c=7-d;break;case"bottom":c=7-a;break;case"top":c=a-7}switch(e){case"top-right":case"bottom-right":b=-d;break;case"top-left":case"bottom-left":b=d;break;case"left":b=a;break;case"right":b=-a}return[b,c]})(b,a[0])}function pm(a,w,x,y,n,M,N,b,o,O){a.createArrays(),a.tilePixelRatio=8192/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const d=a.layers[0].layout,g=a.layers[0]._unevaluatedLayout._values,e={};if("composite"===a.textSizeData.kind){const{minZoom:P,maxZoom:Q}=a.textSizeData;e.compositeTextSizes=[g["text-size"].possiblyEvaluate(new zd(P),b),g["text-size"].possiblyEvaluate(new zd(Q),b)]}if("composite"===a.iconSizeData.kind){const{minZoom:R,maxZoom:S}=a.iconSizeData;e.compositeIconSizes=[g["icon-size"].possiblyEvaluate(new zd(R),b),g["icon-size"].possiblyEvaluate(new zd(S),b)]}e.layoutTextSize=g["text-size"].possiblyEvaluate(new zd(o+1),b),e.layoutIconSize=g["icon-size"].possiblyEvaluate(new zd(o+1),b),e.textMaxSize=g["text-size"].possiblyEvaluate(new zd(18),b);const z="map"===d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),T=d.get("text-size");for(const c of a.features){const A=d.get("text-font").evaluate(c,{},b).join(","),B=T.evaluate(c,{},b),p=e.layoutTextSize.evaluate(c,{},b),f=(e.layoutIconSize.evaluate(c,{},b),{horizontal:{},vertical:void 0}),k=c.text;let q,l=[0,0];if(k){const C=k.toString(),U=24*d.get("text-letter-spacing").evaluate(c,{},b),D=24*d.get("text-line-height").evaluate(c,{},b),E=Li(C)?U:0,r=d.get("text-anchor").evaluate(c,{},b),s=d.get("text-variable-anchor");if(!s){const F=d.get("text-radial-offset").evaluate(c,{},b);l=F?Ne(r,[24*F,nm]):d.get("text-offset").evaluate(c,{},b).map(a=>24*a)}let h=z?"center":d.get("text-justify").evaluate(c,{},b);const i=d.get("symbol-placement"),V="point"===i,G="point"===i?24*d.get("text-max-width").evaluate(c,{},b):0,H=b=>{a.allowVerticalPlacement&&Ki(C)&&(f.vertical=Kl(k,w,x,n,A,G,D,r,b,E,l,Ie.vertical,!0,i,p,B))};if(!z&&s){const I="auto"===h?s.map(a=>Oe(a)):[h];let J=!1;for(let t=0;t=0||!Ki(C)){const K=Kl(k,w,x,n,A,G,D,r,h,E,l,Ie.horizontal,!1,i,p,B);K&&(f.horizontal[h]=K)}H("point"===i?"left":h)}}let L=!1;if(c.icon&&c.icon.name){const j=y[c.icon.name];j&&(q=Ul(n[c.icon.name],d.get("icon-offset").evaluate(c,{},b),d.get("icon-anchor").evaluate(c,{},b)),L=j.sdf,void 0===a.sdfIcons?a.sdfIcons=j.sdf:a.sdfIcons!==j.sdf&&gc("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(j.pixelRatio!==a.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(a.iconsNeedLinear=!0))}const v=tm(f.horizontal)||f.vertical;a.iconsInText||(a.iconsInText=!!v&&v.iconsInText),(v||q)&&qm(a,c,f,q,y,e,p,0,l,L,N,b,O)}M&&a.generateCollisionDebugBuffers(o,a.collisionBoxArray)}function Oe(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function qm(c,b,e,f,F,A,n,G,H,I,J,d,K){let i=A.textMaxSize.evaluate(b,{},d);void 0===i&&(i=n);const a=c.layers[0].layout,o=a.get("icon-offset").evaluate(b,{},d),g=tm(e.horizontal)||e.vertical,p=n/24,q=c.tilePixelRatio*i/24,r=c.tilePixelRatio*a.get("symbol-spacing"),L=a.get("text-padding")*c.tilePixelRatio,M=a.get("icon-padding")*c.tilePixelRatio,s=ga(a.get("text-max-angle")),N="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement"),O="map"===a.get("icon-rotation-alignment")&&"point"!==a.get("symbol-placement"),t=a.get("symbol-placement"),B=r/2,j=a.get("icon-text-fit");let C;f&&"none"!==j&&(c.allowVerticalPlacement&&e.vertical&&(C=Vl(f,e.vertical,j,a.get("icon-text-fit-padding"),o,p)),g&&(f=Vl(f,g,j,a.get("icon-text-fit-padding"),o,p)));const h=(g,a,h)=>{if(a.x<0||a.x>=8192||a.y<0||a.y>=8192)return;const{x:i,y:j,z:k}=K.projectTilePoint(a.x,a.y,h),l=new Ke(i,j,k,0,void 0);!function(a,d,e,aa,h,z,H,j,f,r,m,s,t,I,u,v,ca,J,K,L,b,w,M,x,c){const k=a.addToLineVertexArray(d,aa);let l,n,o,y,N,O,P,Q=0,R=0,S=0,T=0,A=-1,B=-1;const g={};let U=ob(""),C=0,D=0;if(void 0===f._unevaluatedLayout.getValue("text-radial-offset")?[C,D]=f.layout.get("text-offset").evaluate(b,{},c).map(a=>24*a):(C=24*f.layout.get("text-radial-offset").evaluate(b,{},c),D=nm),a.allowVerticalPlacement&&h.vertical){const V=h.vertical;if(u)O=vm(V),j&&(P=vm(j));else{const W=f.layout.get("text-rotate").evaluate(b,{},c)+90;o=um(r,e,d,m,s,t,V,I,W,v),j&&(y=um(r,e,d,m,s,t,j,J,W))}}if(z){const E=f.layout.get("icon-rotate").evaluate(b,{},c),X="none"!==f.layout.get("icon-text-fit"),Y=dm(z,E,M,X),F=j?dm(j,E,M,X):void 0;n=um(r,e,d,m,s,t,z,J,E),Q=4*Y.length;const Z=a.iconSizeData;let p=null;"source"===Z.kind?(p=[128*f.layout.get("icon-size").evaluate(b,{},c)])[0]>rm&&gc(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Z.kind&&((p=[128*w.compositeIconSizes[0].evaluate(b,{},c),128*w.compositeIconSizes[1].evaluate(b,{},c)])[0]>rm||p[1]>rm)&&gc(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),a.addSymbols(a.icon,Y,p,L,K,b,!1,e,d,k.lineStartIndex,k.lineLength,-1,x,c),A=a.icon.placedSymbolArray.length-1,F&&(R=4*F.length,a.addSymbols(a.icon,F,p,L,K,b,Ie.vertical,e,d,k.lineStartIndex,k.lineLength,-1,x,c),B=a.icon.placedSymbolArray.length-1)}for(const $ in h.horizontal){const q=h.horizontal[$];l||(U=ob(q.text),u?N=vm(q):l=um(r,e,d,m,s,t,q,I,f.layout.get("text-rotate").evaluate(b,{},c),v));const _=1===q.positionedLines.length;if(S+=sm(a,e,d,q,H,f,u,b,v,k,h.vertical?Ie.horizontal:Ie.horizontalOnly,_?Object.keys(h.horizontal):[$],g,A,w,x,c),_)break}h.vertical&&(T+=sm(a,e,d,h.vertical,H,f,u,b,v,k,Ie.vertical,["vertical"],g,B,w,x,c));let i=-1;const G=(a,b)=>a?Math.max(a,b):b;i=G(N,i),i=G(O,i),i=G(P,i);const ba=i> -1?1:0;a.glyphOffsetArray.length>=Da.MAX_GLYPHS&&gc("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&a.addToSortKeyRanges(a.symbolInstances.length,b.sortKey),a.symbolInstances.emplaceBack(e.x,e.y,e.z,d.x,d.y,g.right>=0?g.right:-1,g.center>=0?g.center:-1,g.left>=0?g.left:-1,g.vertical>=0?g.vertical:-1,A,B,U,void 0!==l?l:a.collisionBoxArray.length,void 0!==l?l+1:a.collisionBoxArray.length,void 0!==o?o:a.collisionBoxArray.length,void 0!==o?o+1:a.collisionBoxArray.length,void 0!==n?n:a.collisionBoxArray.length,void 0!==n?n+1:a.collisionBoxArray.length,y||a.collisionBoxArray.length,y?y+1:a.collisionBoxArray.length,m,S,T,Q,R,ba,0,C,D,i)}(c,a,l,g,e,f,F,C,c.layers[0],c.collisionBoxArray,b.index,b.sourceLayerIndex,c.index,L,N,H,0,M,O,o,b,A,I,J,d)};if("line"===t)for(const u of Le(b.geometry,0,0,8192,8192)){const D=_l(u,r,s,e.vertical||g,f,24,q,c.overscaling,8192);for(const v of D){const w=g;w&&wm(c,w.text,B,v)||h(u,v,d)}}else if("line-center"===t){for(const k of b.geometry)if(k.length>1){const x=$l(k,s,e.vertical||g,f,24,q);x&&h(k,x,d)}}else if("Polygon"===b.type)for(const y of Ik(b.geometry,0)){const z=km(y,16);h(y[0],new Ke(z.x,z.y,0,0,void 0),d)}else if("LineString"===b.type)for(const l of b.geometry)h(l,new Ke(l[0].x,l[0].y,0,0,void 0),d);else if("Point"===b.type)for(const E of b.geometry)for(const m of E)h([m],new Ke(m.x,m.y,0,0,void 0),d)}const rm=32640;function sm(a,l,m,n,o,e,f,b,g,h,p,q,r,s,i,t,c){const j=function(Z,c,g,M,l,N,O,B){const s=[];if(0===c.positionedLines.length)return s;const h=M.layout.get("text-rotate").evaluate(N,{})*Math.PI/180,m=function(c){const a=c[0],b=c[1],d=a*b;return d>0?[a,-b]:d<0?[-a,b]:0===a?[b,a]:[b,-a]}(g);let C=Math.abs(c.top-c.bottom);for(const P of c.positionedLines)C-=P.lineOffset;const D=c.positionedLines.length,Q=C/D;let t=c.top-g[1];for(let n=0;nrm&&gc(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===k.kind&&((d=[128*i.compositeTextSizes[0].evaluate(b,{},c),128*i.compositeTextSizes[1].evaluate(b,{},c)])[0]>rm||d[1]>rm)&&gc(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),a.addSymbols(a.text,j,d,g,f,b,p,l,m,h.lineStartIndex,h.lineLength,s,t,c),q))r[u]=a.text.placedSymbolArray.length-1;return 4*j.length}function tm(a){for(const b in a)return a[b];return null}function um(o,m,p,r,s,t,a,u,q,n){let b=a.top,c=a.bottom,d=a.left,e=a.right;const f=a.collisionPadding;if(f&&(d-=f[0],b-=f[1],e+=f[2],c+=f[3]),q){const g=new Ha(d,b),h=new Ha(e,b),i=new Ha(d,c),j=new Ha(e,c),l=ga(q);let k=new Ha(0,0);n&&(k=new Ha(n[0],n[1])),g._rotateAround(l,k),h._rotateAround(l,k),i._rotateAround(l,k),j._rotateAround(l,k),d=Math.min(g.x,h.x,i.x,j.x),e=Math.max(g.x,h.x,i.x,j.x),b=Math.min(g.y,h.y,i.y,j.y),c=Math.max(g.y,h.y,i.y,j.y)}return o.emplaceBack(m.x,m.y,m.z,p.x,p.y,d,b,e,c,u,r,s,t),o.length-1}function vm(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const b=a.bottom-a.top;return b>0?Math.max(10,b):null}function wm(f,a,g,d){const b=f.compareText;if(a in b){const e=b[a];for(let c=e.length-1;c>=0;c--)if(d.dist(e[c])a.id),this.index=a.index,this.pixelRatio=a.pixelRatio,this.sourceLayerIndex=a.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Ka([]),this.placementViewportMatrix=Ka([]);const d=this.layers[0]._unevaluatedLayout._values;this.textSizeData=De(this.zoom,d["text-size"]),this.iconSizeData=De(this.zoom,d["icon-size"]);const b=this.layers[0].layout,e=b.get("symbol-sort-key"),c=b.get("symbol-z-order");this.canOverlap=b.get("text-allow-overlap")||b.get("icon-allow-overlap")||b.get("text-ignore-placement")||b.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==c&& void 0!==e.constantOr(1),this.sortFeaturesByY=("viewport-y"===c||"auto"===c&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=b.get("text-writing-mode").map(a=>Ie[a]),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.sourceID=a.sourceID}createArrays(){this.text=new Pe(new Yd(this.layers,this.zoom,a=>/^text/.test(a))),this.icon=new Pe(new Yd(this.layers,this.zoom,a=>/^icon/.test(a))),this.glyphOffsetArray=new Hd,this.lineVertexArray=new Id,this.symbolInstances=new Gd}calculateGlyphDependencies(b,c,g,e,f){for(let a=0;a0)&&("constant"!==k.value.kind||k.value.value.length>0),o="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,x=b.get("symbol-sort-key");if(this.features=[],!n&&!o)return;const p=j.iconDependencies,q=j.glyphDependencies,r=j.availableImages,y=new zd(this.zoom);for(const{feature:h,id:z,index:A,sourceLayerIndex:B}of v){const s=d._featureFilter.needGeometry,a=Fj(h,s);if(!d._featureFilter.filter(y,a,c))continue;let e,f;if(s||(a.geometry=Ej(h,c,w)),n){const C=d.getValueAndResolveTokens("text-field",a,c,r),t=yg.factory(C);Am(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===xd()||this.hasRTLText&&yd.isParsed())&&(e=jl(t,d,a))}if(o){const m=d.getValueAndResolveTokens("icon-image",a,c,r);f=m instanceof Dc?m:Dc.fromString(m)}if(!e&&!f)continue;const D=this.sortFeaturesByKey?x.evaluate(a,{},c):void 0;if(this.features.push({id:z,text:e,icon:f,index:A,sourceLayerIndex:B,geometry:a.geometry,properties:h.properties,type:xm[h.type],sortKey:D}),f&&(p[f.name]=!0),e){const E=k.evaluate(a,{},c).join(","),F="map"===b.get("text-rotation-alignment")&&"point"!==b.get("symbol-placement");for(const i of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Ie.vertical)>=0,e.sections))if(i.image)p[i.image.name]=!0;else{const G=Ki(e.toString()),u=i.fontStack||E,H=q[u]=q[u]||{};this.calculateGlyphDependencies(i.text,H,F,this.allowVerticalPlacement,G)}}}"line"===b.get("symbol-placement")&&(this.features=(function(k){const d={},c={},g=[];let l=0;function m(a){g.push(k[a]),l++}function n(b,d,e){const a=c[b];return delete c[b],c[d]=a,g[a].geometry[0].pop(),g[a].geometry[0]=g[a].geometry[0].concat(e[0]),a}function o(c,b,e){const a=d[b];return delete d[b],d[c]=a,g[a].geometry[0].shift(),g[a].geometry[0]=e[0].concat(g[a].geometry[0]),a}function i(c,a,d){const b=d?a[0][a[0].length-1]:a[0][0];return`${c}:${b.x}:${b.y}`}for(let e=0;ea.geometry)})(this.features)),this.sortFeaturesByKey&&this.features.sort((a,b)=>a.sortKey-b.sortKey)}update(a,b,c,d){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(a,b,this.layers,c,d),this.icon.programConfigurations.updatePaintArrays(a,b,this.layers,c,d))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(a){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(a),this.iconCollisionBox.upload(a)),this.text.upload(a,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(a,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(d,a){const h=this.lineVertexArray.length;if(void 0!==d.segment){let i=d.dist(a[d.segment+1]),j=d.dist(a[d.segment]);const e={};for(let b=d.segment+1;b=0;c--)e[c]={x:a[c].x,y:a[c].y,tileUnitDistanceFromAnchor:j},c>0&&(j+=a[c-1].dist(a[c]));for(let f=0;f=0?a.rightJustifiedTextSymbolIndex:a.centerJustifiedTextSymbolIndex>=0?a.centerJustifiedTextSymbolIndex:a.leftJustifiedTextSymbolIndex>=0?a.leftJustifiedTextSymbolIndex:a.verticalPlacedTextSymbolIndex>=0?a.verticalPlacedTextSymbolIndex:c),e=sb(this.textSizeData,b,d)/24;return this.tilePixelRatio*e}getSymbolInstanceIconSize(a,e,b){const c=this.icon.placedSymbolArray.get(b),d=sb(this.iconSizeData,a,c);return this.tilePixelRatio*d}_commitDebugCollisionVertexUpdate(b,c,a){b.emplaceBack(c,-a,-a),b.emplaceBack(c,a,-a),b.emplaceBack(c,a,a),b.emplaceBack(c,-a,a)}_updateTextDebugCollisionBoxes(b,c,d,e,f,g){for(let a=e;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(b,d){const c=b.placedSymbolArray.get(d),e=c.vertexStartIndex+4*c.numGlyphs;for(let a=c.vertexStartIndex;ag[a]-g[b]||h[b]-h[a]),c}addToSortKeyRanges(a,c){const b=this.sortKeyRanges[this.sortKeyRanges.length-1];b&&b.sortKey===c?b.symbolInstanceEnd=a+1:this.sortKeyRanges.push({sortKey:c,symbolInstanceStart:a,symbolInstanceEnd:a+1})}sortFeatures(b){if(this.sortFeaturesByY&&this.sortedAngle!==b&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const c of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(b),this.sortedAngle=b,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const a=this.symbolInstances.get(c);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex].forEach((a,b,c)=>{a>=0&&c.indexOf(a)===b&&this.addIndicesForPlacedSymbol(this.text,a)}),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}c("SymbolBucket",Da,{omit:["layers","collisionBoxArray","features","compareText"]}),Da.MAX_GLYPHS=65535,Da.addDynamicAttributes=vb;const Re=new n({"symbol-placement":new e(b.layout_symbol["symbol-placement"]),"symbol-spacing":new e(b.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new e(b.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new g(b.layout_symbol["symbol-sort-key"]),"symbol-z-order":new e(b.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new e(b.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new e(b.layout_symbol["icon-ignore-placement"]),"icon-optional":new e(b.layout_symbol["icon-optional"]),"icon-rotation-alignment":new e(b.layout_symbol["icon-rotation-alignment"]),"icon-size":new g(b.layout_symbol["icon-size"]),"icon-text-fit":new e(b.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new e(b.layout_symbol["icon-text-fit-padding"]),"icon-image":new g(b.layout_symbol["icon-image"]),"icon-rotate":new g(b.layout_symbol["icon-rotate"]),"icon-padding":new e(b.layout_symbol["icon-padding"]),"icon-keep-upright":new e(b.layout_symbol["icon-keep-upright"]),"icon-offset":new g(b.layout_symbol["icon-offset"]),"icon-anchor":new g(b.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new e(b.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new e(b.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new e(b.layout_symbol["text-rotation-alignment"]),"text-field":new g(b.layout_symbol["text-field"]),"text-font":new g(b.layout_symbol["text-font"]),"text-size":new g(b.layout_symbol["text-size"]),"text-max-width":new g(b.layout_symbol["text-max-width"]),"text-line-height":new g(b.layout_symbol["text-line-height"]),"text-letter-spacing":new g(b.layout_symbol["text-letter-spacing"]),"text-justify":new g(b.layout_symbol["text-justify"]),"text-radial-offset":new g(b.layout_symbol["text-radial-offset"]),"text-variable-anchor":new e(b.layout_symbol["text-variable-anchor"]),"text-anchor":new g(b.layout_symbol["text-anchor"]),"text-max-angle":new e(b.layout_symbol["text-max-angle"]),"text-writing-mode":new e(b.layout_symbol["text-writing-mode"]),"text-rotate":new g(b.layout_symbol["text-rotate"]),"text-padding":new e(b.layout_symbol["text-padding"]),"text-keep-upright":new e(b.layout_symbol["text-keep-upright"]),"text-transform":new g(b.layout_symbol["text-transform"]),"text-offset":new g(b.layout_symbol["text-offset"]),"text-allow-overlap":new e(b.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new e(b.layout_symbol["text-ignore-placement"]),"text-optional":new e(b.layout_symbol["text-optional"])});var Bm={paint:new n({"icon-opacity":new g(b.paint_symbol["icon-opacity"]),"icon-color":new g(b.paint_symbol["icon-color"]),"icon-halo-color":new g(b.paint_symbol["icon-halo-color"]),"icon-halo-width":new g(b.paint_symbol["icon-halo-width"]),"icon-halo-blur":new g(b.paint_symbol["icon-halo-blur"]),"icon-translate":new e(b.paint_symbol["icon-translate"]),"icon-translate-anchor":new e(b.paint_symbol["icon-translate-anchor"]),"text-opacity":new g(b.paint_symbol["text-opacity"]),"text-color":new g(b.paint_symbol["text-color"],{runtimeType:y,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new g(b.paint_symbol["text-halo-color"]),"text-halo-width":new g(b.paint_symbol["text-halo-width"]),"text-halo-blur":new g(b.paint_symbol["text-halo-blur"]),"text-translate":new e(b.paint_symbol["text-translate"]),"text-translate-anchor":new e(b.paint_symbol["text-translate-anchor"])}),layout:Re};class Se{constructor(a){this.type=a.property.overrides?a.property.overrides.runtimeType:zc,this.defaultValue=a}evaluate(a){if(a.formattedSection){const b=this.defaultValue.property.overrides;if(b&&b.hasOverride(a.formattedSection))return b.getOverride(a.formattedSection)}return a.feature&&a.featureState?this.defaultValue.evaluate(a.feature,a.featureState):this.defaultValue.property.specification.default}eachChild(a){this.defaultValue.isConstant()||a(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}c("FormatSectionOverride",Se,{omit:["defaultValue"]});class Te extends pb{constructor(a){super(a,Bm)}recalculate(d,e){super.recalculate(d,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const b=this.layout.get("text-writing-mode");if(b){const a=[];for(const c of b)0>a.indexOf(c)&&a.push(c);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(b,c,e,f){var g;const a=this.layout.get(b).evaluate(c,{},e,f),d=this._unevaluatedLayout._values[b];return d.isDataDriven()||Dh(d.value)||!a?a:(g=c.properties,a.replace(/{([^{}]+)}/g,(b,a)=>a in g?String(g[a]):""))}createBucket(a){return new Da(a)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const b of Bm.paint.overridableProperties){if(!Te.hasPaintOverride(this.layout,b))continue;const a=this.paint.get(b),e=new Se(a),c=new ed(e,a.property.specification);let d=null;d="constant"===a.value.kind||"source"===a.value.kind?new gd("source",c):new hd("composite",c,a.value.zoomStops,a.value._interpolationType),this.paint._values[b]=new cj(a.property,d,a.parameters)}}_handleOverridablePaintPropertyUpdate(a,b,c){return!(!this.layout||b.isDataDriven()||c.isDataDriven())&&Te.hasPaintOverride(this.layout,a)}static hasPaintOverride(c,d){const a=c.get("text-field"),h=Bm.paint.properties[d];let e=!1;const f=a=>{for(const b of a)if(h.overrides&&h.overrides.hasOverride(b))return void(e=!0)};if("constant"===a.value.kind&&a.value.value instanceof yg)f(a.value.value.sections);else if("source"===a.value.kind){const g=a=>{e||(a instanceof Ec&&Bg(a.value)===Bc?f(a.value.sections):a instanceof Fc?f(a.sections):a.eachChild(g))},b=a.value;b._styleExpression&&g(b._styleExpression.expression)}return e}getProgramConfiguration(a){return new Xd(this,a)}}var Cm={paint:new n({"background-color":new e(b.paint_background["background-color"]),"background-pattern":new gb(b.paint_background["background-pattern"]),"background-opacity":new e(b.paint_background["background-opacity"])})},Dm={paint:new n({"raster-opacity":new e(b.paint_raster["raster-opacity"]),"raster-hue-rotate":new e(b.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new e(b.paint_raster["raster-brightness-min"]),"raster-brightness-max":new e(b.paint_raster["raster-brightness-max"]),"raster-saturation":new e(b.paint_raster["raster-saturation"]),"raster-contrast":new e(b.paint_raster["raster-contrast"]),"raster-resampling":new e(b.paint_raster["raster-resampling"]),"raster-fade-duration":new e(b.paint_raster["raster-fade-duration"])})};class Em extends pb{constructor(a){super(a,{}),this.implementation=a}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(a){this.implementation.onAdd&&this.implementation.onAdd(a,a.painter.context.gl)}onRemove(a){this.implementation.onRemove&&this.implementation.onRemove(a,a.painter.context.gl)}}var Fm={paint:new n({"sky-type":new e(b.paint_sky["sky-type"]),"sky-atmosphere-sun":new e(b.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new e(b.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new e(b.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new e(b.paint_sky["sky-gradient-radius"]),"sky-gradient":new V(b.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new e(b.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new e(b.paint_sky["sky-atmosphere-color"]),"sky-opacity":new e(b.paint_sky["sky-opacity"])})};function Gm(l,m,n){var a,b,f,h,i,j,k,c,d;const g=Q(0,0,1),e=Rb(Qa());return a=e,b=e,f=n?-ga(l)+Math.PI:ga(l),f*=.5,h=b[0],i=b[1],j=b[2],k=b[3],c=Math.sin(f),d=Math.cos(f),a[0]=h*d-j*c,a[1]=i*d+k*c,a[2]=j*d+h*c,a[3]=k*d-i*c,Sb(e,e,-ga(m)),Ob(g,g,e),Kb(g,g)}const Hm={circle:class extends pb{constructor(a){super(a,Vj)}createBucket(a){return new qb(a)}queryRadius(b){const a=b;return Rj("circle-radius",this,a)+Rj("circle-stroke-width",this,a)+Sj(this.paint.get("circle-translate"))}queryIntersectsFeature(a,b,c,e,j,d,f,g){const h=Uj(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),d.angle,a.pixelToTileUnitsFactor),i=this.paint.get("circle-radius").evaluate(b,c)+this.paint.get("circle-stroke-width").evaluate(b,c);return Wj(a,e,d,f,g,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,i)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new Xd(this,a)}},heatmap:class extends pb{createBucket(a){return new je(a)}constructor(a){super(a,ck),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){"heatmap-color"===a&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=le({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(a){return Rj("heatmap-radius",this,a)}queryIntersectsFeature(a,b,c,d,i,e,f,g){const h=this.paint.get("heatmap-radius").evaluate(b,c);return Wj(a,d,e,f,g,!0,!0,new Ha(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new Xd(this,a)}},hillshade:class extends pb{constructor(a){super(a,dk)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(a){return new Xd(this,a)}},fill:class extends pb{constructor(a){super(a,Mk)}getProgramIds(){const a=this.paint.get("fill-pattern"),b=a&&a.constantOr(1),c=[b?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&c.push(b&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),c}getProgramConfiguration(a){return new Xd(this,a)}recalculate(b,c){super.recalculate(b,c);const a=this.paint._values["fill-outline-color"];"constant"===a.value.kind&& void 0===a.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new oe(a)}queryRadius(){return Sj(this.paint.get("fill-translate"))}queryIntersectsFeature(a,d,e,b,f,c){return!a.queryGeometry.isAboveHorizon&&Ij(Tj(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),c.angle,a.pixelToTileUnitsFactor),b)}isTileClipped(){return!0}},"fill-extrusion":class extends pb{constructor(a){super(a,Wk)}createBucket(a){return new ve(a)}queryRadius(){return Sj(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(a){return new Xd(this,a)}queryIntersectsFeature(c,k,l,v,C,a,w,m,x){var d,e,f,g,h,i,n,o,p;const y=Uj(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,c.pixelToTileUnitsFactor),z=this.paint.get("fill-extrusion-height").evaluate(k,l),A=this.paint.get("fill-extrusion-base").evaluate(k,l),b=[0,0],q=m&&a.elevation,B=a.elevation?a.elevation.exaggeration():1;if(q){const r=c.tile.getBucket(this).centroidVertexArray,s=x+1;if(s=3){for(let d=0;d1&&(b=i[++j]);const n=Math.abs(a-b.left),o=Math.abs(a-b.right),e=Math.min(n,o);let g;const h=d/c*(f+1);if(b.isDash){const k=f-Math.abs(h);g=Math.sqrt(e*e+k*k)}else g=f-Math.sqrt(e*e+h*h);this.image.data[m+a]=Math.max(0,Math.min(255,g+128))}}}addRegularDash(a,k){for(let b=a.length-1;b>=0;--b){const e=a[b],f=a[b+1];e.zeroLength?a.splice(b,1):f&&f.isDash===e.isDash&&(f.left=e.left,a.splice(b,1))}const g=a[0],h=a[a.length-1];g.isDash===h.isDash&&(g.left=h.left-this.width,h.right=g.right+this.width);const l=this.width*this.nextRow;let i=0,d=a[i];for(let c=0;c1&&(d=a[++i]);const m=Math.abs(c-d.left),n=Math.abs(c-d.right),j=Math.min(m,n);this.image.data[l+c]=Math.max(0,Math.min(255,(d.isDash?j:-j)+k+128))}}addDash(a,e){const f=this.getKey(a,e);if(this.positions[f])return this.positions[f];const h="round"===e,c=h?7:0,i=2*c+1;if(this.nextRow+i>this.height)return gc("LineAtlas out of space"),null;0===a.length&&a.push(1);let d=0;for(let b=0;b0;a--)c+=(e&(b=1<this.canonical.z?new yb(a,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yb(a,this.wrap,a,this.canonical.x>>b,this.canonical.y>>b)}calculateScaledKey(a,b=!0){if(this.overscaledZ===a&&b)return this.key;if(a>this.canonical.z)return Pm(this.wrap*+b,a,this.canonical.z,this.canonical.x,this.canonical.y);{const c=this.canonical.z-a;return Pm(this.wrap*+b,a,a,this.canonical.x>>c,this.canonical.y>>c)}}isChildOf(a){if(a.wrap!==this.wrap)return!1;const b=this.canonical.z-a.canonical.z;return 0===a.overscaledZ||a.overscaledZ>b&&a.canonical.y===this.canonical.y>>b}children(d){if(this.overscaledZ>=d)return[new yb(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const a=this.canonical.z+1,b=2*this.canonical.x,c=2*this.canonical.y;return[new yb(a,this.wrap,a,b,c),new yb(a,this.wrap,a,b+1,c),new yb(a,this.wrap,a,b,c+1),new yb(a,this.wrap,a,b+1,c+1)]}isLessThan(a){return this.wrapa.wrap)&&(this.overscaledZa.overscaledZ)&&(this.canonical.xa.canonical.x)&&this.canonical.yMath.abs(i[a])){if(d[a]h[a])return null}else{const j=1/i[a];let b=(g[a]-d[a])*j,c=(h[a]-d[a])*j;if(b>c){const k=b;b=c,c=k}if(b>e&&(e=b),cf)return null}return e}function Um(b,c,d,y,z,A,B,C,D,e,a){const f=y-b,g=z-c,h=A-d,i=B-b,j=C-c,k=D-d,q=a[1]*k-a[2]*j,r=a[2]*i-a[0]*k,s=a[0]*j-a[1]*i,t=f*q+g*r+h*s;if(1e-15>Math.abs(t))return null;const l=1/t,m=e[0]-b,n=e[1]-c,o=e[2]-d,p=(m*q+n*r+o*s)*l;if(p<0||p>1)return null;const u=n*h-o*g,v=o*f-m*h,w=m*g-n*f,x=(a[0]*u+a[1]*v+a[2]*w)*l;return x<0||p+x>1?null:(i*u+j*v+k*w)*l}function Vm(b,a,c){return(b-a)/(c-a)}function Wm(d,e,j,b,c,k,l,f,g){const a=1<{const e=f?1:0,g=(c+1)*a-e,h=d*a,i=(d+1)*a-e;b[0]=c*a,b[1]=h,b[2]=g,b[3]=i};let c=new Sm(b);const a=[];for(let g=0;g=1;b/=2){const d=f[f.length-1];c=new Sm(b);for(let h=0;h0;){const{idx:u,t:B,nodex:g,nodey:h,depth:j}=t.pop();if(this.leaves[u]){Wm(g,h,j,o,p,q,r,a,b);const k=1<=x[2])return B}continue}let l=0;for(let c=0;c=s[i[m]]&&(i.splice(m,0,c),y=!0);y||(i[l]=c),l++}}for(let z=0;z=this.dim+1||b< -1||b>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(b+1)*this.stride+(a+1)}_unpackMapbox(a,b,c){return(256*a*256+256*b+c)/10-1e4}_unpackTerrarium(a,b,c){return 256*a+b+c/256-32768}static pack(d,e){const b=[0,0,0,0],c=zb.getUnpackVector(e);let a=Math.floor((d+c[3])/c[2]);return b[2]=a%256,a=Math.floor(a/256),b[1]=a%256,a=Math.floor(a/256),b[0]=a,b}getPixels(){return new rb({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,a,b){if(this.dim!==i.dim)throw new Error("dem dimension mismatch");let e=a*this.dim,f=a*this.dim+this.dim,g=b*this.dim,h=b*this.dim+this.dim;switch(a){case -1:e=f-1;break;case 1:f=e+1}switch(b){case -1:g=h-1;break;case 1:h=g+1}const j=-a*this.dim,k=-b*this.dim;for(let c=g;c{"source"===a.dataType&&"metadata"===a.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===a.dataType&&"content"===a.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),a.on("error",()=>{this._sourceErrored=!0}),this._source=a,this._tiles={},this._cache=new class{constructor(a,b){this.max=a,this.onRemove=b,this.reset()}reset(){for(const b in this.data)for(const a of this.data[b])a.timeout&&clearTimeout(a.timeout),this.onRemove(a.value);return this.data={},this.order=[],this}add(e,f,b){const a=e.wrapped().key;void 0===this.data[a]&&(this.data[a]=[]);const c={value:f,timeout:void 0};if(void 0!==b&&(c.timeout=setTimeout(()=>{this.remove(e,c)},b)),this.data[a].push(c),this.order.push(a),this.order.length>this.max){const d=this._getAndRemoveByKey(this.order[0]);d&&this.onRemove(d)}return this}has(a){return a.wrapped().key in this.data}getAndRemove(a){return this.has(a)?this._getAndRemoveByKey(a.wrapped().key):null}_getAndRemoveByKey(a){const b=this.data[a].shift();return b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.order.splice(this.order.indexOf(a),1),b.value}getByKey(b){const a=this.data[b];return a?a[0].value:null}get(a){return this.has(a)?this.data[a.wrapped().key][0].value:null}remove(c,d){if(!this.has(c))return this;const a=c.wrapped().key,e=void 0===d?0:this.data[a].indexOf(d),b=this.data[a][e];return this.data[a].splice(e,1),b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.onRemove(b.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(b){for(this.max=b;this.order.length>this.max;){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}filter(d){const a=[];for(const e in this.data)for(const b of this.data[e])d(b.value)||a.push(b);for(const c of a)this.remove(c.value.tileID,c)}}(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new class{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(a,g,c){const b=String(g);if(this.stateChanges[a]=this.stateChanges[a]||{},this.stateChanges[a][b]=this.stateChanges[a][b]||{},_b(this.stateChanges[a][b],c),null===this.deletedStates[a])for(const d in this.deletedStates[a]={},this.state[a])d!==b&&(this.deletedStates[a][d]=null);else if(this.deletedStates[a]&&null===this.deletedStates[a][b])for(const e in this.deletedStates[a][b]={},this.state[a][b])c[e]||(this.deletedStates[a][b][e]=null);else for(const f in c)this.deletedStates[a]&&this.deletedStates[a][b]&&null===this.deletedStates[a][b][f]&&delete this.deletedStates[a][b][f]}removeFeatureState(a,d,c){if(null===this.deletedStates[a])return;const b=String(d);if(this.deletedStates[a]=this.deletedStates[a]||{},c&& void 0!==d)null!==this.deletedStates[a][b]&&(this.deletedStates[a][b]=this.deletedStates[a][b]||{},this.deletedStates[a][b][c]=null);else if(void 0!==d)if(this.stateChanges[a]&&this.stateChanges[a][b])for(c in this.deletedStates[a][b]={},this.stateChanges[a][b])this.deletedStates[a][b][c]=null;else this.deletedStates[a][b]=null;else this.deletedStates[a]=null}getState(a,b){const c=String(b),d=_b({},(this.state[a]||{})[c],(this.stateChanges[a]||{})[c]);if(null===this.deletedStates[a])return{};if(this.deletedStates[a]){const e=this.deletedStates[a][b];if(null===e)return{};for(const f in e)delete d[f]}return d}initializeTileState(a,b){a.setFeatureState(this.state,b)}coalesceChanges(g,j){const c={};for(const b in this.stateChanges){this.state[b]=this.state[b]||{};const h={};for(const d in this.stateChanges[b])this.state[b][d]||(this.state[b][d]={}),_b(this.state[b][d],this.stateChanges[b][d]),h[d]=this.state[b][d];c[b]=h}for(const a in this.deletedStates){this.state[a]=this.state[a]||{};const f={};if(null===this.deletedStates[a])for(const i in this.state[a])f[i]={},this.state[a][i]={};else for(const e in this.deletedStates[a]){if(null===this.deletedStates[a][e])this.state[a][e]={};else for(const k of Object.keys(this.deletedStates[a][e]))delete this.state[a][e][k];f[e]=this.state[a][e]}c[a]=c[a]||{},_b(c[a],f)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(c).length)for(const l in g)g[l].setFeatureState(c,j)}}}onAdd(a){this.map=a,this._minTileCacheSize=a?a._minTileCacheSize:null,this._maxTileCacheSize=a?a._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const b in this._tiles){const a=this._tiles[b];if("loaded"!==a.state&&"errored"!==a.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const a=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,a&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(a,b){return a.isSymbolTile=this._onlySymbols,this._source.loadTile(a,b)}_unloadTile(a){if(this._source.unloadTile)return this._source.unloadTile(a,()=>{})}_abortTile(a){if(this._source.abortTile)return this._source.abortTile(a,()=>{})}serialize(){return this._source.serialize()}prepare(b){for(const c in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const a=this._tiles[c];a.upload(b),a.prepare(this.map.style.imageManager)}}getIds(){return $b(this._tiles).map(a=>a.tileID).sort($m).map(a=>a.key)}getRenderableIds(b){const a=[];for(const c in this._tiles)this._isIdRenderable(+c,b)&&a.push(this._tiles[c]);return b?a.sort((e,f)=>{const a=e.tileID,b=f.tileID,c=new Ha(a.canonical.x,a.canonical.y)._rotate(this.transform.angle),d=new Ha(b.canonical.x,b.canonical.y)._rotate(this.transform.angle);return a.overscaledZ-b.overscaledZ||d.y-c.y||d.x-c.x}).map(a=>a.tileID.key):a.map(a=>a.tileID).sort($m).map(a=>a.key)}hasRenderableParent(b){const a=this.findLoadedParent(b,0);return!!a&&this._isIdRenderable(a.tileID.key)}_isIdRenderable(a,b){return this._tiles[a]&&this._tiles[a].hasData()&&!this._coveredTiles[a]&&(b||!this._tiles[a].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const a in this._cache.reset(),this._tiles)"errored"!==this._tiles[a].state&&this._reloadTile(+a,"reloading")}_reloadTile(b,c){const a=this._tiles[b];a&&("loading"!==a.state&&(a.state=c),this._loadTile(a,this._tileLoaded.bind(this,a,b,c)))}_tileLoaded(a,d,e,b){if(b)if(a.state="errored",404!==b.status)this._source.fire(new vc(b,{tile:a}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const c=this.map.painter.terrain;this.update(this.transform,c.getScaledDemTileSize(),!0),c.resetTileLookupCache(this.id)}else this.update(this.transform);else a.timeAdded=ic.now(),"expired"===e&&(a.refreshedUponExpiration=!0),this._setTileReloadTimer(d,a),"raster-dem"===this._source.type&&a.dem&&this._backfillDEM(a),this._state.initializeTileState(a,this.map?this.map.painter:null),this._source.fire(new Xa("data",{dataType:"source",tile:a,coord:a.tileID,sourceCacheId:this.id}))}_backfillDEM(a){const c=this.getRenderableIds();for(let b=0;b1||(Math.abs(b)>1&&(1===Math.abs(b+d)?b+=d:1===Math.abs(b-d)&&(b-=d)),c.dem&&a.dem&&(a.dem.backfillBorder(c.dem,b,e),a.neighboringTiles&&a.neighboringTiles[f]&&(a.neighboringTiles[f].backfilled=!0)))}}getTile(a){return this.getTileByID(a.key)}getTileByID(a){return this._tiles[a]}_retainLoadedChildren(h,d,i,e){for(const f in this._tiles){let a=this._tiles[f];if(e[f]||!a.hasData()||a.tileID.overscaledZ<=d||a.tileID.overscaledZ>i)continue;let b=a.tileID;for(;a&&a.tileID.overscaledZ>d+1;){const g=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[g.key])&&a.hasData()&&(b=g)}let c=b;for(;c.overscaledZ>d;)if(h[(c=c.scaledTo(c.overscaledZ-1)).key]){e[b.key]=b;break}}}findLoadedParent(a,d){if(a.key in this._loadedParentTiles){const b=this._loadedParentTiles[a.key];return b&&b.tileID.overscaledZ>=d?b:null}for(let c=a.overscaledZ-1;c>=d;c--){const f=a.scaledTo(c),e=this._getLoadedTile(f);if(e)return e}}_getLoadedTile(a){const b=this._tiles[a.key];return b&&b.hasData()?b:this._cache.getByKey(this._source.reparseOverscaled?a.wrapped().key:a.canonical.key)}updateCacheSize(b,a){a=a||this._source.tileSize;const e=Math.ceil(b.width/a)+1,f=Math.ceil(b.height/a)+1,c=Math.floor(e*f*5),d="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,c):c,g="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,d):d;this._cache.setMaxSize(g)}handleWrapJump(b){const c=Math.round((b-(void 0===this._prevLng?b:this._prevLng))/360);if(this._prevLng=b,c){const d={};for(const g in this._tiles){const a=this._tiles[g];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+c),d[a.tileID.key]=a}for(const e in this._tiles=d,this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const f in this._tiles)this._setTileReloadTimer(+f,this._tiles[f])}}update(e,n,o){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!o)return;let a;this.updateCacheSize(e,n),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(a=>new yb(a.canonical.z,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y)):(a=e.coveringTiles({tileSize:n||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(a=a.filter(a=>this._source.hasTile(a)))):a=[];const b=this._updateRetainedTiles(a);if(_m(this._source.type)&&0!==a.length){const h={},p={},s=Object.keys(b);for(const i of s){const j=b[i],k=this._tiles[i];if(!k||k.fadeEndTime&&k.fadeEndTime<=ic.now())continue;const f=this.findLoadedParent(j,Math.max(j.overscaledZ-Fa.maxOverzooming,this._source.minzoom));f&&(this._addTile(f.tileID),h[f.tileID.key]=f.tileID),p[i]=j}const t=a[a.length-1].overscaledZ;for(const l in this._tiles){const m=this._tiles[l];if(b[l]||!m.hasData())continue;let c=m.tileID;for(;c.overscaledZ>t;){c=c.scaledTo(c.overscaledZ-1);const q=this._tiles[c.key];if(q&&q.hasData()&&p[c.key]){b[l]=m.tileID;break}}}for(const g in h)b[g]||(this._coveredTiles[g]=!0,b[g]=h[g])}for(const u in b)this._tiles[u].clearFadeHold();const v=function(c,d){const a=[];for(const b in c)b in d||a.push(b);return a}(this._tiles,b);for(const r of v){const d=this._tiles[r];d.hasSymbolBuckets&&!d.holdingForFade()?d.setHoldDuration(this.map._fadeDuration):d.hasSymbolBuckets&&!d.symbolFadeFinished()||this._removeTile(+r)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const a in this._tiles)this._tiles[a].holdingForFade()&&this._removeTile(+a)}_updateRetainedTiles(e){const a={};if(0===e.length)return a;const j={},k=e.reduce((a,b)=>Math.min(a,b.overscaledZ),1/0),l=e[0].overscaledZ,p=Math.max(l-Fa.maxOverzooming,this._source.minzoom),q=Math.max(l+Fa.maxUnderzooming,this._source.minzoom),m={};for(const f of e){const r=this._addTile(f);a[f.key]=f,r.hasData()||k=this._source.maxzoom){const h=c.children(this._source.maxzoom)[0],n=this.getTile(h);if(n&&n.hasData()){a[h.key]=h;continue}}else{const g=c.children(this._source.maxzoom);if(a[g[0].key]&&a[g[1].key]&&a[g[2].key]&&a[g[3].key])continue}let o=b.wasRequested();for(let i=c.overscaledZ-1;i>=p;--i){const d=c.scaledTo(i);if(j[d.key])break;if(j[d.key]=!0,(b=this.getTile(d))||!o||(b=this._addTile(d)),b&&(a[d.key]=d,o=b.wasRequested(),b.hasData()))break}}return a}_updateLoadedParentTileCache(){for(const e in this._loadedParentTiles={},this._tiles){const c=[];let b,a=this._tiles[e].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){b=this._loadedParentTiles[a.key];break}c.push(a.key);const d=a.scaledTo(a.overscaledZ-1);if(b=this._getLoadedTile(d))break;a=d}for(const f of c)this._loadedParentTiles[f]=b}}_addTile(b){let a=this._tiles[b.key];if(a)return a;(a=this._cache.getAndRemove(b))&&(this._setTileReloadTimer(b.key,a),a.tileID=b,this._state.initializeTileState(a,this.map?this.map.painter:null),this._cacheTimers[b.key]&&(clearTimeout(this._cacheTimers[b.key]),delete this._cacheTimers[b.key],this._setTileReloadTimer(b.key,a)));const c=Boolean(a);if(!c){const d=this.map?this.map.painter:null,e="raster"===this._source.type||"raster-dem"===this._source.type;a=new bf(b,this._source.tileSize*b.overscaleFactor(),this.transform.tileZoom,d,e),this._loadTile(a,this._tileLoaded.bind(this,a,b.key,a.state))}return a?(a.uses++,this._tiles[b.key]=a,c||this._source.fire(new Xa("dataloading",{tile:a,coord:a.tileID,dataType:"source"})),a):null}_setTileReloadTimer(a,c){a in this._timers&&(clearTimeout(this._timers[a]),delete this._timers[a]);const b=c.getExpiryTimeout();b&&(this._timers[a]=setTimeout(()=>{this._reloadTile(a,"expired"),delete this._timers[a]},b))}_removeTile(b){const a=this._tiles[b];a&&(a.uses--,delete this._tiles[b],this._timers[b]&&(clearTimeout(this._timers[b]),delete this._timers[b]),a.uses>0||(a.hasData()&&"reloading"!==a.state?this._cache.add(a.tileID,a,a.getExpiryTimeout()):(a.aborted=!0,this._abortTile(a),this._unloadTile(a))))}clearTiles(){for(const a in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+a);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(e,f,g){const a=[],c=this.transform;if(!c)return a;for(const h in this._tiles){const b=this._tiles[h];if(g&&b.clearQueryDebugViz(),b.holdingForFade())continue;const d=e.containsTile(b,c,f);d&&a.push(d)}return a}getVisibleCoordinates(c){const a=this.getRenderableIds(c).map(a=>this._tiles[a].tileID);for(const b of a)b.projMatrix=this.transform.calculateProjMatrix(b.toUnwrapped());return a}hasTransition(){if(this._source.hasTransition())return!0;if(_m(this._source.type))for(const b in this._tiles){const a=this._tiles[b];if(void 0!==a.fadeEndTime&&a.fadeEndTime>=ic.now())return!0}return!1}setFeatureState(a,b,c){this._state.updateState(a=a||"_geojsonTileLayer",b,c)}removeFeatureState(a,b,c){this._state.removeFeatureState(a=a||"_geojsonTileLayer",b,c)}getFeatureState(a,b){return this._state.getState(a=a||"_geojsonTileLayer",b)}setDependencies(b,c,d){const a=this._tiles[b];a&&a.setDependencies(c,d)}reloadTilesForDependencies(b,c){for(const a in this._tiles)this._tiles[a].hasDependency(b,c)&&this._reloadTile(+a,"reloading");this._cache.filter(a=>!a.hasDependency(b,c))}_preloadTiles(a,f){const b=new Map,g=Array.isArray(a)?a:[a],c=this.map.painter.terrain,h=this.usedForTerrain&&c?c.getScaledDemTileSize():this._source.tileSize;for(const d of g){const i=d.coveringTiles({tileSize:h,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of i)b.set(e.key,e);this.usedForTerrain&&d.updateElevation(!1)}const j=Array.from(b.values()),k="raster"===this._source.type||"raster-dem"===this._source.type;Zb(j,(a,c)=>{const b=new bf(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,this.map.painter,k);this._loadTile(b,a=>{"raster-dem"===this._source.type&&b.dem&&this._backfillDEM(b),c(a,b)})},f)}}function $m(a,b){const c=Math.abs(2*a.wrap)- +(a.wrap<0),d=Math.abs(2*b.wrap)- +(b.wrap<0);return a.overscaledZ-b.overscaledZ||d-c||b.canonical.y-a.canonical.y||b.canonical.x-a.canonical.x}function _m(a){return"raster"===a||"image"===a||"video"===a}Fa.maxOverzooming=10,Fa.maxUnderzooming=3;class an{constructor(a,b,c){this._demTile=a,this._dem=this._demTile.dem,this._scale=b,this._offset=c}static create(f,b,g){const a=g||f.findDEMTileFor(b);if(!a||!a.dem)return;const e=a.dem,c=a.tileID,d=1<=0&&a[3]>=0&&l.insert(k,a[0],a[1],a[2],a[3])}}loadVTLayers(){if(!this.vtLayers)for(const a in this.vtLayers=new _.VectorTile(new Fe(this.rawTileData)).layers,this.sourceLayerCoder=new Qm(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[a]=[];return this.vtLayers}query(c,j,k,l){this.loadVTLayers();const d=c.params||{},m=Jh(d.filter),n=c.tileResult,g=c.transform,a=n.bufferedTilespaceBounds,b=this.grid.query(a.min.x,a.min.y,a.max.x,a.max.y,(a,b,c,d)=>ge(n.bufferedTilespaceGeometry,a,b,c,d));b.sort(cn);let o=null;g.elevation&&b.length>0&&(o=an.create(g.elevation,this.tileID));const h={};let i;for(let e=0;e(q||(q=Ej(a,this.tileID.canonical,c.tileTransform)),b.queryIntersectsFeature(n,a,d,q,this.z,c.transform,c.pixelPosMatrix,o,e)))}return h}loadMatchingFeature(l,t,g,e,m,u,v,n,o){const{featureIndex:p,bucketIndex:w,sourceLayerIndex:x,layoutVertexArrayOffset:y}=t,h=this.bucketLayerIDs[w];if(e&&!function(b,c){for(let a=0;a=0)return!0;return!1}(e,h))return;const q=this.sourceLayerCoder.decode(x),a=this.vtLayers[q].feature(p);if(g.needGeometry){const z=Fj(a,!0);if(!g.filter(new zd(this.tileID.overscaledZ),z,this.tileID.canonical))return}else if(!g.filter(new zd(this.tileID.overscaledZ),a))return;const i=this.getId(a,q);for(let j=0;je.indexOf(b))continue;const c=u[b];if(!c)continue;let f={};void 0!==i&&n&&(f=n.getState(c.sourceLayer||"_geojsonTileLayer",i));const d=_b({},v[b]);d.paint=bn(d.paint,c.paint,a,f,m),d.layout=bn(d.layout,c.layout,a,f,m);const r=!o||o(a,c,f,y);if(!r)continue;const s=new Rm(a,this.z,this.x,this.y,i);s.layer=d;let k=l[b];void 0===k&&(k=l[b]=[]),k.push({featureIndex:p,feature:s,intersectionZ:r})}}lookupSymbolFeatures(b,c,d,e,f,g,h,i){const a={};this.loadVTLayers();const j=Jh(f);for(const k of b)this.loadMatchingFeature(a,{bucketIndex:d,sourceLayerIndex:e,featureIndex:k,layoutVertexArrayOffset:0},j,g,h,i,c);return a}loadFeature(e){const{featureIndex:a,sourceLayerIndex:f}=e;this.loadVTLayers();const c=this.sourceLayerCoder.decode(f),b=this.vtFeatures[c];if(b[a])return b[a];const d=this.vtLayers[c].feature(a);return b[a]=d,d}hasLayer(a){for(const b of this.bucketLayerIDs)for(const c of b)if(a===c)return!0;return!1}getId(b,c){let a=b.id;return this.promoteId&&"boolean"==typeof(a=b.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[c]])&&(a=Number(a)),a}}function bn(a,b,c,d,e){return Cf(a,(g,f)=>{const a=b instanceof dj?b.get(f):null;return a&&a.evaluate?a.evaluate(c,d,e):a})}function cn(a,b){return b-a}c("FeatureIndex",Ye,{omit:["rawTileData","sourceLayerCoder"]});var Ze=j([{name:"a_pos",type:"Int16",components:2}]);const aa=new Uint16Array(8184);for(let ba=0;ba<2046;ba++){let Ga=ba+2,D=0,E=0,F=0,G=0,ca=0,da=0;for(1&Ga?F=G=ca=32:D=E=da=32;(Ga>>=1)>1;){const $e=D+F>>1,_e=E+G>>1;1&Ga?(F=D,G=E,D=ca,E=da):(D=F,E=G,F=ca,G=da),ca=$e,da=_e}const ea=4*ba;aa[ea+0]=D,aa[ea+1]=E,aa[ea+2]=F,aa[ea+3]=G}const dn=new Uint16Array(2178),en=new Uint8Array(1089),fn=new Uint16Array(1089);function gn(a){return 0===a?-0.03125:32===a?.03125:0}var af=j([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const hn={type:2,extent:8192,loadGeometry:()=>[[new Ha(0,0),new Ha(8193,0),new Ha(8193,8193),new Ha(0,8193),new Ha(0,0)]]};class bf{constructor(b,c,d,a,e){this.tileID=b,this.uid=ac(),this.uses=0,this.tileSize=c,this.tileZoom=d,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=e,this.expiredRequestCount=0,this.state="loading",a&&a.transform&&(this.projection=a.transform.projection)}registerFadeDuration(b){const a=b+this.timeAdded;ae.getLayer(a)).filter(Boolean);if(0!==c.length)for(const f of(a.layers=c,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(a=>c.filter(b=>b.id===a)[0])),c))b[f.id]=a}return b})(a.buckets,b.style),this.hasSymbolBuckets=!1,this.buckets){const c=this.buckets[g];if(c instanceof Da){if(this.hasSymbolBuckets=!0,!f)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const h in this.buckets){const d=this.buckets[h];if(d instanceof Da&&d.hasRTLText){this.hasRTLText=!0,yd.isLoading()||yd.isLoaded()||"deferred"!==xd()||Zi();break}}for(const e in this.queryPadding=0,this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,b.style.getLayer(e).queryRadius(i))}a.imageAtlas&&(this.imageAtlas=a.imageAtlas),a.glyphAtlasImage&&(this.glyphAtlasImage=a.glyphAtlasImage),a.lineAtlas&&(this.lineAtlas=a.lineAtlas)}else this.collisionBoxArray=new Cd}unloadVectorData(){if(this.hasData()){for(const a in this.buckets)this.buckets[a].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(a){return this.buckets[a.id]}upload(a){for(const d in this.buckets){const c=this.buckets[d];c.uploadPending()&&c.upload(a)}const b=a.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ue(a,this.imageAtlas.image,b.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ue(a,this.glyphAtlasImage,b.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Ue(a,this.lineAtlas.image,b.ALPHA),this.lineAtlas.uploaded=!0)}prepare(a){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(a,this.imageAtlasTexture)}queryRenderedFeatures(a,b,c,d,e,f,g,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:g,transform:f,params:e,tileTransform:this.tileTransform},a,b,c):{}}querySourceFeatures(m,a){const b=this.latestFeatureIndex;if(!b||!b.rawTileData)return;const g=b.loadVTLayers(),h=a?a.sourceLayer:"",d=g._geojsonTileLayer||g[h];if(!d)return;const e=Jh(a&&a.filter),{z:i,x:j,y:k}=this.tileID.canonical,n={z:i,x:j,y:k};for(let f=0;fe)a=!1;else if(c)if(this.expirationTime=0;f--){const g=4*f,h=aa[g+0],i=aa[g+1],j=aa[g+2],k=aa[g+3],l=h+j>>1,m=i+k>>1,r=l+m-i,s=m+h-l,t=33*i+h,u=33*k+j,a=33*m+l,y=Math.hypot((dn[2*t+0]+dn[2*u+0])/2-dn[2*a+0],(dn[2*t+1]+dn[2*u+1])/2-dn[2*a+1])>=16;if(en[a]=en[a]||(y?1:0),f<1022){const z=(i+s>>1)*33+(h+r>>1),A=(k+s>>1)*33+(j+r>>1);en[a]=en[a]||en[z]||en[A]}}const B=new oa,C=new sa;let D=0;function E(b,c){const a=33*c+b;return 0===fn[a]&&(B.emplaceBack(dn[2*a+0],dn[2*a+1],8192*b/32,8192*c/32),fn[a]=++D),fn[a]-1}function v(a,b,e,f,c,d){const g=a+e>>1,h=b+f>>1;if(Math.abs(a-c)+Math.abs(b-d)>1&&en[33*h+g])v(c,d,a,b,g,h),v(e,f,c,d,g,h);else{const i=E(a,b),j=E(e,f),k=E(c,d);C.emplaceBack(i,j,k)}}return v(0,0,32,32,32,0),v(32,32,0,0,0,32),{vertices:B,indices:C}}(this.tileID.canonical,e);a=g.vertices,b=g.indices}else{for(const{x:i,y:j}of(a=new oa,b=new sa,h))a.emplaceBack(i,j,0,0);const d=ne(a.int16,void 0,4);for(let c=0;c{const a=65*d+b;c.emplaceBack(a+1,a,a+65),c.emplaceBack(a+65,a+65+1,a+1)};for(let a=0;a<64;a++)for(let b=0;b<64;b++)d(b,a);return c}getWirefameBuffer(b){if(!this.wireframeSegments){const a=this._createWireframeGrid();this.wireframeIndexBuffer=b.createIndexBuffer(a),this.wireframeSegments=Aa.simpleSegment(0,0,4096,a.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const c=new Y,d=(b,d)=>{const a=65*d+b;c.emplaceBack(a,a+1),c.emplaceBack(a,a+65),c.emplaceBack(a,a+65+1)};for(let a=0;a<64;a++)for(let b=0;b<64;b++)d(b,a);return c}}function hf(a,b){if(!b.isReprojectedInTileSpace)return{scale:1<m&&(n(i,a,e,f,c,d),n(a,j,c,d,g,h))}n(c,d,h,j,i,j),n(d,e,i,j,i,k),n(e,f,i,k,h,k),n(f,c,h,k,h,j),o-=m,p-=m,q+=m,r+=m;const l=1/Math.max(q-o,r-p);return{scale:l,x:o*l,y:p*l,x2:q*l,y2:r*l,projection:b}}class jf{constructor(c){const d={},e=[];for(const f in c){const g=c[f],q=d[f]={};for(const h in g.glyphs){const a=g.glyphs[+h];if(!a||0===a.bitmap.width||0===a.bitmap.height)continue;const i=a.metrics.localGlyph?2:1,j={x:0,y:0,w:a.bitmap.width+2*i,h:a.bitmap.height+2*i};e.push(j),q[h]=j}}const{w:r,h:s}=Ge(e),k=new ke({width:r||1,height:s||1});for(const l in c){const m=c[l];for(const n in m.glyphs){const b=m.glyphs[+n];if(!b||0===b.bitmap.width||0===b.bitmap.height)continue;const o=d[l][n],p=b.metrics.localGlyph?2:1;ke.copy(b.bitmap,k,{x:0,y:0},{x:o.x+p,y:o.y+p},b.bitmap)}}this.image=k,this.positions=d}}c("GlyphAtlas",jf);class rn{constructor(a){this.tileID=new yb(a.tileID.overscaledZ,a.tileID.wrap,a.tileID.canonical.z,a.tileID.canonical.x,a.tileID.canonical.y),this.tileZoom=a.tileZoom,this.uid=a.uid,this.zoom=a.zoom,this.canonical=a.tileID.canonical,this.pixelRatio=a.pixelRatio,this.tileSize=a.tileSize,this.source=a.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=a.showCollisionBoxes,this.collectResourceTiming=!!a.collectResourceTiming,this.returnDependencies=!!a.returnDependencies,this.promoteId=a.promoteId,this.enableTerrain=!!a.enableTerrain,this.isSymbolTile=a.isSymbolTile,this.tileTransform=hf(a.tileID.canonical,a.projection),this.projection=a.projection}parse(h,v,i,j,E){this.status="parsing",this.data=h,this.collisionBoxArray=new Cd;const w=new Qm(Object.keys(h.layers).sort()),c=new Ye(this.tileID,this.promoteId);c.bucketLayerIDs=[];const x={},m=new wb(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:i},k=v.familiesBySource[this.source];for(const b in k){const e=h.layers[b];if(!e)continue;let n=!1,o=!1;for(const y of k[b])"symbol"===y[0].type?n=!0:o=!0;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!o)continue;1===e.version&&gc(`Vector tile source "${this.source}" layer "${b}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const p=w.encode(b),q=[];for(let f=0;f=a.maxzoom||"none"!==a.visibility&&(sn(g,this.zoom,i),(x[a.id]=a.createBucket({index:c.bucketLayerIDs.length,layers:g,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:i})).populate(q,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(g.map(a=>a.id)))}}let F,A,B,C;m.trim();const l={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},s=Cf(d.glyphDependencies,a=>Object.keys(a).map(Number));Object.keys(s).length?j.send("getGlyphs",{uid:this.uid,stacks:s},(a,b)=>{F||(F=a,A=b,D.call(this))},void 0,!1,l):A={};const t=Object.keys(d.iconDependencies);t.length?j.send("getImages",{icons:t,source:this.source,tileID:this.tileID,type:"icons"},(a,b)=>{F||(F=a,B=b,D.call(this))},void 0,!1,l):B={};const u=Object.keys(d.patternDependencies);function D(){if(F)return E(F);if(A&&B&&C){const b=new jf(A),e=new He(B,C);for(const f in x){const a=x[f];a instanceof Da?(sn(a.layers,this.zoom,i),pm(a,A,b.positions,B,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection),a.projection=this.projection.name):a.hasPattern&&(a instanceof ye||a instanceof oe||a instanceof ve)&&(sn(a.layers,this.zoom,i),a.addFeatures(d,this.tileID.canonical,e.patternPositions,i))}this.status="done",E(null,{buckets:$b(x).filter(a=>!a.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,lineAtlas:m,imageAtlas:e,glyphMap:this.returnDependencies?A:null,iconMap:this.returnDependencies?B:null,glyphPositions:this.returnDependencies?b.positions:null})}}u.length?j.send("getImages",{icons:u,source:this.source,tileID:this.tileID,type:"patterns"},(a,b)=>{F||(F=a,C=b,D.call(this))},void 0,!1,l):C={},D.call(this)}}function sn(a,b,c){const d=new zd(b);for(const e of a)e.recalculate(d,c)}class kf{constructor(a){this.entries={},this.scheduler=a}request(b,d,e,c){const a=this.entries[b]=this.entries[b]||{callbacks:[]};if(a.result){const[f,g]=a.result;return this.scheduler?this.scheduler.add(()=>{c(f,g)},d):c(f,g),()=>{}}return a.callbacks.push(c),a.cancel||(a.cancel=e((c,e)=>{for(const f of(a.result=[c,e],a.callbacks))this.scheduler?this.scheduler.add(()=>{f(c,e)},d):f(c,e);setTimeout(()=>delete this.entries[b],3e3)})),()=>{a.result||(a.callbacks=a.callbacks.filter(a=>a!==c),a.callbacks.length||(a.cancel(),delete this.entries[b]))}}}function lf(a,c,d){const b=JSON.stringify(a.request);return a.data&&(this.deduped.entries[b]={result:[null,a.data]}),this.deduped.request(b,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},b=>{const c=fg(a.request,(c,a,e,f)=>{c?b(c):a&&b(null,{vectorTile:d?void 0:new _.VectorTile(new Fe(a)),rawData:a,cacheControl:e,expires:f})});return()=>{c.cancel(),b()}},c)}const tn=Ka(new Float64Array(16));class un{constructor(a,b){this._tr=a,this._worldSize=b}createInversionMatrix(){return tn}createTileMatrix(e){let a,f,g;const c=e.canonical,b=Ka(new Float64Array(16)),h=this._tr.projection;if(h.isReprojectedInTileSpace){const d=hf(c,h);a=1,f=d.x+e.wrap*d.scale,g=d.y,Db(b,b,[a/d.scale,a/d.scale,this._tr.pixelsPerMeter/this._worldSize])}else a=this._worldSize/this._tr.zoomScale(c.z),f=(c.x+Math.pow(2,c.z)*e.wrap)*a,g=c.y*a;return Cb(b,b,[f,g,0]),Db(b,b,[a/8192,a/8192,1]),b}pointCoordinate(a,b,c){const d=this._tr.horizonLineFromTop(!1),e=new Ha(a,Math.max(d,b));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(e,c))}upVector(){return[0,0,1]}upVectorScale(){return 1}}var mf={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&vf(this.parallels,this.constants.parallels))return;const a=Math.sin(ga(this.parallels[0])),b=(a+Math.sin(ga(this.parallels[1])))/2,c=1+a*(2*b-a),d=Math.sqrt(c)/b;this.constants={n:b,c:c,r0:d,parallels:this.parallels}},project(d,e){this.initializeConstants();const b=ga(d-this.center[0]),f=ga(e),{n:a,c:g,r0:h}=this.constants,c=Math.sqrt(g-2*a*Math.sin(f))/a;return{x:c*Math.sin(b*a),y:c*Math.cos(b*a)-h,z:0}},unproject(c,f){this.initializeConstants();const{n:a,c:g,r0:h}=this.constants,b=h+f;let d=Math.atan2(c,Math.abs(b))*Math.sign(b);b*a<0&&(d-=Math.PI*Math.sign(c)*Math.sign(b));const e=ga(this.center[0])*a;d=Yb(d,-Math.PI-e,Math.PI-e);const i=Tb(d/a)+this.center[0],j=Math.asin(Wb((g-(c*c+b*b)*a*a)/(2*a),-1,1)),k=Wb(Tb(j),-85.051129,85.051129);return new _d(i,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>ce(1,a)*b,farthestPixelDistance(a){return ln(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new un(a,b)};const vn=Math.sqrt(3)/2;var nf={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(c,d){d=d/180*Math.PI,c=c/180*Math.PI;const b=Math.asin(vn*Math.sin(d)),a=b*b,e=a*a*a;return{x:.5*(c*Math.cos(b)/(vn*(1.340264+ -0.24331799999999998*a+e*(.0062510000000000005+.034164*a)))/Math.PI+.5),y:1-.5*(b*(1.340264+ -0.081106*a+e*(893e-6+.003796*a))/Math.PI+1),z:0}},unproject(d,e){d=(2*d-.5)*Math.PI;let b=e=(2*(1-e)-1)*Math.PI,a=b*b,c=a*a*a;for(let f,g,h,i=0;i<12&&(g=b*(1.340264+ -0.081106*a+c*(893e-6+.003796*a))-e,h=1.340264+ -0.24331799999999998*a+c*(.0062510000000000005+.034164*a),f=g/h,b=Wb(b-f,-Math.PI/3,Math.PI/3),a=b*b,c=a*a*a,!(1e-12>Math.abs(f)));++i);const j=Wb(180*(vn*d*(1.340264+ -0.24331799999999998*a+c*(.0062510000000000005+.034164*a))/Math.cos(b))/Math.PI,-180,180),k=Wb(180*Math.asin(Math.sin(b)/vn)/Math.PI,-85.051129,85.051129);return new _d(j,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>ce(1,a)*b,farthestPixelDistance(a){return ln(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new un(a,b)},of={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(a,b)=>({x:.5+a/360,y:.5-b/360,z:0}),unproject(a,b){const c=Wb(360*(.5-b),-85.051129,85.051129);return new _d(360*(a-.5),c)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>ce(1,a)*b,farthestPixelDistance(a){return ln(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new un(a,b)};const wn=Math.PI/2;function xn(a){return Math.tan((wn+a)/2)}var pf={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&vf(this.parallels,this.constants.parallels))return;const a=ga(this.parallels[0]),b=ga(this.parallels[1]),d=Math.cos(a),c=a===b?Math.sin(a):Math.log(d/Math.cos(b))/Math.log(xn(b)/xn(a)),e=d*Math.pow(xn(a),c)/c;this.constants={n:c,f:e,parallels:this.parallels}},project(b,a){this.initializeConstants(),a=ga(a),b=ga(b-this.center[0]);const{n:c,f:d}=this.constants;d>0?a< -wn+1e-6&&(a=-wn+1e-6):a>wn-1e-6&&(a=wn-1e-6);const e=d/Math.pow(xn(a),c);return{x:.5*(e*Math.sin(c*b)/Math.PI+.5),y:1-.5*((d-e*Math.cos(c*b))/Math.PI+.5),z:0}},unproject(a,d){this.initializeConstants(),a=(2*a-.5)*Math.PI,d=(2*(1-d)-.5)*Math.PI;const{n:c,f:e}=this.constants,b=e-d,f=Math.sign(b),h=Math.sign(c)*Math.sqrt(a*a+b*b);let g=Math.atan2(a,Math.abs(b))*f;b*c<0&&(g-=Math.PI*Math.sign(a)*f);const i=Wb(Tb(g/c)+this.center[0],-180,180),j=Wb(Tb(2*Math.atan(Math.pow(e/h,1/c))-wn),-85.051129,85.051129);return new _d(i,j)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>ce(1,a)*b,farthestPixelDistance(a){return ln(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new un(a,b)},qf={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(a,b)=>({x:ae(a),y:be(b),z:0}),unproject(a,b){const c=zj(a),d=de(b);return new _d(c,d)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>ce(1,a)*b,farthestPixelDistance(a){return ln(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new un(a,b)};const yn=ga(85.051129);var rf={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(d,c){const a=(c=ga(c))*c,b=a*a;return{x:.5*((d=ga(d))*(.8707-.131979*a+b*(b*(.003971*a-.001529*b)-.013791))/Math.PI+.5),y:1-.5*(c*(1.007226+a*(.015085+b*(.028874*a-.044475-.005916*b)))/Math.PI+1),z:0}},unproject(d,e){d=(2*d-.5)*Math.PI;let b=e=(2*(1-e)-1)*Math.PI,g=25,f=0,a=b*b;do{a=b*b;const c=a*a;f=(b*(1.007226+a*(.015085+c*(.028874*a-.044475-.005916*c)))-e)/(1.007226+a*(.045255+c*(.259866*a-.311325-.005916*11*c))),b=Wb(b-f,-yn,yn)}while(Math.abs(f)>1e-6&& --g>0)a=b*b;const h=Wb(Tb(d/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))),-180,180),i=Tb(b);return new _d(h,i)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>ce(1,a)*b,farthestPixelDistance(a){return ln(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new un(a,b)};const zn=ga(85.051129),An={albers:mf,equalEarth:nf,equirectangular:of,lambertConformalConic:pf,mercator:qf,naturalEarth:rf,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(a,b){b=ga(b),a=ga(a);const c=Math.cos(b),d=Math.acos(c*Math.cos(a/2)),e=Math.sin(d)/d;return{x:.5*((.5*(a*(2/Math.PI)+2*c*Math.sin(a/2)/e)||0)/Math.PI+.5),y:1-.5*((.5*(b+Math.sin(b)/e)||0)/Math.PI+1),z:0}},unproject(j,k){let b=j=(2*j-.5)*Math.PI,c=k=(2*(1-k)-1)*Math.PI,z=25,l=0,m=0;do{const a=Math.cos(c),d=Math.sin(c),o=2*d*a,p=d*d,n=a*a,e=Math.cos(b/2),f=Math.sin(b/2),q=2*e*f,r=f*f,h=1-n*e*e,i=h?1/h:0,g=h?Math.acos(a*e)*Math.sqrt(1/h):0,s=.5*(2*g*a*f+2*b/Math.PI)-j,t=.5*(g*d+c)-k,u=.5*i*(n*r+g*a*e*p)+1/Math.PI,v=i*(q*o/4-g*d*f),w=.125*i*(o*f-g*d*n*q),x=.5*i*(p*e+g*r*a)+.5,y=v*w-x*u;l=(t*v-s*x)/y,m=(s*w-t*u)/y,b=Wb(b-l,-Math.PI,Math.PI),c=Wb(c-m,-zn,zn)}while((Math.abs(l)>1e-6||Math.abs(m)>1e-6)&& --z>0)return new _d(Tb(b),Tb(c))},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>ce(1,a)*b,farthestPixelDistance(a){return ln(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new un(a,b)}};a.ARRAY_TYPE=I,a.AUTH_ERR_MSG=lc,a.Aabb=B,a.Actor=class{constructor(a,b,c){this.target=a,this.parent=b,this.mapId=c,this.callbacks={},this.cancelCallbacks={},cc(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=hc()?a:s,this.scheduler=new class{constructor(){this.tasks={},this.taskQueue=[],cc(["process"],this),this.invoker=new class{constructor(a){this._callback=a,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}(this.process),this.nextId=0}add(b,c){const a=this.nextId++,d=function({type:b,isSymbolTile:c,zoom:a}){return a=a||0,"message"===b?0:"maybePrepare"!==b||c?"parseTile"!==b||c?"parseTile"===b&&c?300-a:"maybePrepare"===b&&c?400-a:500:200-a:100-a}(c);if(0===d){hc();try{b()}finally{}return{cancel:()=>{}}}return this.tasks[a]={fn:b,metadata:c,priority:d,id:a},this.taskQueue.push(a),this.invoker.trigger(),{cancel:()=>{delete this.tasks[a]}}}process(){hc();try{if(this.taskQueue=this.taskQueue.filter(a=>!!this.tasks[a]),!this.taskQueue.length)return;const a=this.pick();if(null===a)return;const b=this.tasks[a];if(delete this.tasks[a],this.taskQueue.length&&this.invoker.trigger(),!b)return;b.fn()}finally{}}pick(){let a=null,c=1/0;for(let b=0;b{a&&delete this.callbacks[b],this.target.postMessage({id:b,type:"",targetMapId:f,sourceMapId:this.mapId})}}}receive(e){const a=e.data,b=a.id;if(b&&(!a.targetMapId||this.mapId===a.targetMapId))if(""===a.type){const c=this.cancelCallbacks[b];delete this.cancelCallbacks[b],c&&c.cancel()}else if(a.mustQueue||hc()){const d=this.callbacks[b];this.cancelCallbacks[b]=this.scheduler.add(()=>this.processTask(b,a),d&&d.metadata||{type:"message"})}else this.processTask(b,a)}processTask(e,a){if(""===a.type){const b=this.callbacks[e];delete this.callbacks[e],b&&(a.error?b(ii(a.error)):b(null,ii(a.data)))}else{const g=Kf(this.globalScope)?void 0:[],c=a.hasCallback?(a,b)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:a?hi(a):null,data:hi(b,g)},g)}:a=>{},d=ii(a.data);if(this.parent[a.type])this.parent[a.type](a.sourceMapId,d,c);else if(this.parent.getWorkerSource){const f=a.type.split(".");this.parent.getWorkerSource(a.sourceMapId,f[0],d.source)[f[1]](d,c)}else c(new Error(`Could not find function ${a.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=xb,a.Color=m,a.ColorMode=r,a.CullFaceMode=o,a.DEMData=zb,a.DataConstantProperty=e,a.DedupedRequest=kf,a.DepthMode=C,a.EXTENT=8192,a.Elevation=class{getAtPointOrZero(a,b=0){return this.getAtPoint(a,b)||0}getAtPoint(a,e,o=!0){null==e&&(e=null);const i=this._source();if(!i)return e;if(a.y<0||a.y>1)return e;const g=i.getSource().maxzoom,j=1<{const e=this.getAtTileOffset(a,c.x,c.y),d=b.upVector(a.canonical,c.x,c.y);return Ib(d,d,e*b.upVectorScale(a.canonical)),d}}getForTilePoints(a,b,e,c){const d=an.create(this,a,c);return!!d&&(b.forEach(a=>{a[2]=this.exaggeration()*d.getElevationAt(a[0],a[1],e)}),!0)}getMinMaxForTile(a){const c=this.findDEMTileFor(a);if(!c||!c.dem)return null;const d=c.dem.tree,e=c.tileID,h=1<Math.abs(e))return!1;const d=((b[0]-this.pos[0])*a[0]+(b[1]-this.pos[1])*a[1]+(b[2]-this.pos[2])*a[2])/e;return c[0]=this.pos[0]+this.dir[0]*d,c[1]=this.pos[1]+this.dir[1]*d,c[2]=this.pos[2]+this.dir[2]*d,!0}closestPointOnSphere(i,b,a){var j,k,n,o,p,q,r,s;if(j=this.pos,k=i,n=j[0],o=j[1],p=j[2],q=k[0],r=k[1],s=k[2],Math.abs(n-q)<=1e-6*Math.max(1,Math.abs(n),Math.abs(q))&&Math.abs(o-r)<=1e-6*Math.max(1,Math.abs(o),Math.abs(r))&&Math.abs(p-s)<=1e-6*Math.max(1,Math.abs(p),Math.abs(s))||0===b)return a[0]=a[1]=a[2]=0,!1;const[f,g,h]=this.dir,c=this.pos[0]-i[0],d=this.pos[1]-i[1],e=this.pos[2]-i[2],w=f*f+g*g+h*h,l=2*(c*f+d*g+e*h),x=l*l-4*w*(c*c+d*d+e*e-b*b);if(x<0){const t=Math.max(-l/2,0),y=c+f*t,z=d+g*t,A=e+h*t,u=Math.hypot(y,z,A);return a[0]=y*b/u,a[1]=z*b/u,a[2]=A*b/u,!1}{const m=(-l-Math.sqrt(x))/(2*w);if(m<0){const v=Math.hypot(c,d,e);return a[0]=c*b/v,a[1]=d*b/v,a[2]=e*b/v,!1}return a[0]=c+f*m,a[1]=d+g*m,a[2]=e+h*m,!0}}},a.RequestManager=class{constructor(a,b,c){this._transformRequestFn=a,this._customAccessToken=b,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){const a=function(){let a="";for(let b=0;b<10;b++)a+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",a].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=a.token,this._skuTokenExpiresAt=a.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(a,b){return this._transformRequestFn&&this._transformRequestFn(a,b)||{url:a}}normalizeStyleURL(a,c){if(!mc(a))return a;const b=Tf(a);return b.path=`/styles/v1${b.path}`,this._makeAPIURL(b,this._customAccessToken||c)}normalizeGlyphsURL(a,c){if(!mc(a))return a;const b=Tf(a);return b.path=`/fonts/v1${b.path}`,this._makeAPIURL(b,this._customAccessToken||c)}normalizeSourceURL(b,c){if(!mc(b))return b;const a=Tf(b);return a.path=`/v4/${a.authority}.json`,a.params.push("secure"),this._makeAPIURL(a,this._customAccessToken||c)}normalizeSpriteURL(b,c,d,e){const a=Tf(b);return mc(b)?(a.path=`/styles/v1${a.path}/sprite${c}${d}`,this._makeAPIURL(a,this._customAccessToken||e)):(a.path+=`${c}${d}`,Uf(a))}normalizeTileURL(b,e,c){if(this._isSkuTokenExpired()&&this._createSkuToken(),b&&!mc(b))return b;const a=Tf(b);a.path=a.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||c&&"raster"!==a.authority&&512===c?"@2x":""}${kc.supported?".webp":"$1"}`),"raster"===a.authority?a.path=`/${jc.RASTER_URL_PREFIX}${a.path}`:(a.path=a.path.replace(/^.+\/v4\//,"/"),a.path=`/${jc.TILE_URL_VERSION}${a.path}`);const d=this._customAccessToken||function(b){for(const c of b){const a=c.match(/^access_token=(.*)$/);if(a)return a[1]}return null}(a.params)||jc.ACCESS_TOKEN;return jc.REQUIRE_ACCESS_TOKEN&&d&&this._skuToken&&a.params.push(`sku=${this._skuToken}`),this._makeAPIURL(a,d)}canonicalizeTileURL(d,e){const a=Tf(d);if(!a.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!a.path.match(/\.[\w]+$/))return d;let b="mapbox://";a.path.match(/^\/raster\/v1\//)?b+=`raster/${a.path.replace(`/${jc.RASTER_URL_PREFIX}/`,"")}`:b+=`tiles/${a.path.replace(`/${jc.TILE_URL_VERSION}/`,"")}`;let c=a.params;return e&&(c=c.filter(a=>!a.match(/^access_token=/))),c.length&&(b+=`?${c.join("&")}`),b}canonicalizeTileset(d,c){const e=!!c&&mc(c),a=[];for(const b of d.tiles||[])Rf(b)?a.push(this.canonicalizeTileURL(b,e)):a.push(b);return a}_makeAPIURL(a,b){const d="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",c=Tf(jc.API_URL);if(a.protocol=c.protocol,a.authority=c.authority,"http"===a.protocol){const e=a.params.indexOf("secure");e>=0&&a.params.splice(e,1)}if("/"!==c.path&&(a.path=`${c.path}${a.path}`),!jc.REQUIRE_ACCESS_TOKEN)return Uf(a);if(b=b||jc.ACCESS_TOKEN,!this._silenceAuthErrors){if(!b)throw new Error(`An API access token is required to use Mapbox GL. ${d}`);if("s"===b[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${d}`)}return a.params=a.params.filter(a=>-1===a.indexOf("access_token")),a.params.push(`access_token=${b||""}`),Uf(a)}},a.ResourceType=Wa,a.SegmentVector=Aa,a.SourceCache=Fa,a.StencilMode=Ea,a.StructArrayLayout1ui2=xa,a.StructArrayLayout2f1f2i16=ra,a.StructArrayLayout2i4=na,a.StructArrayLayout2ui4=Y,a.StructArrayLayout3f12=pa,a.StructArrayLayout3ui6=sa,a.StructArrayLayout4i8=oa,a.Texture=Ue,a.Tile=bf,a.Transitionable=Ad,a.Uniform1f=Pd,a.Uniform1i=class extends za{constructor(a,b){super(a,b),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},a.Uniform2f=class extends za{constructor(a,b){super(a,b),this.current=[0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]||(this.current=a,this.gl.uniform2f(this.location,a[0],a[1]))}},a.Uniform3f=class extends za{constructor(a,b){super(a,b),this.current=[0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]||(this.current=a,this.gl.uniform3f(this.location,a[0],a[1],a[2]))}},a.Uniform4f=Qd,a.UniformColor=Rd,a.UniformMatrix2f=class extends za{constructor(a,b){super(a,b),this.current=oj}set(b){for(let a=0;a<4;a++)if(b[a]!==this.current[a]){this.current=b,this.gl.uniformMatrix2fv(this.location,!1,b);break}}},a.UniformMatrix3f=class extends za{constructor(a,b){super(a,b),this.current=nj}set(b){for(let a=0;a<9;a++)if(b[a]!==this.current[a]){this.current=b,this.gl.uniformMatrix3fv(this.location,!1,b);break}}},a.UniformMatrix4f=class extends za{constructor(a,b){super(a,b),this.current=mj}set(a){if(a[12]!==this.current[12]||a[0]!==this.current[0])return this.current=a,void this.gl.uniformMatrix4fv(this.location,!1,a);for(let b=1;b<16;b++)if(a[b]!==this.current[b]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},a.UnwrappedTileID=We,a.ValidationError=wc,a.VectorTileWorkerSource=class extends S{constructor(a,b,c,d,e){super(),this.actor=a,this.layerIndex=b,this.availableImages=c,this.loadVectorData=e||lf,this.loading={},this.loaded={},this.deduped=new kf(a.scheduler),this.isSpriteLoaded=d,this.scheduler=a.scheduler}loadTile(a,e){const c=a.uid,b=a&&a.request,f=b&&b.collectResourceTiming,d=this.loading[c]=new rn(a);d.abort=this.loadVectorData(a,(h,g)=>{const i=!this.loading[c];if(delete this.loading[c],i||h||!g)return d.status="done",i||(this.loaded[c]=d),e(h);const k=g.rawData,j={};g.expires&&(j.expires=g.expires),g.cacheControl&&(j.cacheControl=g.cacheControl),d.vectorTile=g.vectorTile||new _.VectorTile(new Fe(k));const l=()=>{d.parse(d.vectorTile,this.layerIndex,this.availableImages,this.actor,(a,c)=>{if(a||!c)return e(a);const d={};if(f){const g=Ve(b);g.length>0&&(d.resourceTiming=JSON.parse(JSON.stringify(g)))}e(null,_b({rawTileData:k.slice(0)},c,j,d))})};this.isSpriteLoaded?l():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(l,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):l()}),this.loaded=this.loaded||{},this.loaded[c]=d})}reloadTile(b,f){const c=this.loaded,e=b.uid,g=this;if(c&&c[e]){const a=c[e];a.showCollisionBoxes=b.showCollisionBoxes,a.enableTerrain=!!b.enableTerrain,a.projection=b.projection;const d=(c,d)=>{const b=a.reloadCallback;b&&(delete a.reloadCallback,a.parse(a.vectorTile,g.layerIndex,this.availableImages,g.actor,b)),f(c,d)};"parsing"===a.status?a.reloadCallback=d:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,d):d())}}abortTile(c,d){const b=c.uid,a=this.loading[b];a&&(a.abort&&a.abort(),delete this.loading[b]),d()}removeTile(c,d){const a=this.loaded,b=c.uid;a&&a[b]&&delete a[b],d()}},a.WritingMode=Ie,a.ZoomHistory=ud,a.add=Hb,a.addDynamicAttributes=vb,a.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},a.asyncAll=Zb,a.bezier=Ra,a.bindAll=cc,a.boundsAttributes=af,a.bufferConvexPolygon=function(a,g){const e=[];for(let b=0;bag&&(a.getActor().send("enforceCacheSizeLimit",_f),dg=0)},a.calculateGlobeMatrix=ff,a.calculateGlobeMercatorMatrix=function(a){const c=a.worldSize,f=Wb(a.center.lat,-85.051129,85.051129),d=new Ha(ae(a.center.lng)*c,be(f)*c),g=ce(1,a.center.lat)*c,h=a.pixelsPerMeter,e=c/(g/a.pixelsPerMeter),b=Ka(new Float64Array(16));return Cb(b,b,[d.x,d.y,0]),Db(b,b,[e,e,h]),b},a.clamp=Wb,a.clearTileCache=function(a){const b=s.caches.delete(Yf);a&&b.catch(a).then(()=>a())},a.clipLine=Le,a.clone=function(b){var a=new I(16);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},a.clone$1=fc,a.collisionCircleLayout=Ce,a.config=jc,a.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},a.create=function(){var a=new I(16);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},a.create$1=Ja,a.createExpression=fd,a.createLayout=j,a.createStyleLayer=function(a){return"custom"===a.type?new Em(a):new Hm[a.type](a)},a.cross=Mb,a.degToRad=ga,a.div=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},a.dot=Lb,a.ease=Vb,a.easeCubicInOut=Ub,a.emitValidationErrors=td,a.endsWith=dc,a.enforceCacheSizeLimit=function(a){bg(),Zf&&Zf.then(b=>{b.keys().then(d=>{for(let c=0;cb&&(e+=(c[a]-b)*(c[a]-b)),d[a]Math.abs(a.parallels[0]+a.parallels[1])){let c=function(b){const a=Math.max(.01,Math.cos(ga(b))),c=1/(2*Math.max(Math.PI*a,1/a));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(b,d){const e=ga(b)*a,f=Math.sin(ga(d))/a;return{x:e*c+.5,y:-f*c+.5,z:0}},unproject(b,d){const e=-(d-.5)/c,f=Wb(Tb((b-.5)/c)/a,-180,180),g=Math.asin(Wb(e*a,-1,1)),h=Wb(Tb(g),-85.051129,85.051129);return new _d(f,h)}}}(a.parallels[0]);if("lambertConformalConic"===a.name){const{project:d,unproject:e}=An.mercator;c={wrap:!0,supportsWorldCopies:!0,project:d,unproject:e}}return _b({},b,a,c)}return _b({},b,a)})(a,b):a},a.getRTLTextPluginStatus=xd,a.getReferrer=qc,a.getTilePoint=function(a,{x:b,y:c},d=0){return new Ha(((b-d)*a.scale-a.x)*8192,(c*a.scale-a.y)*8192)},a.getTileVec3=function(a,b,c=0){return Q(((b.x-c)*a.scale-a.x)*8192,(b.y*a.scale-a.y)*8192,Aj(b.z,b.y))},a.getVideo=function(c,e){const a=s.document.createElement("video");a.muted=!0,a.onloadstart=function(){e(null,a)};for(let b=0;b{}}},a.globeBuffersForTileMesh=function(d,a,e,f){const g=d.context,h=d.transform;let b=a.globeGridBuffer,c=a.globePoleBuffer;if(!b){const i=gf.createGridVertices(e.canonical);b=a.globeGridBuffer=g.createVertexBuffer(i,kn,!1)}if(!c){const j=gf.createPoleTriangleVertices(f,h.tileSize*f,0===e.canonical.y);c=a.globePoleBuffer=g.createVertexBuffer(j,kn,!1)}return[b,c]},a.globeDenormalizeECEF=ef,a.globeMatrixForTile=function(d,e){var a,b;const f=ef(df(d)),c=((a=new Float64Array(16))[0]=(b=e)[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a);return Gb(c,c,f),c},a.globePoleMatrixForTile=function(e,g,b){const a=Ka(new Float64Array(16)),c=Math.pow(2,e.z),h=(e.x-c/2)/c*Math.PI*2,f=b.point,d=b.worldSize/(b.tileSize*c);return Cb(a,a,[f.x,f.y,-b.worldSize/Math.PI/2]),Db(a,a,[d,d,d]),Eb(a,a,ga(-b._center.lat)),Fb(a,a,ga(-b._center.lng)),Fb(a,a,h),g&&Db(a,a,[1,-1,1]),a},a.globeTileBounds=df,a.globeToMercatorTransition=function(a){return Xb(5,6,a)},a.identity=Ka,a.identity$1=Rb,a.invert=function(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=c[5],j=c[6],k=c[7],l=c[8],m=c[9],n=c[10],o=c[11],p=c[12],q=c[13],r=c[14],s=c[15],t=d*i-e*h,u=d*j-f*h,v=d*k-g*h,w=e*j-f*i,x=e*k-g*i,y=f*k-g*j,z=l*q-m*p,A=l*r-n*p,B=l*s-o*p,C=m*r-n*q,D=m*s-o*q,E=n*s-o*r,a=t*E-u*D+v*C+w*B-x*A+y*z;return a?(b[0]=(i*E-j*D+k*C)*(a=1/a),b[1]=(f*D-e*E-g*C)*a,b[2]=(q*y-r*x+s*w)*a,b[3]=(n*x-m*y-o*w)*a,b[4]=(j*B-h*E-k*A)*a,b[5]=(d*E-f*B+g*A)*a,b[6]=(r*v-p*y-s*u)*a,b[7]=(l*y-n*v+o*u)*a,b[8]=(h*D-i*B+k*z)*a,b[9]=(e*B-d*D-g*z)*a,b[10]=(p*x-q*v+s*t)*a,b[11]=(m*v-l*x-o*t)*a,b[12]=(i*A-h*C-j*z)*a,b[13]=(d*C-e*A+f*z)*a,b[14]=(q*u-p*w-r*t)*a,b[15]=(l*w-m*u+n*t)*a,b):null},a.isMapAuthenticated=function(a){return Xf.has(a)},a.isMapboxURL=mc,a.latFromMercatorY=de,a.len=Na,a.length=Na,a.length$1=function(a){return Math.hypot(a[0],a[1],a[2],a[3])},a.loadVectorTile=lf,a.makeRequest=rc,a.mercatorXfromLng=ae,a.mercatorYfromLat=be,a.mercatorZfromAltitude=ce,a.mul=Gb,a.mul$1=Pa,a.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1],o=c[2],p=c[3],q=c[4],r=c[5],s=c[6],t=c[7],u=c[8];return a[0]=m*d+n*g+o*j,a[1]=m*e+n*h+o*k,a[2]=m*f+n*i+o*l,a[3]=p*d+q*g+r*j,a[4]=p*e+q*h+r*k,a[5]=p*f+q*i+r*l,a[6]=s*d+t*g+u*j,a[7]=s*e+t*h+u*k,a[8]=s*f+t*i+u*l,a},a.multiply$1=La,a.multiply$2=Pa,a.nextPowerOfTwo=bc,a.normalize=Kb,a.normalize$1=function(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],a=d*d+e*e+f*f+g*g;return a>0&&(a=1/Math.sqrt(a)),b[0]=d*a,b[1]=e*a,b[2]=f*a,b[3]=g*a,b},a.number=Za,a.ortho=function(a,b,c,d,e,f,g){var h=1/(b-c),i=1/(d-e),j=1/(f-g);return a[0]=-2*h,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*i,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*j,a[11]=0,a[12]=(b+c)*h,a[13]=(e+d)*i,a[14]=(g+f)*j,a[15]=1,a},a.pbf=Fe,a.perspective=function(a,f,g,c,b){var d,e=1/Math.tan(f/2);return a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(a[10]=(b+c)*(d=1/(c-b)),a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a},a.pick=function(c,d){const e={};for(let a=0;athis._layers[a.id]),e=g[0];if("none"===e.visibility)continue;const h=e.source||"";let c=this.familiesBySource[h];c||(c=this.familiesBySource[h]={});const i=e.sourceLayer||"_geojsonTileLayer";let f=c[i];f||(f=c[i]=[]),f.push(g)}}}const{ImageBitmap:n}=a.window;class o{loadTile(d,e){const{uid:f,encoding:g,rawImageData:b,padding:c,buildQuadTree:h}=d,i=n&&b instanceof n?this.getImageData(b,c):b;e(null,new a.DEMData(f,i,g,c<1,h))}getImageData(b,c){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(b.width,b.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=b.width,this.offscreenCanvas.height=b.height,this.offscreenCanvasContext.drawImage(b,0,0,b.width,b.height);const d=this.offscreenCanvasContext.getImageData(-c,-c,b.width+2*c,b.height+2*c);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new a.RGBAImage({width:d.width,height:d.height},d.data)}}var f,p=function e(b,c){var a,d=b&&b.type;if("FeatureCollection"===d)for(a=0;a=Math.abs(d)?b-f+d:d-f+b,b=f}b+g>=0!= !!i&&a.reverse()}const s=a.vectorTile.VectorTileFeature.prototype.toGeoJSON;class t{constructor(b){this._feature=b,this.extent=a.EXTENT,this.type=b.type,this.properties=b.tags,"id"in b&&!isNaN(b.id)&&(this.id=parseInt(b.id,10))}loadGeometry(){if(1===this._feature.type){const b=[];for(const c of this._feature.geometry)b.push([new a.pointGeometry(c[0],c[1])]);return b}{const d=[];for(const g of this._feature.geometry){const e=[];for(const f of g)e.push(new a.pointGeometry(f[0],f[1]));d.push(e)}return d}}toGeoJSON(a,b,c){return s.call(this,a,b,c)}}class u{constructor(b){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=b.length,this._features=b}feature(a){return new t(this._features[a])}}var g=a.vectorTile.VectorTileFeature,h=i;function i(a,b){this.options=b||{},this.features=a,this.length=a.length}function b(a,b){this.id="number"==typeof a.id?a.id:void 0,this.type=a.type,this.rawGeometry=1===a.type?[a.geometry]:a.geometry,this.properties=a.tags,this.extent=b||4096}i.prototype.feature=function(a){return new b(this.features[a],this.options.extent)},b.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var c=0;c>31}function A(f,a){for(var g=f.loadGeometry(),d=f.type,h=0,i=0,n=g.length,e=0;e>1;D(c,d,g,a,b,f%2),C(c,d,e,a,g-1,f+1),C(c,d,e,g+1,b,f+1)}function D(g,b,e,c,d,h){for(;d>c;){if(d-c>600){const f=d-c+1,l=e-c+1,m=Math.log(f),j=.5*Math.exp(2*m/3),n=.5*Math.sqrt(m*j*(f-j)/f)*(l-f/2<0?-1:1);D(g,b,e,Math.max(c,Math.floor(e-l*j/f+n)),Math.min(d,Math.floor(e+(f-l)*j/f+n)),h)}const k=b[2*e+h];let i=c,a=d;for(E(g,b,c,e),b[2*d+h]>k&&E(g,b,c,d);ik;)a--}b[2*c+h]===k?E(g,b,c,a):(a++,E(g,b,a,d)),a<=e&&(c=a+1),e<=a&&(d=a-1)}}function E(d,c,a,b){F(d,a,b),F(c,2*a,2*b),F(c,2*a+1,2*b+1)}function F(a,b,c){const d=a[b];a[b]=a[c],a[c]=d}function G(c,d,e,f){const a=c-e,b=d-f;return a*a+b*b}c.fromVectorTileJs=j,c.fromGeojsonVt=function(d,b){b=b||{};var c={};for(var a in d)c[a]=new h(d[a].features,b),c[a].name=a,c[a].version=b.version,c[a].extent=b.extent;return j({layers:c})},c.GeoJSONWrapper=h;class H{constructor(b,f=a=>a[0],g=a=>a[1],e=64,h=Float64Array){this.nodeSize=e,this.points=b;const i=b.length<65536?Uint16Array:Uint32Array,c=this.ids=new i(b.length),d=this.coords=new h(2*b.length);for(let a=0;a=j&&b<=l&&c>=k&&c<=m&&n.push(i[d]);continue}const e=Math.floor((h+g)/2);b=f[2*e],c=f[2*e+1],b>=j&&b<=l&&c>=k&&c<=m&&n.push(i[e]);const p=(o+1)%2;(0===o?j<=b:k<=c)&&(a.push(h),a.push(e-1),a.push(p)),(0===o?l>=b:m>=c)&&(a.push(e+1),a.push(g),a.push(p))}return n})(this.ids,this.coords,a,b,c,d,this.nodeSize)}within(a,b,c){return(function(j,e,f,g,b,q){const a=[0,j.length-1,0],k=[],o=b*b;for(;a.length;){const l=a.pop(),h=a.pop(),i=a.pop();if(h-i<=q){for(let c=i;c<=h;c++)G(e[2*c],e[2*c+1],f,g)<=o&&k.push(j[c]);continue}const d=Math.floor((i+h)/2),m=e[2*d],n=e[2*d+1];G(m,n,f,g)<=o&&k.push(j[d]);const p=(l+1)%2;(0===l?f-b<=m:g-b<=n)&&(a.push(i),a.push(d-1),a.push(p)),(0===l?f+b>=m:g+b>=n)&&(a.push(d+1),a.push(h),a.push(p))}return k})(this.ids,this.coords,a,b,c,this.nodeSize)}}const I=Math.fround||(f=new Float32Array(1),a=>(f[0]=+a,f[0]));class J{constructor(a){this.options=R(Object.create({minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:a=>a}),a),this.trees=new Array(this.options.maxZoom+1)}load(b){const{log:c,minZoom:i,maxZoom:f,nodeSize:g}=this.options;c&&console.time("total time");const h=`prepare ${b.length} points`;c&&console.time(h),this.points=b;let a=[];for(let d=0;d=i;e--){const j=+Date.now();a=this._cluster(a,e),this.trees[e]=new H(a,S,T,g,Float32Array),c&&console.log("z%d: %d clusters in %dms",e,a.length,+Date.now()-j)}return c&&console.timeEnd("total time"),this}getClusters(a,d){let b=((a[0]+180)%360+360)%360-180;const e=Math.max(-90,Math.min(90,a[1]));let c=180===a[2]?180:((a[2]+180)%360+360)%360-180;const f=Math.max(-90,Math.min(90,a[3]));if(a[2]-a[0]>=360)b=-180,c=180;else if(b>c){const j=this.getClusters([b,e,180,f],d),k=this.getClusters([-180,e,c,f],d);return j.concat(k)}const h=this.trees[this._limitZoom(d)],l=h.range(O(b),P(f),O(c),P(e)),i=[];for(const m of l){const g=h.points[m];i.push(g.numPoints?M(g):this.points[g.index])}return i}getChildren(c){const h=this._getOriginId(c),g=this._getOriginZoom(c),d="No cluster with the specified id.",a=this.trees[g];if(!a)throw new Error(d);const e=a.points[h];if(!e)throw new Error(d);const i=this.options.radius/(this.options.extent*Math.pow(2,g-1)),j=a.within(e.x,e.y,i),f=[];for(const k of j){const b=a.points[k];b.parentId===c&&f.push(b.numPoints?M(b):this.points[b.index])}if(0===f.length)throw new Error(d);return f}getLeaves(d,a,b){const c=[];return this._appendLeaves(c,d,a=a||10,b=b||0,0),c}getTile(i,d,e){const b=this.trees[this._limitZoom(i)],a=Math.pow(2,i),{extent:j,radius:k}=this.options,c=k/j,g=(e-c)/a,h=(e+1+c)/a,f={features:[]};return this._addTileFeatures(b.range((d-c)/a,g,(d+1+c)/a,h),b.points,d,e,a,f),0===d&&this._addTileFeatures(b.range(1-c/a,g,1,h),b.points,a,e,a,f),d===a-1&&this._addTileFeatures(b.range(0,g,c/a,h),b.points,-1,e,a,f),f.features.length?f:null}getClusterExpansionZoom(a){let b=this._getOriginZoom(a)-1;for(;b<=this.options.maxZoom;){const c=this.getChildren(a);if(b++,1!==c.length)break;a=c[0].properties.cluster_id}return b}_appendLeaves(c,g,e,d,a){const h=this.getChildren(g);for(const f of h){const b=f.properties;if(b&&b.cluster?a+b.point_count<=d?a+=b.point_count:a=this._appendLeaves(c,b.cluster_id,e,d,a):ab&&(c+=o.numPoints||1)}if(c>e&&c>=u){let p=a.x*e,q=a.y*e,i=j&&e>1?this._map(a,!0):null;const l=(g<<5)+(b+1)+this.points.length;for(const x of k){const d=h.points[x];if(d.zoom<=b)continue;d.zoom=b;const r=d.numPoints||1;p+=d.x*r,q+=d.y*r,d.parentId=l,j&&(i||(i=this._map(a,!0)),j(i,this._map(d)))}a.parentId=l,f.push(K(p/c,q/c,l,c,i))}else if(f.push(a),c>1)for(const y of k){const m=h.points[y];m.zoom<=b||(m.zoom=b,f.push(m))}}return f}_getOriginId(a){return a-this.points.length>>5}_getOriginZoom(a){return(a-this.points.length)%32}_map(a,c){if(a.numPoints)return c?R({},a.properties):a.properties;const d=this.points[a.index].properties,b=this.options.map(d);return c&&b===d?R({},b):b}}function K(a,b,c,d,e){return{x:I(a),y:I(b),zoom:1/0,id:c,parentId:-1,numPoints:d,properties:e}}function L(a,b){const[c,d]=a.geometry.coordinates;return{x:I(O(c)),y:I(P(d)),zoom:1/0,index:b,parentId:-1}}function M(a){return{type:"Feature",id:a.id,properties:N(a),geometry:{type:"Point",coordinates:[360*(a.x-.5),Q(a.y)]}}}function N(b){const a=b.numPoints,c=a>=1e4?`${Math.round(a/1e3)}k`:a>=1e3?Math.round(a/100)/10+"k":a;return R(R({},b.properties),{cluster:!0,cluster_id:b.id,point_count:a,point_count_abbreviated:c})}function O(a){return a/360+.5}function P(c){const b=Math.sin(c*Math.PI/180),a=.5-.25*Math.log((1+b)/(1-b))/Math.PI;return a<0?0:a>1?1:a}function Q(a){return 360*Math.atan(Math.exp((180-360*a)*Math.PI/180))/Math.PI-90}function R(a,b){for(const c in b)a[c]=b[c];return a}function S(a){return a.x}function T(a){return a.y}function U(a,b,c,g){for(var d,f=g,k=c-b>>1,i=c-b,l=a[b],m=a[b+1],n=a[c],o=a[c+1],e=b+3;ef)d=e,f=h;else if(h===f){var j=Math.abs(e-k);jg&&(d-b>3&&U(a,b,d,g),a[d+2]=f,c-d>3&&U(a,d,c,g))}function V(f,g,c,d,h,i){var a=h-c,b=i-d;if(0!==a||0!==b){var e=((f-c)*a+(g-d)*b)/(a*a+b*b);e>1?(c=h,d=i):e>0&&(c+=a*e,d+=b*e)}return(a=f-c)*a+(b=g-d)*b}function W(a,c,d,e){var b={id:void 0===a?null:a,type:c,geometry:d,tags:e,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return(function(d){var b=d.geometry,c=d.type;if("Point"===c||"MultiPoint"===c||"LineString"===c)X(d,b);else if("Polygon"===c||"MultiLineString"===c)for(var a=0;a0&&(h+=k?(f*d-c*g)/2:Math.sqrt(Math.pow(c-f,2)+Math.pow(d-g,2))),f=c,g=d}var i=a.length-3;a[2]=1,U(a,0,i,j),a[i+2]=1,a.size=Math.abs(h),a.start=0,a.end=a.size}function _(b,d,e,f){for(var a=0;a1?1:a}function ca(j,m,e,d,f,n,o,p){if(d/=m,n>=(e/=m)&&o=d)return null;for(var i=[],k=0;k=e&&r=d)){var b=[];if("Point"===a||"MultiPoint"===a)da(h,b,e,d,f);else if("LineString"===a)ea(h,b,e,d,f,!1,p.lineMetrics);else if("MultiLineString"===a)ga(h,b,e,d,f,!1);else if("Polygon"===a)ga(h,b,e,d,f,!0);else if("MultiPolygon"===a)for(var g=0;g=e&&d<=f&&(c.push(b[a]),c.push(b[a+1]),c.push(b[a+2]))}}function ea(b,u,e,f,o,v,m){for(var n,g,a=fa(b),p=0===o?ia:ja,q=b.start,h=0;he&&(g=p(a,c,d,j,k,e),m&&(a.start=q+n*g)):l>f?r=e&&(g=p(a,c,d,j,k,e),t=!0),r>f&&l<=f&&(g=p(a,c,d,j,k,f),t=!0),!v&&t&&(m&&(a.end=q+n*g),u.push(a),a=fa(b)),m&&(q+=n)}var i=b.length-3;c=b[i],d=b[i+1],s=b[i+2],(l=0===o?c:d)>=e&&l<=f&&ha(a,c,d,s),i=a.length-3,v&&i>=3&&(a[i]!==a[0]||a[i+1]!==a[1])&&ha(a,a[0],a[1],a[2]),a.length&&u.push(a)}function fa(b){var a=[];return a.size=b.size,a.start=b.start,a.end=b.end,a}function ga(b,c,d,e,f,g){for(var a=0;aa.maxX&&(a.maxX=h),i>a.maxY&&(a.maxY=i)}return a}function pa(f,d,h,m){var b=d.geometry,c=d.type,e=[];if("Point"===c||"MultiPoint"===c)for(var a=0;a0&&a.size<(f?g:b))e.numPoints+=a.length/3;else{for(var d=[],c=0;cg)&&(e.numSimplified++,d.push(a[c]),d.push(a[c+1])),e.numPoints++;f&&(function(b,f){for(var e=0,a=0,c=b.length,d=c-2;a0===f)for(a=0,c=b.length;a24)throw new Error("maxZoom should be in the 0-24 range");if(a.promoteId&&a.generateId)throw new Error("promoteId and generateId cannot be used together.");var d,e,b,c,f,g,h=function(a,d){var c=[];if("FeatureCollection"===a.type)for(var b=0;b1&&console.time("creation"),a=this.tiles[u]=oa(g,c,d,b,e),this.tileCoords.push({z:c,x:d,y:b}),j)){j>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",c,d,b,a.numFeatures,a.numPoints,a.numSimplified),console.timeEnd("creation"));var v="z"+c;this.stats[v]=(this.stats[v]||0)+1,this.total++}if(a.source=g,m){if(c===e.maxZoom||c===m)continue;var w=1<1&&console.time("clipping");var n,o,p,q,k,l,i=.5*e.buffer/e.extent,r=.5-i,s=.5+i,t=1+i;n=o=p=q=null,k=ca(g,h,d-i,d+s,0,a.minX,a.maxX,e),l=ca(g,h,d+r,d+t,0,a.minX,a.maxX,e),g=null,k&&(n=ca(k,h,b-i,b+s,1,a.minY,a.maxY,e),o=ca(k,h,b+r,b+t,1,a.minY,a.maxY,e),k=null),l&&(p=ca(l,h,b-i,b+s,1,a.minY,a.maxY,e),q=ca(l,h,b+r,b+t,1,a.minY,a.maxY,e),l=null),j>1&&console.timeEnd("clipping"),f.push(n||[],c+1,2*d,2*b),f.push(o||[],c+1,2*d,2*b+1),f.push(p||[],c+1,2*d+1,2*b),f.push(q||[],c+1,2*d+1,2*b+1)}}},d.prototype.getTile=function(a,b,g){var k=this.options,l=k.extent,h=k.debug;if(a<0||a>24)return null;var j=1<1&&console.log("drilling down to z%d-%d-%d",a,b,g);for(var c,d=a,e=b,f=g;!c&&d>0;)d--,e=Math.floor(e/2),f=Math.floor(f/2),c=this.tiles[ra(d,e,f)];return c&&c.source?(h>1&&console.log("found parent tile z%d-%d-%d",d,e,f),h>1&&console.time("drilling down"),this.splitTile(c.source,d,e,f,a,b,g),h>1&&console.timeEnd("drilling down"),this.tiles[i]?ma(this.tiles[i],l):null):null};class sa extends a.VectorTileWorkerSource{constructor(b,d,e,f,a){super(b,d,e,f,function(g,b){const d=g.tileID.canonical;if(!this._geoJSONIndex)return b(null,null);const e=this._geoJSONIndex.getTile(d.z,d.x,d.y);if(!e)return b(null,null);const f=new u(e.features);let a=c(f);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),b(null,{vectorTile:f,rawData:a.buffer})}),a&&(this.loadGeoJSON=a)}loadData(b,e){const c=b&&b.request,f=c&&c.collectResourceTiming;this.loadGeoJSON(b,(i,g)=>{if(i||!g)return e(i);if("object"!=typeof g)return e(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));{p(g,!0);try{var j,k;if(b.filter){const l=a.createExpression(b.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===l.result)throw new Error(l.value.map(a=>`${a.key}: ${a.message}`).join(", "));const n=g.features.filter(a=>l.value.evaluate({zoom:0},a));g={type:"FeatureCollection",features:n}}this._geoJSONIndex=b.cluster?new J(function({superclusterOptions:b,clusterProperties:d}){if(!d||!b)return b;const f={},g={},l={accumulated:null,zoom:0},m={properties:null},h=Object.keys(d);for(const c of h){const[e,i]=d[c],j=a.createExpression(i),k=a.createExpression("string"==typeof e?[e,["accumulated"],["get",c]]:e);f[c]=j.value,g[c]=k.value}return b.map=c=>{m.properties=c;const a={};for(const b of h)a[b]=f[b].evaluate(l,m);return a},b.reduce=(b,c)=>{for(const a of(m.properties=c,h))l.accumulated=b[a],b[a]=g[a].evaluate(l,m)},b}(b)).load(g.features):(j=g,k=b.geojsonVtOptions,new d(j,k))}catch(o){return e(o)}this.loaded={};const h={};if(f){const m=a.getPerformanceMeasurement(c);m&&(h.resourceTiming={},h.resourceTiming[b.source]=JSON.parse(JSON.stringify(m)))}e(null,h)}})}reloadTile(a,b){const c=this.loaded;return c&&c[a.uid]?super.reloadTile(a,b):this.loadTile(a,b)}loadGeoJSON(b,c){if(b.request)a.getJSON(b.request,c);else{if("string"!=typeof b.data)return c(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));try{return c(null,JSON.parse(b.data))}catch(d){return c(new Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(b,a){try{a(null,this._geoJSONIndex.getClusterExpansionZoom(b.clusterId))}catch(c){a(c)}}getClusterChildren(b,a){try{a(null,this._geoJSONIndex.getChildren(b.clusterId))}catch(c){a(c)}}getClusterLeaves(a,b){try{b(null,this._geoJSONIndex.getLeaves(a.clusterId,a.limit,a.offset))}catch(c){b(c)}}}class e{constructor(b){this.self=b,this.actor=new a.Actor(b,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:sa},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(a,b)=>{if(this.workerSourceTypes[a])throw new Error(`Worker source with name "${a}" already registered.`);this.workerSourceTypes[a]=b},this.self.registerRTLTextPlugin=b=>{if(a.plugin.isParsed())throw new Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=b.applyArabicShaping,a.plugin.processBidirectionalText=b.processBidirectionalText,a.plugin.processStyledBidirectionalText=b.processStyledBidirectionalText}}clearCaches(a,c,b){delete this.layerIndexes[a],delete this.availableImages[a],delete this.workerSources[a],delete this.demWorkerSources[a],b()}checkIfReady(b,c,a){a()}setReferrer(b,a){this.referrer=a}spriteLoaded(c,e){for(const f in this.isSpriteLoaded[c]=e,this.workerSources[c]){const b=this.workerSources[c][f];for(const d in b)b[d]instanceof a.VectorTileWorkerSource&&(b[d].isSpriteLoaded=e,b[d].fire(new a.Event("isSpriteLoaded")))}}setImages(a,b,d){for(const e in this.availableImages[a]=b,this.workerSources[a]){const c=this.workerSources[a][e];for(const f in c)c[f].availableImages=b}d()}enableTerrain(c,a,b){this.terrain=a,b()}setProjection(b,c){this.projections[b]=a.getProjection(c)}setLayers(a,b,c){this.getLayerIndex(a).replace(b),c()}updateLayers(b,a,c){this.getLayerIndex(b).update(a.layers,a.removedIds),c()}loadTile(c,b,e){const d=this.enableTerrain?a.extend({enableTerrain:this.terrain},b):b;d.projection=this.projections[c]||this.defaultProjection,this.getWorkerSource(c,b.type,b.source).loadTile(d,e)}loadDEMTile(c,b,d){const e=this.enableTerrain?a.extend({buildQuadTree:this.terrain},b):b;this.getDEMWorkerSource(c,b.source).loadTile(e,d)}reloadTile(c,b,e){const d=this.enableTerrain?a.extend({enableTerrain:this.terrain},b):b;d.projection=this.projections[c]||this.defaultProjection,this.getWorkerSource(c,b.type,b.source).reloadTile(d,e)}abortTile(b,a,c){this.getWorkerSource(b,a.type,a.source).abortTile(a,c)}removeTile(b,a,c){this.getWorkerSource(b,a.type,a.source).removeTile(a,c)}removeSource(b,a,c){if(!this.workerSources[b]||!this.workerSources[b][a.type]||!this.workerSources[b][a.type][a.source])return;const d=this.workerSources[b][a.type][a.source];delete this.workerSources[b][a.type][a.source],void 0!==d.removeSource?d.removeSource(a,c):c()}loadWorkerSource(d,b,a){try{this.self.importScripts(b.url),a()}catch(c){a(c.toString())}}syncRTLPluginState(g,e,c){try{a.plugin.setState(e);const b=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&null!=b){this.self.importScripts(b);const d=a.plugin.isParsed();c(d?void 0:new Error(`RTL Text Plugin failed to import scripts from ${b}`),d)}}catch(f){c(f.toString())}}getAvailableImages(b){let a=this.availableImages[b];return a||(a=[]),a}getLayerIndex(b){let a=this.layerIndexes[b];return a||(a=this.layerIndexes[b]=new m),a}getWorkerSource(a,b,c){return this.workerSources[a]||(this.workerSources[a]={}),this.workerSources[a][b]||(this.workerSources[a][b]={}),this.workerSources[a][b][c]||(this.workerSources[a][b][c]=new this.workerSourceTypes[b]({send:(b,c,d,g,e,f)=>{this.actor.send(b,c,d,a,e,f)},scheduler:this.actor.scheduler},this.getLayerIndex(a),this.getAvailableImages(a),this.isSpriteLoaded[a])),this.workerSources[a][b][c]}getDEMWorkerSource(a,b){return this.demWorkerSources[a]||(this.demWorkerSources[a]={}),this.demWorkerSources[a][b]||(this.demWorkerSources[a][b]=new o),this.demWorkerSources[a][b]}enforceCacheSizeLimit(c,b){a.enforceCacheSizeLimit(b)}getWorkerPerformanceMetrics(b,c,a){a(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new e(self)),e}),a(["./shared"],function(a){"use strict";var l=m;function m(c){var b,a;return b=c,"undefined"!=typeof window&&"undefined"!=typeof document&& !!Array.prototype&&!!Array.prototype.every&&!!Array.prototype.filter&&!!Array.prototype.forEach&&!!Array.prototype.indexOf&&!!Array.prototype.lastIndexOf&&!!Array.prototype.map&&!!Array.prototype.some&&!!Array.prototype.reduce&&!!Array.prototype.reduceRight&&!!Array.isArray&& !!Function.prototype&&!!Function.prototype.bind&& !!Object.keys&&!!Object.create&&!!Object.getPrototypeOf&&!!Object.getOwnPropertyNames&&!!Object.isSealed&&!!Object.isFrozen&&!!Object.isExtensible&&!!Object.getOwnPropertyDescriptor&&!!Object.defineProperty&&!!Object.defineProperties&&!!Object.seal&&!!Object.freeze&&!!Object.preventExtensions&&"JSON"in window&&"parse"in JSON&&"stringify"in JSON&& !!function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var a,b,d=new Blob([""],{type:"text/javascript"}),c=URL.createObjectURL(d);try{b=new Worker(c),a=!0}catch(e){a=!1}return b&&b.terminate(),URL.revokeObjectURL(c),a}()&&"Uint8ClampedArray"in window&& !!ArrayBuffer.isView&& !!function(){var a=document.createElement("canvas");a.width=a.height=1;var b=a.getContext("2d");if(!b)return!1;var c=b.getImageData(0,0,1,1);return c&&c.width===a.width}()&&(void 0===B[a=b&&b.failIfMajorPerformanceCaveat]&&(B[a]=(function(f){var e,c,d,b,a=(e=f,c=document.createElement("canvas"),(d=Object.create(m.webGLContextAttributes)).failIfMajorPerformanceCaveat=e,c.getContext("webgl",d)||c.getContext("experimental-webgl",d));if(!a)return!1;try{b=a.createShader(a.VERTEX_SHADER)}catch(g){return!1}return!(!b||a.isContextLost())&&(a.shaderSource(b,"void main() {}"),a.compileShader(b),!0===a.getShaderParameter(b,a.COMPILE_STATUS))})(a)),!!B[a]&&!document.documentMode)}var B={};function C(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],a=d*g-f*e;return a?(b[0]=g*(a=1/a),b[1]=-e*a,b[2]=-f*a,b[3]=d*a,b):null}function D(a,b){if(Array.isArray(a)){if(!Array.isArray(b)||a.length!==b.length)return!1;for(let c=0;c{a.window.removeEventListener("click",G,!0)},0)},b.mousePos=function(a,b){const c=a.getBoundingClientRect();return H(a,c,b)},b.touchPos=function(b,c){const e=b.getBoundingClientRect(),d=[];for(let a=0;a=0?0:b.button};class J extends a.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(a){if(this.loaded!==a&&(this.loaded=a,a)){for(const{ids:b,callback:c}of this.requestors)this._notify(b,c);this.requestors=[]}}getImage(a){return this.images[a]}addImage(a,b){this._validate(a,b)&&(this.images[a]=b)}_validate(d,b){let c=!0;return this._validateStretch(b.stretchX,b.data&&b.data.width)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "stretchX" value`))),c=!1),this._validateStretch(b.stretchY,b.data&&b.data.height)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "stretchY" value`))),c=!1),this._validateContent(b.content,b)||(this.fire(new a.ErrorEvent(new Error(`Image "${d}" has invalid "content" value`))),c=!1),c}_validateStretch(b,d){if(!b)return!0;let c=0;for(const a of b){if(a[0]{this.ready=!0})}broadcast(c,d,b){a.asyncAll(this.actors,(a,b)=>{a.send(c,d,b)},b=b||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(a=>{a.remove()}),this.actors=[],this.workerPool.release(this.id)}}function V(b,c,d){return c*(a.EXTENT/(b.tileSize*Math.pow(2,d-b.tileID.overscaledZ)))}n.Actor=a.Actor;class W{constructor(b,c,d){this.context=b;const a=b.gl;this.buffer=a.createBuffer(),this.dynamicDraw=Boolean(d),this.context.unbindVAO(),b.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(b){const a=this.context.gl;this.context.unbindVAO(),this.bind(),a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,0,b.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const X={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Y{constructor(c,b,d,e){this.length=b.length,this.attributes=d,this.itemSize=b.bytesPerElement,this.dynamicDraw=e,this.context=c;const a=c.gl;this.buffer=a.createBuffer(),c.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,b.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete b.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(b){const a=this.context.gl;this.bind(),a.bufferSubData(a.ARRAY_BUFFER,0,b.arrayBuffer)}enableAttributes(c,d){for(let a=0;ad.pointCoordinate3D(a)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(b,c){let d,e;if(b instanceof a.pointGeometry||"number"==typeof b[0]){const h=a.pointGeometry.convert(b);d=[a.pointGeometry.convert(b)],e=c.isPointAboveHorizon(h)}else{const f=a.pointGeometry.convert(b[0]),g=a.pointGeometry.convert(b[1]);d=[f,g],e=a.polygonizeBounds(f,g).every(a=>c.isPointAboveHorizon(a))}return new _(d,c.getCameraPoint(),e,c)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(b){return a.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],b)}bufferedCameraGeometry(e){const d=this.screenBounds[0],b=1===this.screenBounds.length?this.screenBounds[0].add(new a.pointGeometry(1,1)):this.screenBounds[1],c=a.polygonizeBounds(d,b,0,!1);return this.cameraPoint.y>b.y&&(this.cameraPoint.x>d.x&&this.cameraPoint.x=b.x?c[2]=this.cameraPoint:this.cameraPoint.x<=d.x&&(c[3]=this.cameraPoint)),a.bufferConvexPolygon(c,e)}containsTile(c,d,h){var b;const f=c.queryPadding+1,i=c.tileID.wrap,e=h?this._bufferedCameraMercator(f,d).map(b=>a.getTilePoint(c.tileTransform,b,i)):this._bufferedScreenMercator(f,d).map(b=>a.getTilePoint(c.tileTransform,b,i)),g=this.screenGeometryMercator.map(b=>a.getTileVec3(c.tileTransform,b,i)),j=g.map(b=>new a.pointGeometry(b[0],b[1])),k=d.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),n=a.getTileVec3(c.tileTransform,k,i),l=g.map(c=>{const b=a.sub(c,c,n);return a.normalize(b,b),new a.Ray(n,b)}),m=V(c,1,d.zoom);if(a.polygonIntersectsBox(e,0,0,a.EXTENT,a.EXTENT))return{queryGeometry:this,tilespaceGeometry:j,tilespaceRays:l,bufferedTilespaceGeometry:e,bufferedTilespaceBounds:((b=a.getBounds(e)).min.x=a.clamp(b.min.x,0,a.EXTENT),b.min.y=a.clamp(b.min.y,0,a.EXTENT),b.max.x=a.clamp(b.max.x,0,a.EXTENT),b.max.y=a.clamp(b.max.y,0,a.EXTENT),b),tile:c,tileID:c.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(b,d){const a=aa(b);if(this._screenRaycastCache[a])return this._screenRaycastCache[a];{const c=this.bufferedScreenGeometry(b).map(a=>d.pointCoordinate3D(a));return this._screenRaycastCache[a]=c,c}}_bufferedCameraMercator(b,d){const a=aa(b);if(this._cameraRaycastCache[a])return this._cameraRaycastCache[a];{const c=this.bufferedCameraGeometry(b).map(a=>d.pointCoordinate3D(a));return this._cameraRaycastCache[a]=c,c}}}function aa(a){return 100*a|0}function ba(b,c,e){const d=function(g,f){if(g)return e(g);if(f){const d=a.pick(a.extend(f,b),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);f.vector_layers&&(d.vectorLayers=f.vector_layers,d.vectorLayerIds=d.vectorLayers.map(a=>a.id)),d.tiles=c.canonicalizeTileset(d,b.url),e(null,d)}};return b.url?a.getJSON(c.transformRequest(c.normalizeSourceURL(b.url),a.ResourceType.Source),d):a.exported.frame(()=>d(null,b))}class ca{constructor(b,c,d){this.bounds=a.LngLatBounds.convert(this.validateBounds(b)),this.minzoom=c||0,this.maxzoom=d||24}validateBounds(a){return Array.isArray(a)&&4===a.length?[Math.max(-180,a[0]),Math.max(-90,a[1]),Math.min(180,a[2]),Math.min(90,a[3])]:[-180,-90,180,90]}contains(b){const c=Math.pow(2,b.z),d=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*c),e=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*c),f=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*c),g=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*c);return b.x>=d&&b.x=e&&b.y{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):b&&(a.extend(this,b),b.bounds&&(this.tileBounds=new ca(b.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(b.tiles),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(a){this.map=a,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(b,e){const c=a.exported.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),c,this.tileSize);b.request=a.getImage(this.map._requestManager.transformRequest(d,a.ResourceType.Tile),(g,f,h,i)=>{if(delete b.request,b.aborted)b.state="unloaded",e(null);else if(g)b.state="errored",e(g);else if(f){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const c=this.map.painter.context,d=c.gl;b.texture=this.map.painter.getTileTexture(f.width),b.texture?b.texture.update(f,{useMipmap:!0}):(b.texture=new a.Texture(c,f,d.RGBA,{useMipmap:!0}),b.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&d.texParameterf(d.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),b.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),e(null)}})}abortTile(a,b){a.request&&(a.request.cancel(),delete a.request),b()}unloadTile(a,b){a.texture&&this.map.painter.saveTileTexture(a.texture),b()}hasTransition(){return!1}}let da;function ea(e,f,g,h,i,j,k,l){const b=[e,g,i,f,h,j,1,1,1],c=[k,l,1],d=a.adjoint([],b),[m,n,o]=a.transformMat3(c,c,a.transpose(d,d));return a.multiply(b,[m,0,0,0,n,0,0,0,o],b)}class s extends a.Evented{constructor(b,a,c,d){super(),this.id=b,this.dispatcher=c,this.coordinates=a.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=a}load(b,c){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this.url=this.options.url,a.getImage(this.map._requestManager.transformRequest(this.url,a.ResourceType.Image),(d,e)=>{this._loaded=!0,d?this.fire(new a.ErrorEvent(d)):e&&(this.image=a.exported.getImageData(e),this.width=this.image.width,this.height=this.image.height,b&&(this.coordinates=b),c&&c(),this._finishLoading())})}loaded(){return this._loaded}updateImage(a){return this.image&&a.url&&(this.options.url=a.url,this.load(a.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(a){this.map=a,this.load()}setCoordinates(b){this.coordinates=b,delete this._boundsArray;const c=b.map(a.MercatorCoordinate.fromLngLat);return this.tileID=(function(i){let b=1/0,c=1/0,d=-1/0,e=-1/0;for(const f of i)b=Math.min(b,f.x),c=Math.min(c,f.y),d=Math.max(d,f.x),e=Math.max(e,f.y);const g=Math.max(0,Math.floor(-Math.log(Math.max(d-b,e-c))/Math.LN2)),h=Math.pow(2,g);return new a.CanonicalTileID(g,Math.floor((b+d)/2*h),Math.floor((c+e)/2*h))})(c),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const f=a.tileTransform(this.tileID,this.map.transform.projection),[b,c,d,e]=this.coordinates.map(b=>{const c=f.projection.project(b[0],b[1]);return a.getTilePoint(f,c)._round()});return this.perspectiveTransform=(function(c,d,f,g,h,i,j,k,l,m){const e=ea(0,0,c,0,0,d,c,d),b=ea(f,g,h,i,j,k,l,m);return a.multiply(b,a.adjoint(e,e),b),[b[6]/b[8]*c/a.EXTENT,b[7]/b[8]*d/a.EXTENT]})(this.width,this.height,b.x,b.y,c.x,c.y,e.x,e.y,d.x,d.y),this._boundsArray=new a.StructArrayLayout4i8,this._boundsArray.emplaceBack(b.x,b.y,0,0),this._boundsArray.emplaceBack(c.x,c.y,a.EXTENT,0),this._boundsArray.emplaceBack(e.x,e.y,0,a.EXTENT),this._boundsArray.emplaceBack(d.x,d.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const b=this.map.painter.context,c=b.gl;for(const e in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=b.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new a.Texture(b,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE)),this.tiles){const d=this.tiles[e];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}loadTile(a,b){this.tileID&&this.tileID.equals(a.tileID.canonical)?(this.tiles[String(a.tileID.wrap)]=a,a.buckets={},b(null)):(a.state="errored",b(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const fa={vector:class extends a.Evented{constructor(c,b,d,e){if(super(),this.id=c,this.dispatcher=d,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.extend(this,a.pick(b,["url","scheme","tileSize","promoteId"])),this._options=a.extend({type:"vector"},b),this._collectResourceTiming=b.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(e),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ba(this._options,this.map._requestManager,(c,b)=>{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):b&&(a.extend(this,b),b.bounds&&(this.tileBounds=new ca(b.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(b.tiles,this.map._requestManager._customAccessToken),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}onAdd(a){this.map=a,this.load()}setSourceProperty(a){this._tileJSONRequest&&this._tileJSONRequest.cancel(),a();const b=this.map.style._getSourceCaches(this.id);for(const c of b)c.clearTiles();this.load()}setTiles(a){return this.setSourceProperty(()=>{this._options.tiles=a}),this}setUrl(a){return this.setSourceProperty(()=>{this.url=a,this._options.url=a}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}loadTile(b,e){const d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme)),c={request:this.map._requestManager.transformRequest(d,a.ResourceType.Tile),data:void 0,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,tileSize:this.tileSize*b.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:b.isSymbolTile};if(c.request.collectResourceTiming=this._collectResourceTiming,b.actor&&"expired"!==b.state)"loading"===b.state?b.reloadCallback=e:b.request=b.actor.send("reloadTile",c,g.bind(this));else if(b.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready)b.request=b.actor.send("loadTile",c,g.bind(this),void 0,!0);else{const f=a.loadVectorTile.call({deduped:this._deduped},c,(d,a)=>{d||!a?g.call(this,d):(c.data={cacheControl:a.cacheControl,expires:a.expires,rawData:a.rawData.slice(0)},b.actor&&b.actor.send("loadTile",c,g.bind(this),void 0,!0))},!0);b.request={cancel:f}}function g(d,c){return delete b.request,b.aborted?e(null):d&&404!==d.status?e(d):(c&&c.resourceTiming&&(b.resourceTiming=c.resourceTiming),this.map._refreshExpiredTiles&&c&&b.setExpiryData(c),b.loadVectorData(c,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),e(null),void(b.reloadCallback&&(this.loadTile(b,b.reloadCallback),b.reloadCallback=null)))}}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.actor&&a.actor.send("abortTile",{uid:a.uid,type:this.type,source:this.id})}unloadTile(a){a.unloadVectorData(),a.actor&&a.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:r,"raster-dem":class extends r{constructor(c,b,d,e){super(c,b,d,e),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},b),this.encoding=b.encoding||"mapbox"}loadTile(b,d){const c=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function e(a,c){a&&(b.state="errored",d(a)),c&&(b.dem=c,b.dem.onDeserialize(),b.needsHillshadePrepare=!0,b.needsDEMTextureUpload=!0,b.state="loaded",d(null))}b.request=a.getImage(this.map._requestManager.transformRequest(c,a.ResourceType.Tile),(function(g,c,h,i){if(delete b.request,b.aborted)b.state="unloaded",d(null);else if(g)b.state="errored",d(g);else if(c){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const j=a.window.ImageBitmap&&c instanceof a.window.ImageBitmap&&(null==da&&(da=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.window.createImageBitmap),da),f=1-(c.width-a.prevPowerOfTwo(c.width))/2;f<1||b.neighboringTiles||(b.neighboringTiles=this._getNeighboringTiles(b.tileID));const k=j?c:a.exported.getImageData(c,f),l={uid:b.uid,coord:b.tileID,source:this.id,rawImageData:k,encoding:this.encoding,padding:f};b.actor&&"expired"!==b.state||(b.actor=this.dispatcher.getActor(),b.actor.send("loadDEMTile",l,e.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(c){const b=c.canonical,e=Math.pow(2,b.z),f=(b.x-1+e)%e,g=0===b.x?c.wrap-1:c.wrap,h=(b.x+1+e)%e,i=b.x+1===e?c.wrap+1:c.wrap,d={};return d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y).key]={backfilled:!1},b.y>0&&(d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y-1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,c.wrap,b.z,b.x,b.y-1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y-1).key]={backfilled:!1}),b.y+1{if(this._loaded=!0,this._pendingLoad=null,c)this.fire(new a.ErrorEvent(c));else{const d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&b&&b.resourceTiming&&b.resourceTiming[this.id]&&(d.resourceTiming=b.resourceTiming[this.id]),this.fire(new a.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(b,d){const c=b.actor?"reloadTile":"loadTile";b.actor=this.actor,b.request=this.actor.send(c,{type:this.type,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(a,e)=>(delete b.request,b.unloadVectorData(),b.aborted?d(null):a?d(a):(b.loadVectorData(e,this.map.painter,"reloadTile"===c),d(null))),void 0,"loadTile"===c)}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.aborted=!0}unloadTile(a){a.unloadVectorData(),this.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return a.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends s{constructor(b,a,c,d){super(b,a,c,d),this.roundZoom=!0,this.type="video",this.options=a}load(){this._loaded=!1;const b=this.options;for(const c of(this.urls=[],b.urls))this.urls.push(this.map._requestManager.transformRequest(c,a.ResourceType.Source).url);a.getVideo(this.urls,(b,c)=>{this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(this.video=c,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(c){if(this.video){const b=this.video.seekable;cb.end(0)?this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${b.start(0)} and ${b.end(0)}-second mark.`))):this.video.currentTime=c}}getVideo(){return this.video}onAdd(a){this.map||(this.map=a,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const c=this.map.painter.context,b=c.gl;for(const e in this.texture?this.video.paused||(this.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE),b.texSubImage2D(b.TEXTURE_2D,0,0,0,b.RGBA,b.UNSIGNED_BYTE,this.video)):(this.texture=new a.Texture(c,this.video,b.RGBA),this.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const d=this.tiles[e];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:s,canvas:class extends s{constructor(c,b,d,e){super(c,b,d,e),b.coordinates?Array.isArray(b.coordinates)&&4===b.coordinates.length&&!b.coordinates.some(a=>!Array.isArray(a)||2!==a.length||a.some(a=>"number"!=typeof a))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,"\"coordinates\" property must be an array of 4 longitude/latitude array pairs"))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,"missing required property \"coordinates\""))),b.animate&&"boolean"!=typeof b.animate&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,"optional \"animate\" property must be a boolean value"))),b.canvas?"string"==typeof b.canvas||b.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,"\"canvas\" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance"))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,"missing required property \"canvas\""))),this.options=b,this.animate=void 0===b.animate||b.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof a.window.HTMLCanvasElement?this.options.canvas:a.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(a){this.map=a,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let b=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,b=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,b=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const c=this.map.painter.context,e=c.gl;for(const f in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(b||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(c,this.canvas,e.RGBA,{premultiply:!0}),this.tiles){const d=this.tiles[f];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const a of[this.canvas.width,this.canvas.height])if(isNaN(a)||a<=0)return!0;return!1}}},ga=function(c,d,e,f){const b=new fa[d.type](c,d,e,f);if(b.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${b.id}`);return a.bindAll(["load","abort","unload","serialize","prepare"],b),b};function ha(c,d){const b=a.identity([]);return a.scale(b,b,[.5*c.width,-(.5*c.height),1]),a.translate(b,b,[1,-1,0]),a.multiply$1(b,b,c.calculateProjMatrix(d.toUnwrapped()))}function ia(b,g,h,i,j,k,l,d=!1){const e=b.tilesIn(i,l,d);e.sort(ka);const f=[];for(const a of e)f.push({wrappedTileID:a.tile.tileID.wrapped().key,queryResults:a.tile.queryRenderedFeatures(g,h,b._state,a,j,k,ha(b.transform,a.tile.tileID),d)});const c=function(j){const b={},d={};for(const e of j){const f=e.queryResults,g=e.wrappedTileID,h=d[g]=d[g]||{};for(const a in f){const k=f[a],i=h[a]=h[a]||{},l=b[a]=b[a]||[];for(const c of k)i[c.featureIndex]||(i[c.featureIndex]=!0,l.push(c))}}return b}(f);for(const m in c)c[m].forEach(c=>{const a=c.feature,d=b.getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=d});return c}function ja(g,h){const b=g.getRenderableIds().map(a=>g.getTileByID(a)),c=[],d={};for(let a=0;a{a.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[ma]}numActive(){return Object.keys(this.active).length}}let na;function oa(){return na||(na=new e),na}function pa(c,e){const d={};for(const b in c)"ref"!==b&&(d[b]=c[b]);return a.refProperties.forEach(a=>{a in e&&(d[a]=e[a])}),d}function qa(a){a=a.slice();const d=Object.create(null);for(let c=0;c0?(e-g)/h:0;return this.points[f].mult(1-i).add(this.points[b].mult(i))}}class za{constructor(a,b,c){const e=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(a/c),this.yCellCount=Math.ceil(b/c);for(let d=0;dthis.width||i<0||g>this.height)return!d&&[];const a=[];if(f<=0&&g<=0&&this.width<=h&&this.height<=i){if(d)return!0;for(let b=0;b0:a}_queryCircle(b,c,a,d,j){const f=b-a,g=b+a,h=c-a,i=c+a;if(g<0||f>this.width||i<0||h>this.height)return!d&&[];const e=[];return this._forEachCell(f,h,g,i,this._queryCellCircle,e,{hitTest:d,circle:{x:b,y:c,radius:a},seenUids:{box:{},circle:{}}},j),d?e.length>0:e}query(a,b,c,d,e){return this._query(a,b,c,d,!1,e)}hitTest(a,b,c,d,e){return this._query(a,b,c,d,!0,e)}hitTestCircle(a,b,c,d){return this._queryCircle(a,b,c,!0,d)}_queryCell(l,m,n,o,p,g,k,h){const i=k.seenUids,q=this.boxCells[p];if(null!==q){const a=this.bboxes;for(const e of q)if(!i.box[e]){i.box[e]=!0;const b=4*e;if(l<=a[b+2]&&m<=a[b+3]&&n>=a[b+0]&&o>=a[b+1]&&(!h||h(this.boxKeys[e]))){if(k.hitTest)return g.push(!0),!0;g.push({key:this.boxKeys[e],x1:a[b],y1:a[b+1],x2:a[b+2],y2:a[b+3]})}}}const r=this.circleCells[p];if(null!==r){const c=this.circles;for(const f of r)if(!i.circle[f]){i.circle[f]=!0;const d=3*f;if(this._circleAndRectCollide(c[d],c[d+1],c[d+2],l,m,n,o)&&(!h||h(this.circleKeys[f]))){if(k.hitTest)return g.push(!0),!0;{const s=c[d],t=c[d+1],j=c[d+2];g.push({key:this.circleKeys[f],x1:s-j,y1:t-j,x2:s+j,y2:t+j})}}}}}_queryCellCircle(o,p,q,r,j,k,l,b){const a=l.circle,c=l.seenUids,m=this.boxCells[j];if(null!==m){const d=this.bboxes;for(const e of m)if(!c.box[e]){c.box[e]=!0;const f=4*e;if(this._circleAndRectCollide(a.x,a.y,a.radius,d[f+0],d[f+1],d[f+2],d[f+3])&&(!b||b(this.boxKeys[e])))return k.push(!0),!0}}const n=this.circleCells[j];if(null!==n){const h=this.circles;for(const g of n)if(!c.circle[g]){c.circle[g]=!0;const i=3*g;if(this._circlesCollide(h[i],h[i+1],h[i+2],a.x,a.y,a.radius)&&(!b||b(this.circleKeys[g])))return k.push(!0),!0}}}_forEachCell(c,d,e,f,g,h,i,j){const k=this._convertToXCellCoord(c),l=this._convertToYCellCoord(d),m=this._convertToXCellCoord(e),n=this._convertToYCellCoord(f);for(let a=k;a<=m;a++)for(let b=l;b<=n;b++)if(g.call(this,c,d,e,f,this.xCellCount*b+a,h,i,j))return}_convertToXCellCoord(a){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(a*this.xScale)))}_convertToYCellCoord(a){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(a*this.yScale)))}_circlesCollide(d,e,f,g,h,i){const a=g-d,b=h-e,c=f+i;return c*c>a*a+b*b}_circleAndRectCollide(j,k,a,f,g,l,m){const b=(l-f)/2,d=Math.abs(j-(f+b));if(d>b+a)return!1;const c=(m-g)/2,e=Math.abs(k-(g+c));if(e>c+a)return!1;if(d<=b||e<=c)return!0;const h=d-b,i=e-c;return h*h+i*i<=a*a}}const Aa=Math.tan(85*Math.PI/180);function Ba(e,f,g,h,c,i){let b=a.create();if(g){if("globe"===c.projection.name)b=a.calculateGlobeMatrix(c,c.worldSize/c._projectionScaler,[0,0]),a.multiply$1(b,b,a.globeDenormalizeECEF(a.globeTileBounds(f)));else{const d=C([],i);b[0]=d[0],b[1]=d[1],b[4]=d[2],b[5]=d[3]}h||a.rotateZ(b,b,c.angle)}else a.multiply$1(b,c.labelPlaneMatrix,e);return b}function Ca(g,j,h,i,f,b){if(h){if("globe"===f.projection.name){const c=Ba(g,j,h,i,f,b);return a.invert(c,c),a.multiply$1(c,g,c),c}{const d=a.clone(g),e=a.identity([]);return e[0]=b[0],e[1]=b[1],e[4]=b[2],e[5]=b[3],a.multiply$1(d,d,e),i||a.rotateZ(d,d,-f.angle),d}}return f.glCoordMatrix}function Da(d,e,f=0){const b=[d.x,d.y,f,1];f?a.transformMat4$1(b,b,e):Pa(b,b,e);const c=b[3];return{point:new a.pointGeometry(b[0]/c,b[1]/c),signedDistanceFromCamera:c}}function Ea(a,b){return Math.min(.5+a/b*.5,1.5)}function Fa(a,b){const c=a[0]/a[3],d=a[1]/a[3];return c>= -b[0]&&c<=b[0]&&d>= -b[1]&&d<=b[1]}function Ga(c,m,e,i,n,x,y,z,o,p){const q=e.transform,A=i?c.textSizeData:c.iconSizeData,G=a.evaluateSizeForZoom(A,e.transform.zoom),H=[256/e.width*2+1,256/e.height*2+1],d=i?c.text.dynamicLayoutVertexArray:c.icon.dynamicLayoutVertexArray;d.clear();const B=c.lineVertexArray,r=i?c.text.placedSymbolArray:c.icon.placedSymbolArray,C=e.transform.width/e.transform.height;let f=!1;for(let g=0;gMath.abs(c.x-b.x)*e?{useVertical:!0}:d.writingMode===a.WritingMode.vertical?b.yAa})(b,c,e)?1===d.flipState?{needsFlipping:!0}:null:b.x>c.x?{needsFlipping:!0}:null}function Ja(b,E,c,v,m,n,w,o,d,F,p,e,q,x,r,i,j){const f=E/24,s=b.lineOffsetX*f,t=b.lineOffsetY*f;let g;if(b.numGlyphs>1){const G=b.glyphStartIndex+b.numGlyphs,H=b.lineStartIndex,I=b.lineStartIndex+b.lineLength,h=Ha(f,o,s,t,c,p,e,b,d,n,q,r,!1,i,j);if(!h)return{notEnoughRoom:!0};const J=Da(h.first.point,w).point,K=Da(h.last.point,w).point;if(v&&!c){const k=Ia(b,J,K,x);if(b.flipState=k&&k.needsFlipping?1:2,k)return k}g=[h.first];for(let u=b.glyphStartIndex+1;u0?B.point:La(e,A,y,1,m,void 0,i,j.canonical),x);if(b.flipState=l&&l.needsFlipping?1:2,l)return l}const C=Ma(f*o.getoffsetX(b.glyphStartIndex),s,t,c,p,e,b.segment,b.lineStartIndex,b.lineStartIndex+b.lineLength,d,n,q,r,!1,!1,i,j);if(!C)return{notEnoughRoom:!0};g=[C]}for(const D of g)a.addDynamicAttributes(F,D.point,D.angle);return{}}function Ka(c,g,e,h,f){const b=h.projectTilePoint(c.x,c.y,g);if(!f)return Da(b,e,b.z);const d=f(c);return Da(new a.pointGeometry(b.x+d[0],b.y+d[1]),e,b.z+d[2])}function La(a,d,b,e,f,g,h,i){const j=Ka(a.add(a.sub(d)._unit()),i,f,h,g).point,c=b.sub(j);return b.add(c._mult(e/c.mag()))}function Ma(p,q,r,s,t,D,u,k,E,f,F,j,v,w,G,H,I){const x=s?p-q:p+q;let h=x>0?1:-1,l=0;s&&(h*=-1,l=Math.PI),h<0&&(l+=Math.PI);let b=h>0?k+u:k+u+1,c=t,e=t,m=0,i=0;const y=Math.abs(x),n=[],g=[];let d=D;const J=()=>{const c=b-h;return 0===m?D:new a.pointGeometry(f.getx(c),f.gety(c))},z=()=>La(J(),d,e,y-m+1,F,v,H,I.canonical);for(;m+i<=y;){if((b+=h)=E)return null;if(e=c,n.push(c),w&&g.push(d||J()),void 0===(c=j[b])){d=new a.pointGeometry(f.getx(b),f.gety(b));const A=Ka(d,I.canonical,F,H,v);c=A.signedDistanceFromCamera>0?j[b]=A.point:z()}else d=null;m+=i,i=e.dist(c)}G&&v&&(d=d||new a.pointGeometry(f.getx(b),f.gety(b)),j[b]=c=void 0===j[b]?c:z(),i=e.dist(c));const B=(y-m)/i,C=c.sub(e),o=C.mult(B)._add(e);r&&o._add(C._unit()._perp()._mult(r*h));const K=l+Math.atan2(c.y-e.y,c.x-e.x);return n.push(o),w&&(d=d||new a.pointGeometry(f.getx(b),f.gety(b)),g.push(function(c,d,b){const e=1-b;return new a.pointGeometry(c.x*e+d.x*b,c.y*e+d.y*b)}(g.length>0?g[g.length-1]:d,d,B))),{point:o,angle:K,path:n,tilePath:g}}const Na=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Oa(d,a){for(let b=0;ba.sortKey-b.sortKey));this._currentPartIndex[0,0,0],I=new a.pointGeometry(f.tileAnchorX,f.tileAnchorY),r=this.transform.projection.projectTilePoint(f.tileAnchorX,f.tileAnchorY,l.canonical),s=H(I),g=[r.x+s[0],r.y+s[1],r.z+s[2]],t=this.projectAndGetPerspectiveRatio(V,g[0],g[1],g[2],l),{perspectiveRatio:u}=t,v=(q?D/u:D*u)/a.ONE_EM,_=Da(new a.pointGeometry(g[0],g[1]),E,g[2]).point,w=t.signedDistanceFromCamera>0?Ha(v,U,f.lineOffsetX*v,f.lineOffsetY*v,!1,_,I,f,T,E,{},k&&!q?H:null,q&&!!k,this.transform.projection,l):null;let m=!1,x=!1,y=!0;if(w&&!t.aboveHorizon){const c=.5*Y*u+Z,h=new a.pointGeometry(-100,-100),i=new a.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),n=new ya,J=w.first,K=w.last;let b=[];for(let z=J.path.length-1;z>=1;z--)b.push(J.path[z]);for(let A=1;A{const c=H(aDa(a,W));b=L.some(a=>a.signedDistanceFromCamera<=0)?[]:L.map(a=>a.point)}let M=[];if(b.length>0){const d=b[0].clone(),e=b[0].clone();for(let j=1;j=h.x&&e.x<=i.x&&d.y>=h.y&&e.y<=i.y?[b]:e.xi.x||e.yi.y?[]:a.clipLine([b],h.x,h.y,i.x,i.y)}for(const ba of M){n.reset(ba,.25*c);let B=0;B=n.length<=.5*c?1:Math.ceil(n.paddedLength/aa)+1;for(let C=0;C0){a.transformMat4$1(b,b,d);let i=!1;this.fogState&&g&&(i=(function(d,e,f,g,h,b){const i=b.calculateFogTileMatrix(h),c=[e,f,g];return a.transformMat4(c,c,i),Q(d,c,b.pitch,b._fov)})(this.fogState,e,f,c||0,g.toUnwrapped(),this.transform)>.9),h=b[2]>b[3]||i}else Pa(b,b,d);return{point:new a.pointGeometry((b[0]/b[3]+1)/2*this.transform.width+100,(-b[1]/b[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/b[3]*.5,1.5),signedDistanceFromCamera:b[3],aboveHorizon:h}}isOffscreen(a,b,c,d){return c<100||a>=this.screenRightBoundary||d<100||b>this.screenBottomBoundary}isInsideGrid(a,b,c,d){return c>=0&&a=0&&ba.collisionGroupID===b}}return this.collisionGroups[a]}}(e),this.collisionCircleArrays={},this.prevPlacement=b,b&&(b.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(h,d,b,q){const c=b.getBucket(d),i=b.latestFeatureIndex;if(!c||!i||d.id!==c.layerIds[0])return;const e=c.layers[0].layout,r=b.collisionBoxArray,s=Math.pow(2,this.transform.zoom-b.tileID.overscaledZ),t=b.tileSize/a.EXTENT,j=b.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(j),g="map"===e.get("text-pitch-alignment"),k="map"===e.get("text-rotation-alignment");d.compileFilter();const l=d.dynamicFilter(),u=d.dynamicFilterNeedsFeature(),m=this.transform.calculatePixelsToTileUnitsMatrix(b),v=Ba(f,b.tileID.canonical,g,k,this.transform,m);let n=null;if(g){const w=Ca(f,b.tileID.canonical,g,k,this.transform,m);n=a.multiply$1([],this.transform.labelPlaneMatrix,w)}let o=null;l&&b.latestFeatureIndex&&(o={unwrappedTileID:j,dynamicFilter:l,dynamicFilterNeedsFeature:u,featureIndex:b.latestFeatureIndex}),this.retainedQueryData[c.bucketInstanceId]=new Ua(c.bucketInstanceId,i,c.sourceLayerIndex,c.index,b.tileID);const p={bucket:c,layout:e,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:n,clippingData:o,scale:s,textPixelRatio:t,holdingForFade:b.holdingForFade(),collisionBoxArray:r,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(c.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(c.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(q)for(const x of c.sortKeyRanges){const{sortKey:y,symbolInstanceStart:z,symbolInstanceEnd:A}=x;h.push({sortKey:y,symbolInstanceStart:z,symbolInstanceEnd:A,parameters:p})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:p})}attemptAnchorPlacement(d,s,g,h,e,i,j,k,l,m,n,a,t,c,f,o,v,u){const p=[a.textOffset0,a.textOffset1],b=Va(d,g,h,p,e),q=this.collisionIndex.placeCollisionBox(e,s,Wa(b.x,b.y,i,j,this.transform.angle),n,k,l,m.predicate);if((!o||0!==this.collisionIndex.placeCollisionBox(c.getSymbolInstanceIconSize(u,this.transform.zoom,t),o,Wa(b.x,b.y,i,j,this.transform.angle),n,k,l,m.predicate).box.length)&&q.box.length>0){let r;return this.prevPlacement&&this.prevPlacement.variableOffsets[a.crossTileID]&&this.prevPlacement.placements[a.crossTileID]&&this.prevPlacement.placements[a.crossTileID].text&&(r=this.prevPlacement.variableOffsets[a.crossTileID].anchor),this.variableOffsets[a.crossTileID]={textOffset:p,width:g,height:h,anchor:d,textScale:e,prevAnchor:r},this.markUsedJustification(c,d,a,f),c.allowVerticalPlacement&&(this.markUsedOrientation(c,f,a),this.placedOrientations[a.crossTileID]=f),{shift:b,placedGlyphBoxes:q}}}placeLayerBucketPart(e,t,i,o){const{bucket:b,layout:c,posMatrix:p,textLabelPlaneMatrix:u,labelToScreenMatrix:v,clippingData:w,textPixelRatio:x,holdingForFade:y,collisionBoxArray:f,partiallyEvaluatedTextSize:z,partiallyEvaluatedIconSize:A,collisionGroup:B}=e.parameters,q=c.get("text-optional"),r=c.get("icon-optional"),j=c.get("text-allow-overlap"),k=c.get("icon-allow-overlap"),C="map"===c.get("text-rotation-alignment"),D="map"===c.get("text-pitch-alignment"),E="none"!==c.get("icon-text-fit"),s="viewport-y"===c.get("symbol-z-order"),F=j&&(k||!b.hasIconData()||r),G=k&&(j||!b.hasTextData()||q);!b.collisionArrays&&f&&b.deserializeCollisionBoxes(f),i&&o&&b.updateCollisionDebugBuffers(this.transform.zoom,f);const l=(d,ca,f)=>{if(w){const $={zoom:this.transform.zoom,pitch:this.transform.pitch};let N=null;if(w.dynamicFilterNeedsFeature){const O=this.retainedQueryData[b.bucketInstanceId];N=w.featureIndex.loadFeature({featureIndex:d.featureIndex,bucketIndex:O.bucketIndex,sourceLayerIndex:O.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,w.dynamicFilter)($,N,this.retainedQueryData[b.bucketInstanceId].tileID.canonical,new a.pointGeometry(d.tileAnchorX,d.tileAnchorY),this.transform.calculateDistanceTileData(w.unwrappedTileID)))return this.placements[d.crossTileID]=new Sa(!1,!1,!1,!0),void(t[d.crossTileID]=!0)}if(t[d.crossTileID])return;if(y)return void(this.placements[d.crossTileID]=new Sa(!1,!1,!1));let e=!1,l=!1,n=!0,da=null,h={box:null,offscreen:null},s={box:null,offscreen:null},m=null,g=null,H=null,J=0,K=0,P=0;f.textFeatureIndex?J=f.textFeatureIndex:d.useRuntimeCollisionCircles&&(J=d.featureIndex),f.verticalTextFeatureIndex&&(K=f.verticalTextFeatureIndex);const _=a=>{a.tileID=this.retainedQueryData[b.bucketInstanceId].tileID,(this.transform.elevation||a.elevation)&&(a.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[b.bucketInstanceId].tileID,a.tileAnchorX,a.tileAnchorY):0)},Q=f.textBox;if(Q){_(Q);const R=f=>{let c=a.WritingMode.horizontal;if(b.allowVerticalPlacement&&!f&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[d.crossTileID];e&&(this.placedOrientations[d.crossTileID]=e,c=e,this.markUsedOrientation(b,c,d))}return c},S=(c,e)=>{if(b.allowVerticalPlacement&&d.numVerticalGlyphVertices>0&&f.verticalTextBox){for(const g of b.writingModes)if(g===a.WritingMode.vertical?s=h=e():h=c(),h&&h.box&&h.box.length)break}else h=c()};if(c.get("text-variable-anchor")){let L=c.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[d.crossTileID]){const T=this.prevPlacement.variableOffsets[d.crossTileID];L.indexOf(T.anchor)>0&&(L=L.filter(a=>a!==T.anchor)).unshift(T.anchor)}const ea=(a,l,m)=>{const g=b.getSymbolInstanceTextSize(z,d,this.transform.zoom,ca),n=(a.x2-a.x1)*g+2*a.padding,o=(a.y2-a.y1)*g+2*a.padding,h=E&&!k?l:null;h&&_(h);let c={box:[],offscreen:!1};const q=j?2*L.length:L.length;for(let f=0;f=L.length,d,ca,b,m,h,z,A);if(i&&(c=i.placedGlyphBoxes)&&c.box&&c.box.length){e=!0,da=i.shift;break}}return c};S(()=>ea(Q,f.iconBox,a.WritingMode.horizontal),()=>{const c=f.verticalTextBox;return c&&_(c),b.allowVerticalPlacement&&!(h&&h.box&&h.box.length)&&d.numVerticalGlyphVertices>0&&c?ea(c,f.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null}}),h&&(e=h.box,n=h.offscreen);const aa=R(h&&h.box);if(!e&&this.prevPlacement){const M=this.prevPlacement.variableOffsets[d.crossTileID];M&&(this.variableOffsets[d.crossTileID]=M,this.markUsedJustification(b,M.anchor,d,aa))}}else{const fa=(f,e)=>{const g=b.getSymbolInstanceTextSize(z,d,this.transform.zoom,ca),c=this.collisionIndex.placeCollisionBox(g,f,new a.pointGeometry(0,0),j,x,p,B.predicate);return c&&c.box&&c.box.length&&(this.markUsedOrientation(b,e,d),this.placedOrientations[d.crossTileID]=e),c};S(()=>fa(Q,a.WritingMode.horizontal),()=>{const c=f.verticalTextBox;return b.allowVerticalPlacement&&d.numVerticalGlyphVertices>0&&c?(_(c),fa(c,a.WritingMode.vertical)):{box:null,offscreen:null}}),R(h&&h.box&&h.box.length)}}if(e=(m=h)&&m.box&&m.box.length>0,n=m&&m.offscreen,d.useRuntimeCollisionCircles){const U=b.text.placedSymbolArray.get(d.centerJustifiedTextSymbolIndex>=0?d.centerJustifiedTextSymbolIndex:d.verticalPlacedTextSymbolIndex),V=a.evaluateSizeForFeature(b.textSizeData,z,U),ba=c.get("text-padding");g=this.collisionIndex.placeCollisionCircles(j,U,b.lineVertexArray,b.glyphOffsetArray,V,p,u,v,i,D,B.predicate,d.collisionCircleDiameter*V/a.ONE_EM,ba,this.retainedQueryData[b.bucketInstanceId].tileID),e=j||g.circles.length>0&&!g.collisionDetected,n=n&&g.offscreen}if(f.iconFeatureIndex&&(P=f.iconFeatureIndex),f.iconBox){const W=c=>{_(c);const d=E&&da?Wa(da.x,da.y,C,D,this.transform.angle):new a.pointGeometry(0,0),e=b.getSymbolInstanceIconSize(A,this.transform.zoom,ca);return this.collisionIndex.placeCollisionBox(e,c,d,k,x,p,B.predicate)};l=s&&s.box&&s.box.length&&f.verticalIconBox?(H=W(f.verticalIconBox)).box.length>0:(H=W(f.iconBox)).box.length>0,n=n&&H.offscreen}const X=q||0===d.numHorizontalGlyphVertices&&0===d.numVerticalGlyphVertices,Y=r||0===d.numIconVertices;if(X||Y?Y?X||(l=l&&e):e=l&&e:l=e=l&&e,e&&m&&m.box&&this.collisionIndex.insertCollisionBox(m.box,c.get("text-ignore-placement"),b.bucketInstanceId,s&&s.box&&K?K:J,B.ID),l&&H&&this.collisionIndex.insertCollisionBox(H.box,c.get("icon-ignore-placement"),b.bucketInstanceId,P,B.ID),g&&(e&&this.collisionIndex.insertCollisionCircles(g.circles,c.get("text-ignore-placement"),b.bucketInstanceId,J,B.ID),i)){const Z=b.bucketInstanceId;let o=this.collisionCircleArrays[Z];void 0===o&&(o=this.collisionCircleArrays[Z]=new Ta);for(let I=0;I=0;--g){const h=m[g];l(b.symbolInstances.get(h),h,b.collisionArrays[h])}}else for(let d=e.symbolInstanceStart;d=0&&(e.text.placedSymbolArray.get(d).crossTileID=c>=0&&d!==c?0:b.crossTileID)}markUsedOrientation(d,b,c){const e=b===a.WritingMode.horizontal||b===a.WritingMode.horizontalOnly?b:0,f=b===a.WritingMode.vertical?b:0,g=[c.leftJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.rightJustifiedTextSymbolIndex];for(const h of g)d.text.placedSymbolArray.get(h).placedOrientation=e;c.verticalPlacedTextSymbolIndex&&(d.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).placedOrientation=f)}commit(f){this.commitTime=f,this.zoomAtLastRecencyCheck=this.transform.zoom;const a=this.prevPlacement;let c=!1;this.prevZoomAdjustment=a?a.zoomAdjustment(this.transform.zoom):0;const i=a?a.symbolFadeChange(f):1,j=a?a.opacities:{},m=a?a.variableOffsets:{},n=a?a.placedOrientations:{};for(const g in this.placements){const b=this.placements[g],h=j[g];h?(this.opacities[g]=new Ra(h,i,b.text,b.icon,null,b.clipped),c=c||b.text!==h.text.placed||b.icon!==h.icon.placed):(this.opacities[g]=new Ra(null,i,b.text,b.icon,b.skipFade,b.clipped),c=c||b.text||b.icon)}for(const k in j){const l=j[k];if(!this.opacities[k]){const o=new Ra(l,i,!1,!1);o.isHidden()||(this.opacities[k]=o,c=c||l.text.placed||l.icon.placed)}}for(const d in m)this.variableOffsets[d]||!this.opacities[d]||this.opacities[d].isHidden()||(this.variableOffsets[d]=m[d]);for(const e in n)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=n[e]);c?this.lastPlacementChangeTime=f:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=a?a.lastPlacementChangeTime:f)}updateLayerOpacities(c,d){const e={};for(const a of d){const b=a.getBucket(c);b&&a.latestFeatureIndex&&c.id===b.layerIds[0]&&this.updateBucketOpacities(b,e,a.collisionBoxArray)}}updateBucketOpacities(b,s,t){b.hasTextData()&&b.text.opacityVertexArray.clear(),b.hasIconData()&&b.icon.opacityVertexArray.clear(),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexArray.clear(),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexArray.clear();const f=b.layers[0].layout,F=!!b.layers[0].dynamicFilter(),G=new Ra(null,0,!1,!1,!0),u=f.get("text-allow-overlap"),v=f.get("icon-allow-overlap"),H=f.get("text-variable-anchor"),I="map"===f.get("text-rotation-alignment"),J="map"===f.get("text-pitch-alignment"),l="none"!==f.get("icon-text-fit"),K=new Ra(null,0,u&&(v||!b.hasIconData()||f.get("icon-optional")),v&&(u||!b.hasTextData()||f.get("text-optional")),!0);!b.collisionArrays&&t&&(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData())&&b.deserializeCollisionBoxes(t);const m=(b,c,d)=>{for(let a=0;a0||y>0,A=c.numIconVertices>0,o=this.placedOrientations[c.crossTileID],p=o===a.WritingMode.vertical,j=o===a.WritingMode.horizontal||o===a.WritingMode.horizontalOnly;if(!z&&!A||d.isHidden()||w++,z){const B=Ya(d.text);m(b.text,x,p?0:B),m(b.text,y,j?0:B);const L=d.text.isHidden();[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex].forEach(a=>{a>=0&&(b.text.placedSymbolArray.get(a).hidden=L||p?1:0)}),c.verticalPlacedTextSymbolIndex>=0&&(b.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).hidden=L||j?1:0);const C=this.variableOffsets[c.crossTileID];C&&this.markUsedJustification(b,C.anchor,c,o);const q=this.placedOrientations[c.crossTileID];q&&(this.markUsedJustification(b,"left",c,q),this.markUsedOrientation(b,q,c))}if(A){const D=Ya(d.icon);c.placedIconSymbolIndex>=0&&(m(b.icon,c.numIconVertices,p?0:D),b.icon.placedSymbolArray.get(c.placedIconSymbolIndex).hidden=d.icon.isHidden()),c.verticalPlacedIconSymbolIndex>=0&&(m(b.icon,c.numVerticalIconVertices,j?0:D),b.icon.placedSymbolArray.get(c.verticalPlacedIconSymbolIndex).hidden=d.icon.isHidden())}if(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData()){const g=b.collisionArrays[n];if(g){let e=new a.pointGeometry(0,0),k=!0;if(g.textBox||g.verticalTextBox){if(H){const h=this.variableOffsets[i];h?(e=Va(h.anchor,h.width,h.height,h.textOffset,h.textScale),I&&e._rotate(J?this.transform.angle:-this.transform.angle)):k=!1}F&&(k=!d.clipped),g.textBox&&Xa(b.textCollisionBox.collisionVertexArray,d.text.placed,!k||p,e.x,e.y),g.verticalTextBox&&Xa(b.textCollisionBox.collisionVertexArray,d.text.placed,!k||j,e.x,e.y)}const E=k&&Boolean(!j&&g.verticalIconBox);g.iconBox&&Xa(b.iconCollisionBox.collisionVertexArray,d.icon.placed,E,l?e.x:0,l?e.y:0),g.verticalIconBox&&Xa(b.iconCollisionBox.collisionVertexArray,d.icon.placed,!E,l?e.x:0,l?e.y:0)}}}if(b.fullyClipped=0===w,b.sortFeatures(this.transform.angle),this.retainedQueryData[b.bucketInstanceId]&&(this.retainedQueryData[b.bucketInstanceId].featureSortOrder=b.featureSortOrder),b.hasTextData()&&b.text.opacityVertexBuffer&&b.text.opacityVertexBuffer.updateData(b.text.opacityVertexArray),b.hasIconData()&&b.icon.opacityVertexBuffer&&b.icon.opacityVertexBuffer.updateData(b.icon.opacityVertexArray),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexBuffer&&b.iconCollisionBox.collisionVertexBuffer.updateData(b.iconCollisionBox.collisionVertexArray),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexBuffer&&b.textCollisionBox.collisionVertexBuffer.updateData(b.textCollisionBox.collisionVertexArray),b.bucketInstanceId in this.collisionCircleArrays){const r=this.collisionCircleArrays[b.bucketInstanceId];b.placementInvProjMatrix=r.invProjMatrix,b.placementViewportMatrix=r.viewportMatrix,b.collisionCircleArray=r.circles,delete this.collisionCircleArrays[b.bucketInstanceId]}}symbolFadeChange(a){return 0===this.fadeDuration?1:(a-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(a){return Math.max(0,(this.transform.zoom-a)/1.5)}hasTransitions(a){return this.stale||a-this.lastPlacementChangeTimeb}setStale(){this.stale=!0}}(b,f,g,h,i),this._currentPlacementIndex=c.length-1,this._forceFullPlacement=d,this._showCollisionBoxes=e,this._done=!1}isDone(){return this._done}continuePlacement(d,e,f){const h=a.exported.now(),g=()=>{const b=a.exported.now()-h;return!this._forceFullPlacement&&b>2};for(;this._currentPlacementIndex>=0;){const b=e[d[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===b.type&&(!b.minzoom||b.minzoom<=c)&&(!b.maxzoom||b.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new Za(b)),this._inProgressLayer.continuePlacement(f[b.source],this.placement,this._showCollisionBoxes,b,g))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(a){return this.placement.commit(a),this.placement}}const _a=512/a.EXTENT/2;class ab{constructor(d,e,f){this.tileID=d,this.indexedSymbolInstances={},this.bucketInstanceId=f;for(let a=0;aa.overscaledZ)for(const l in f){const i=f[l];i.tileID.isChildOf(a)&&i.findMatches(b.symbolInstances,a,d)}else{const j=f[a.scaledTo(Number(e)).key];j&&j.findMatches(b.symbolInstances,a,d)}}for(let g=0;g{c[a]=!0}),this.layerIndexes)c[a]||delete this.layerIndexes[a]}}const db=(c,b)=>a.emitValidationErrors(c,b&&b.filter(a=>"source.canvas"!==a.identifier)),eb=a.pick(i,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),fb=a.pick(i,["setCenter","setZoom","setBearing","setPitch"]),gb=function(){const c={},f=a.spec.$version;for(const b in a.spec.$root){const d=a.spec.$root[b];if(d.required){let e=null;null!=(e="version"===b?f:"array"===d.type?[]:{})&&(c[b]=e)}}return c}(),hb={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class c extends a.Evented{constructor(d,b={}){super(),this.map=d,this.dispatcher=new n(oa(),this),this.imageManager=new J,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(d._requestManager,b.localFontFamily?a.LocalGlyphMode.all:b.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,b.localFontFamily||b.localIdeographFontFamily),this.lineAtlas=new a.LineAtlas(256,512),this.crossTileSymbolIndex=new cb,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new a.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",a.getReferrer());const e=this;this._rtlTextPluginCallback=c.registerForPluginStateChange(b=>{e.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:b.pluginStatus,pluginURL:b.pluginURL},(f,b)=>{if(a.triggerPluginCompletionEvent(f),b&&b.every(a=>a))for(const g in e._sourceCaches){const c=e._sourceCaches[g],d=c.getSource().type;"vector"!==d&&"geojson"!==d||c.reload()}})}),this.on("data",a=>{if("source"!==a.dataType||"metadata"!==a.sourceDataType)return;const b=this.getSource(a.sourceId);if(b&&b.vectorLayerIds)for(const d in this._layers){const c=this._layers[d];c.source===b.id&&this._validateLayer(c)}})}loadURL(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"}));const e="boolean"==typeof c.validate?c.validate:!a.isMapboxURL(b);b=this.map._requestManager.normalizeStyleURL(b,c.accessToken);const d=this.map._requestManager.transformRequest(b,a.ResourceType.Style);this._request=a.getJSON(d,(b,c)=>{this._request=null,b?this.fire(new a.ErrorEvent(b)):c&&this._load(c,e)})}loadJSON(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(b,!1!==c.validate)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(gb,!1)}_updateLayerCount(a,c){const b=c?1:-1;a.is3D()&&(this._num3DLayers+=b),"circle"===a.type&&(this._numCircleLayers+=b),"symbol"===a.type&&(this._numSymbolLayers+=b)}_load(c,f){if(f&&db(this,a.validateStyle(c)))return;for(const d in this._loaded=!0,this.stylesheet=c,this.updateProjection(),c.sources)this.addSource(d,c.sources[d],{validate:!1});this._changed=!1,c.sprite?this._loadSprite(c.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(c.glyphs);const e=qa(this.stylesheet.layers);for(let b of(this._order=e.map(a=>a.id),this._layers={},this._serializedLayers={},e))(b=a.createStyleLayer(b)).setEventedParent(this,{layer:{id:b.id}}),this._layers[b.id]=b,this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new M(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new a.Event("data",{dataType:"style"})),this.fire(new a.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(a){a?this.stylesheet.projection=a:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const b=this.map.transform.projection,c=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),a=this.map.transform.projection;if(this._loaded&&(a.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),c){if(a.isReprojectedInTileSpace||b.isReprojectedInTileSpace)for(const d in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[d].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(b){this._spriteRequest=(function(c,b,e){let f,g,h;const d=a.exported.devicePixelRatio>1?"@2x":"";let i=a.getJSON(b.transformRequest(b.normalizeSpriteURL(c,d,".json"),a.ResourceType.SpriteJSON),(a,b)=>{i=null,h||(h=a,f=b,k())}),j=a.getImage(b.transformRequest(b.normalizeSpriteURL(c,d,".png"),a.ResourceType.SpriteImage),(a,b)=>{j=null,h||(h=a,g=b,k())});function k(){if(h)e(h);else if(f&&g){const k=a.exported.getImageData(g),b={};for(const c in f){const{width:d,height:i,x:l,y:m,sdf:n,pixelRatio:o,stretchX:p,stretchY:q,content:r}=f[c],j=new a.RGBAImage({width:d,height:i});a.RGBAImage.copy(k,j,{x:l,y:m},{x:0,y:0},{width:d,height:i}),b[c]={data:j,pixelRatio:o,sdf:n,stretchX:p,stretchY:q,content:r}}e(null,b)}}return{cancel(){i&&(i.cancel(),i=null),j&&(j.cancel(),j=null)}}})(b,this.map._requestManager,(c,b)=>{if(this._spriteRequest=null,c)this.fire(new a.ErrorEvent(c));else if(b)for(const d in b)this.imageManager.addImage(d,b[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new a.Event("data",{dataType:"style"}))})}_validateLayer(c){const b=this.getSource(c.source);if(!b)return;const d=c.sourceLayer;d&&("geojson"===b.type||b.vectorLayerIds&& -1===b.vectorLayerIds.indexOf(d))&&this.fire(new a.ErrorEvent(new Error(`Source layer "${d}" does not exist on source "${b.id}" as specified by style layer "${c.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const a in this._sourceCaches)if(!this._sourceCaches[a].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(c){const a=[];for(const d of c){const b=this._layers[d];"custom"!==b.type&&a.push(b.serialize())}return a}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const a in this._sourceCaches)if(this._sourceCaches[a].hasTransition())return!0;for(const b in this._layers)if(this._layers[b].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(a){return!!this.terrain&&hb[a.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(b){if(!this._loaded)return;const p=this._changed;if(this._changed){const g=Object.keys(this._updatedLayers),h=Object.keys(this._removedLayers);for(const d in(g.length||h.length)&&this._updateWorkerLayers(g,h),this._updatedSources){const i=this._updatedSources[d];"reload"===i?this._reloadSource(d):"clear"===i&&this._clearSource(d)}for(const q in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[q].updateTransitions(b);this.light.updateTransitions(b),this.fog&&this.fog.updateTransitions(b),this._resetUpdates()}const e={};for(const j in this._sourceCaches){const k=this._sourceCaches[j];e[j]=k.used,k.used=!1}for(const r of this._order){const c=this._layers[r];if(c.recalculate(b,this._availableImages),!c.isHidden(b.zoom)){const l=this._getLayerSourceCache(c);l&&(l.used=!0)}const m=this.map.painter;if(m){const n=c.getProgramIds();if(!n)continue;const s=c.getProgramConfiguration(b.zoom);for(const t of n)m.useProgram(t,s)}}for(const o in e){const f=this._sourceCaches[o];e[o]!==f.used&&f.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:f.getSource().id}))}this.light.recalculate(b),this.terrain&&this.terrain.recalculate(b),this.fog&&this.fog.recalculate(b),this.z=b.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),p&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const a=Object.keys(this._changedImages);if(a.length){for(const b in this._sourceCaches)this._sourceCaches[b].reloadTilesForDependencies(["icons","patterns"],a);this._changedImages={}}}_updateWorkerLayers(a,b){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(a),removedIds:b})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(b){if(this._checkLoaded(),db(this,a.validateStyle(b)))return!1;(b=a.clone$1(b)).layers=qa(b.layers);const c=(function(c,a){if(!c)return[{command:i.setStyle,args:[a]}];let b=[];try{if(!D(c.version,a.version))return[{command:i.setStyle,args:[a]}];D(c.center,a.center)||b.push({command:i.setCenter,args:[a.center]}),D(c.zoom,a.zoom)||b.push({command:i.setZoom,args:[a.zoom]}),D(c.bearing,a.bearing)||b.push({command:i.setBearing,args:[a.bearing]}),D(c.pitch,a.pitch)||b.push({command:i.setPitch,args:[a.pitch]}),D(c.sprite,a.sprite)||b.push({command:i.setSprite,args:[a.sprite]}),D(c.glyphs,a.glyphs)||b.push({command:i.setGlyphs,args:[a.glyphs]}),D(c.transition,a.transition)||b.push({command:i.setTransition,args:[a.transition]}),D(c.light,a.light)||b.push({command:i.setLight,args:[a.light]}),D(c.fog,a.fog)||b.push({command:i.setFog,args:[a.fog]}),D(c.projection,a.projection)||b.push({command:i.setProjection,args:[a.projection]});const e={},f=[];!function(c,b,d,e){let a;for(a in b=b||{},c=c||{})c.hasOwnProperty(a)&&(b.hasOwnProperty(a)||sa(a,d,e));for(a in b)b.hasOwnProperty(a)&&(c.hasOwnProperty(a)?D(c[a],b[a])||("geojson"===c[a].type&&"geojson"===b[a].type&&ua(c,b,a)?d.push({command:i.setGeoJSONSourceData,args:[a,b[a].data]}):ta(a,b,d,e)):ra(a,b,d))}(c.sources,a.sources,f,e);const g=[];c.layers&&c.layers.forEach(a=>{e[a.source]?b.push({command:i.removeLayer,args:[a.id]}):g.push(a)});let d=c.terrain;d&&e[d.source]&&(b.push({command:i.setTerrain,args:[void 0]}),d=void 0),b=b.concat(f),D(d,a.terrain)||b.push({command:i.setTerrain,args:[a.terrain]}),(function(m,k,f){k=k||[];const n=(m=m||[]).map(wa),j=k.map(wa),p=m.reduce(xa,{}),o=k.reduce(xa,{}),g=n.slice(),q=Object.create(null);let e,h,b,d,c,l,a;for(e=0,h=0;e!(a.command in fb));if(0===c.length)return!1;const d=c.filter(a=>!(a.command in eb));if(d.length>0)throw new Error(`Unimplemented: ${d.map(a=>a.command).join(", ")}.`);return c.forEach(a=>{"setTransition"!==a.command&&this[a.command].apply(this,a.args)}),this.stylesheet=b,this.updateProjection(),!0}addImage(b,c){if(this.getImage(b))return this.fire(new a.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(b,c),this._afterImageUpdated(b)}updateImage(a,b){this.imageManager.updateImage(a,b)}getImage(a){return this.imageManager.getImage(a)}removeImage(b){if(!this.getImage(b))return this.fire(new a.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(b),this._afterImageUpdated(b)}_afterImageUpdated(b){this._availableImages=this.imageManager.listImages(),this._changedImages[b]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new a.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(c,b,f={}){if(this._checkLoaded(),void 0!==this.getSource(c))throw new Error("There is already a source with this ID");if(!b.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(b).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(b.type)>=0&&this._validate(a.validateStyle.source,`sources.${c}`,b,null,f))return;this.map&&this.map._collectResourceTiming&&(b.collectResourceTiming=!0);const d=ga(c,b,this.dispatcher,this);d.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:d.serialize(),sourceId:c}));const e=b=>{const f=(b?"symbol:":"other:")+c,e=this._sourceCaches[f]=new a.SourceCache(f,d,b);(b?this._symbolSourceCaches:this._otherSourceCaches)[c]=e,e.style=this,e.onAdd(this.map)};e(!1),"vector"!==b.type&&"geojson"!==b.type||e(!0),d.onAdd&&d.onAdd(this.map),this._changed=!0}removeSource(b){this._checkLoaded();const d=this.getSource(b);if(void 0===d)throw new Error("There is no source with this ID");for(const e in this._layers)if(this._layers[e].source===b)return this.fire(new a.ErrorEvent(new Error(`Source "${b}" cannot be removed while layer "${e}" is using it.`)));if(this.terrain&&this.terrain.get().source===b)return this.fire(new a.ErrorEvent(new Error(`Source "${b}" cannot be removed while terrain is using it.`)));const f=this._getSourceCaches(b);for(const c of f)delete this._sourceCaches[c.id],delete this._updatedSources[c.id],c.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:c.getSource().id})),c.setEventedParent(null),c.clearTiles();delete this._otherSourceCaches[b],delete this._symbolSourceCaches[b],d.setEventedParent(null),d.onRemove&&d.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(a,b){this._checkLoaded(),this.getSource(a).setData(b),this._changed=!0}getSource(b){const a=this._getSourceCache(b);return a&&a.getSource()}addLayer(c,e,h={}){this._checkLoaded();const d=c.id;if(this.getLayer(d))return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${d}" already exists on this map`)));let b;if("custom"===c.type){if(db(this,a.validateCustomStyleLayer(c)))return;b=a.createStyleLayer(c)}else{if("object"==typeof c.source&&(this.addSource(d,c.source),c=a.clone$1(c),c=a.extend(c,{source:d})),this._validate(a.validateStyle.layer,`layers.${d}`,c,{arrayIndex:-1},h))return;b=a.createStyleLayer(c),this._validateLayer(b),b.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0)}const f=e?this._order.indexOf(e):this._order.length;if(e&& -1===f)return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${e}" does not exist on this map.`)));this._order.splice(f,0,d),this._layerOrderChanged=!0,this._layers[d]=b;const g=this._getLayerSourceCache(b);if(this._removedLayers[d]&&b.source&&g&&"custom"!==b.type){const i=this._removedLayers[d];delete this._removedLayers[d],i.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",g.pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(b,c){if(this._checkLoaded(),this._changed=!0,!this._layers[b])return void this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style and cannot be moved.`)));if(b===c)return;const e=this._order.indexOf(b);this._order.splice(e,1);const d=c?this._order.indexOf(c):this._order.length;c&& -1===d?this.fire(new a.ErrorEvent(new Error(`Layer with id "${c}" does not exist on this map.`))):(this._order.splice(d,0,b),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(b){this._checkLoaded();const c=this._layers[b];if(!c)return void this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style and cannot be removed.`)));c.setEventedParent(null),this._updateLayerCount(c,!1);const d=this._order.indexOf(b);this._order.splice(d,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[b]=c,delete this._layers[b],delete this._serializedLayers[b],delete this._updatedLayers[b],delete this._updatedPaintProps[b],c.onRemove&&c.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(a){return this._layers[a]}hasLayer(a){return a in this._layers}hasLayerType(a){for(const b in this._layers)if(this._layers[b].type===a)return!0;return!1}setLayerZoomRange(e,c,d){this._checkLoaded();const b=this.getLayer(e);b?b.minzoom===c&&b.maxzoom===d||(null!=c&&(b.minzoom=c),null!=d&&(b.maxzoom=d),this._updateLayer(b)):this.fire(new a.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(d,c,e={}){this._checkLoaded();const b=this.getLayer(d);if(b){if(!D(b.filter,c))return null==c?(b.filter=void 0,void this._updateLayer(b)):void(this._validate(a.validateStyle.filter,`layers.${b.id}.filter`,c,{layerType:b.type},e)||(b.filter=a.clone$1(c),this._updateLayer(b)))}else this.fire(new a.ErrorEvent(new Error(`The layer '${d}' does not exist in the map's style and cannot be filtered.`)))}getFilter(b){return a.clone$1(this.getLayer(b).filter)}setLayoutProperty(c,d,e,f={}){this._checkLoaded();const b=this.getLayer(c);b?D(b.getLayoutProperty(d),e)||(b.setLayoutProperty(d,e,f),this._updateLayer(b)):this.fire(new a.ErrorEvent(new Error(`The layer '${c}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(b,d){const c=this.getLayer(b);if(c)return c.getLayoutProperty(d);this.fire(new a.ErrorEvent(new Error(`The layer '${b}' does not exist in the map's style.`)))}setPaintProperty(c,d,e,f={}){this._checkLoaded();const b=this.getLayer(c);b?D(b.getPaintProperty(d),e)||(b.setPaintProperty(d,e,f)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[c]=!0):this.fire(new a.ErrorEvent(new Error(`The layer '${c}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(a,b){return this.getLayer(a).getPaintProperty(b)}setFeatureState(b,g){this._checkLoaded();const c=b.source,d=b.sourceLayer,e=this.getSource(c);if(void 0===e)return void this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)));const f=e.type;if("geojson"===f&&d)return void this.fire(new a.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===f&&!d)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===b.id&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided.")));const h=this._getSourceCaches(c);for(const i of h)i.setFeatureState(d,b.id,g)}removeFeatureState(b,d){this._checkLoaded();const c=b.source,e=this.getSource(c);if(void 0===e)return void this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)));const f=e.type,g="vector"===f?b.sourceLayer:void 0;if("vector"===f&&!g)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(d&&"string"!=typeof b.id&&"number"!=typeof b.id)return void this.fire(new a.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const h=this._getSourceCaches(c);for(const i of h)i.removeFeatureState(g,b.id,d)}getFeatureState(b){this._checkLoaded();const c=b.source,d=b.sourceLayer,e=this.getSource(c);if(void 0!==e){if("vector"!==e.type||d)return void 0===b.id&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(c)[0].getFeatureState(d,b.id);this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(new Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const b={};for(const d in this._sourceCaches){const c=this._sourceCaches[d].getSource();b[c.id]||(b[c.id]=c.serialize())}return a.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:b,layers:this._serializeLayers(this._order)},a=>void 0!==a)}_updateLayer(a){this._updatedLayers[a.id]=!0;const b=this._getLayerSourceCache(a);a.source&&!this._updatedSources[a.source]&&b&&"raster"!==b.getSource().type&&(this._updatedSources[a.source]="reload",b.pause()),this._changed=!0,a.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){var a,a;const i={},b=[];for(let c=this._order.length-1;c>=0;c--){const e=this._order[c];if(a=e,"fill-extrusion"===this._layers[a].type)for(const n of(i[e]=c,h)){const j=n[e];if(j)for(const o of j)b.push(o)}}b.sort((a,b)=>b.intersectionZ-a.intersectionZ);const f=[];for(let d=this._order.length-1;d>=0;d--){const k=this._order[d];if(a=k,"fill-extrusion"===this._layers[a].type)for(let g=b.length-1;g>=0;g--){const l=b[g].feature;if(i[l.layer.id]{const a=this.getLayer(b);return a&&a.is3D()}):this.has3DLayers(),h=_.createFromScreenPoints(j,d);for(const i in this._sourceCaches){const l=this._sourceCaches[i].getSource().id;b.layers&&!e[l]||c.push(ia(this._sourceCaches[i],this._layers,this._serializedLayers,h,b,d,k,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,j,r,k,c,l,m){const a={},f=l.queryRenderedSymbols(k),d=[];for(const n of Object.keys(f).map(Number))d.push(m[n]);for(const b of(d.sort(ka),d)){const g=b.featureIndex.lookupSymbolFeatures(f[b.bucketInstanceId],j,b.bucketIndex,b.sourceLayerIndex,c.filter,c.layers,c.availableImages,i);for(const e in g){const o=a[e]=a[e]||[],h=g[e];for(const p of(h.sort((c,d)=>{const a=b.featureSortOrder;if(a){const e=a.indexOf(c.featureIndex);return a.indexOf(d.featureIndex)-e}return d.featureIndex-c.featureIndex}),h))o.push(p)}}for(const q in a)a[q].forEach(b=>{const a=b.feature,c=r(i[q]).getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=c});return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),h.screenGeometry,b,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(d,b){b&&b.filter&&this._validate(a.validateStyle.filter,"querySourceFeatures.filter",b.filter,null,b);const e=this._getSourceCaches(d);let c=[];for(const f of e)c=c.concat(ja(f,b));return c}addSourceType(a,b,d){return c.getSourceType(a)?d(new Error(`A source type called "${a}" already exists.`)):(c.setSourceType(a,b),b.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:a,url:b.workerSourceURL},d):d(null,null))}getLight(){return this.light.getLight()}setLight(b,e={}){this._checkLoaded();const f=this.light.getLight();let c=!1;for(const d in b)if(!D(b[d],f[d])){c=!0;break}if(!c)return;const g={now:a.exported.now(),transition:a.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(b,e),this.light.updateTransitions(g)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(b,c=1){if(this._checkLoaded(),!b)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===c){if("object"==typeof b.source){const e="terrain-dem-src";this.addSource(e,b.source),b=a.clone$1(b),b=a.extend(b,{source:e})}if(this._validate(a.validateStyle.terrain,"terrain",b))return}if(!this.terrain||this.terrain&&c!==this.terrain.drapeRenderMode)this._createTerrain(b,c);else{const d=this.terrain,g=d.get();for(const f in b)if(!D(b[f],g[f])){d.set(b),this.stylesheet.terrain=b;const h={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(h);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(b){const c=this.fog=new U(b,this.map.transform);this.stylesheet.fog=b;const d={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(d)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const a of this.map._markers)a._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(b){if(this._checkLoaded(),!b)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const c=this.fog,e=c.get();for(const d in b)if(!D(b[d],e[d])){c.set(b),this.stylesheet.fog=b;const f={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(f);break}}else this._createFog(b);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const a=this._order.filter(a=>this.isLayerDraped(this._layers[a])),b=this._order.filter(a=>!this.isLayerDraped(this._layers[a]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...a),this._drapedFirstOrder.push(...b)}_createTerrain(b,c){const d=this.terrain=new P(b,c);this.stylesheet.terrain=b,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const e={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(e)}_force3DLayerUpdate(){for(const b in this._layers){const a=this._layers[b];"fill-extrusion"===a.type&&this._updateLayer(a)}}_forceSymbolLayerUpdate(){for(const b in this._layers){const a=this._layers[b];"symbol"===a.type&&this._updateLayer(a)}}_validate(c,d,e,f,b={}){return(!b|| !1!==b.validate)&&db(this,c.call(a.validateStyle,a.extend({key:d,style:this.serialize(),value:e,styleSpec:a.spec},f)))}_remove(){for(const c in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[c].setEventedParent(null);for(const b in this._sourceCaches)this._sourceCaches[b].clearTiles(),this._sourceCaches[b].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(a){const b=this._getSourceCaches(a);for(const c of b)c.clearTiles()}_reloadSource(b){const c=this._getSourceCaches(b);for(const a of c)a.resume(),a.reload()}_updateSources(a){for(const b in this._sourceCaches)this._sourceCaches[b].update(a)}_generateCollisionBoxes(){for(const b in this._sourceCaches){const a=this._sourceCaches[b];a.resume(),a.reload()}}_updatePlacement(c,k,h,l,e=!1){let f=!1,i=!1;const d={};for(const m of this._order){const b=this._layers[m];if("symbol"!==b.type)continue;if(!d[b.source]){const j=this._getLayerSourceCache(b);if(!j)continue;d[b.source]=j.getRenderableIds(!0).map(a=>j.getTileByID(a)).sort((a,b)=>b.tileID.overscaledZ-a.tileID.overscaledZ||(a.tileID.isLessThan(b.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(b,d[b.source],c.center.lng,c.projection);f=f||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),e=e||this._layerOrderChanged||0===h,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(e||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),c.zoom))&&(this.pauseablePlacement=new $a(c,this._order,e,k,h,l,this.placement,this.fog&&c.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,d),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),i=!0),f&&this.pauseablePlacement.placement.setStale()),i||f)for(const o of this._order){const g=this._layers[o];"symbol"===g.type&&this.placement.updateLayerOpacities(g,d[g.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(const a in this._sourceCaches)this._sourceCaches[a].releaseSymbolFadeTiles()}getImages(d,a,c){this.imageManager.getImages(a.icons,c),this._updateTilesForChangedImages();const b=b=>{b&&b.setDependencies(a.tileID.key,a.type,a.icons)};b(this._otherSourceCaches[a.source]),b(this._symbolSourceCaches[a.source])}getGlyphs(c,a,b){this.glyphManager.getGlyphs(a.stacks,b)}getResource(d,b,c){return a.makeRequest(b,c)}_getSourceCache(a){return this._otherSourceCaches[a]}_getLayerSourceCache(a){return"symbol"===a.type?this._symbolSourceCaches[a.source]:this._otherSourceCaches[a.source]}_getSourceCaches(a){const b=[];return this._otherSourceCaches[a]&&b.push(this._otherSourceCaches[a]),this._symbolSourceCaches[a]&&b.push(this._symbolSourceCaches[a]),b}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}c.getSourceType=function(a){return fa[a]},c.setSourceType=function(a,b){fa[a]=b},c.registerForPluginStateChange=a.registerForPluginStateChange;var t="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif",j="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let u={},v={};u=lb("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),v=lb("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const ib=lb("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nreturn mix(globe,mercator,t);\n#else\nreturn globe;\n#endif\n}\n#ifdef PROJECTION_GLOBE_VIEW\nmat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),jb=t;var kb={background:lb("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:lb("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:lb("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:lb("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:lb("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:lb("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:lb("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:lb("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:lb("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:lb("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:lb("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:lb("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:lb("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:lb("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:lb("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:lb("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:lb("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:lb("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:lb("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:lb("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:lb("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:lb("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:lb("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:lb("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:lb("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:lb("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",j),skyboxGradient:lb("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",j),skyboxCapture:lb("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:lb("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:lb("uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)\ndiscard;float t=clamp(1.0-sqrt(normDistFromCenter-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;void main() {gl_Position=vec4(a_pos,1.0);}")};function lb(c,b,h){const e=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,d=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,i=b.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),f=c.match(d),g=b.match(d),j=t.match(d);let a=g?g.concat(f):f;h||(u.staticUniforms&&(a=u.staticUniforms.concat(a)),v.staticUniforms&&(a=v.staticUniforms.concat(a))),a&&(a=a.concat(j));const k={};return{fragmentSource:c=c.replace(e,(e,d,b,c,a)=>(k[a]=!0,"define"===d?`\n#ifndef HAS_UNIFORM_u_${a}\nvarying ${b} ${c} ${a};\n#else\nuniform ${b} ${c} u_${a};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${a}\n ${b} ${c} ${a} = u_${a};\n#endif\n`)),vertexSource:b=b.replace(e,(g,f,b,c,a)=>{const e="float"===c?"vec2":"vec4",d=a.match(/color/)?"color":e;return k[a]?"define"===f?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nattribute ${b} ${e} a_${a};\nvarying ${b} ${c} ${a};\n#else\nuniform ${b} ${c} u_${a};\n#endif\n`:"vec4"===d?`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = a_${a};\n#else\n ${b} ${c} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${a} = unpack_mix_${d}(a_${a}, u_${a}_t);\n#else\n ${b} ${c} ${a} = u_${a};\n#endif\n`:"define"===f?`\n#ifndef HAS_UNIFORM_u_${a}\nuniform lowp float u_${a}_t;\nattribute ${b} ${e} a_${a};\n#else\nuniform ${b} ${c} u_${a};\n#endif\n`:"vec4"===d?`\n#ifndef HAS_UNIFORM_u_${a}\n ${b} ${c} ${a} = a_${a};\n#else\n ${b} ${c} ${a} = u_${a};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${a}\n ${b} ${c} ${a} = unpack_mix_${d}(a_${a}, u_${a}_t);\n#else\n ${b} ${c} ${a} = u_${a};\n#endif\n`}),staticAttributes:i,staticUniforms:a}}class mb{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(f,h,i,b,a,j,c,d){this.context=f;let g=this.boundPaintVertexBuffers.length!==b.length;for(let e=0;!g&&e{const g=b.paint.get("hillshade-shadow-color"),h=b.paint.get("hillshade-highlight-color"),i=b.paint.get("hillshade-accent-color");let e=b.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===b.paint.get("hillshade-illumination-anchor")&&(e-=c.transform.angle);const j=!c.options.moving;return{u_matrix:f||c.transform.calculateProjMatrix(d.tileID.toUnwrapped(),j),u_image:0,u_latrange:(function(e,b){const c=Math.pow(2,b.canonical.z),d=b.canonical.y;return[new a.MercatorCoordinate(0,d/c).toLngLat().lat,new a.MercatorCoordinate(0,(d+1)/c).toLngLat().lat]})(0,d.tileID),u_light:[b.paint.get("hillshade-exaggeration"),e],u_shadow:g,u_highlight:h,u_accent:i}})(b,f,g,b.terrain?e.projMatrix:null);b.prepareDrawProgram(c,i,e.toUnwrapped());const{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=b.getTileBoundsBuffers(f);i.draw(c,d.TRIANGLES,j,k,l,a.CullFaceMode.disabled,m,g.id,n,o,p)}function ob(d,b,e){if(!b.needsDEMTextureUpload)return;const c=d.context,g=c.gl;c.pixelStoreUnpackPremultiplyAlpha.set(!1),b.demTexture=b.demTexture||d.getTileTexture(e.stride);const f=e.getPixels();b.demTexture?b.demTexture.update(f,{premultiply:!1}):b.demTexture=new a.Texture(c,f,g.RGBA,{premultiply:!1}),b.needsDEMTextureUpload=!1}function pb(f,b,j,k,l,m){const c=f.context,d=c.gl;if(!b.dem)return;const g=b.dem;if(c.activeTexture.set(d.TEXTURE1),ob(f,b,g),!b.demTexture)return;b.demTexture.bind(d.NEAREST,d.CLAMP_TO_EDGE);const e=g.dim;c.activeTexture.set(d.TEXTURE0);let h=b.fbo;if(!h){const i=new a.Texture(c,{width:e,height:e,data:null},d.RGBA);i.bind(d.LINEAR,d.CLAMP_TO_EDGE),(h=b.fbo=c.createFramebuffer(e,e,!0)).colorAttachment.set(i.texture)}c.bindFramebuffer.set(h.framebuffer),c.viewport.set([0,0,e,e]);const{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=f.getMercatorTileBoundsBuffers();f.useProgram("hillshadePrepare").draw(c,d.TRIANGLES,k,l,m,a.CullFaceMode.disabled,((e,c)=>{const d=c.stride,b=a.create();return a.ortho(b,0,a.EXTENT,-a.EXTENT,0,0,1),a.translate(b,b,[0,-a.EXTENT,0]),{u_matrix:b,u_image:1,u_dimension:[d,d],u_zoom:e.overscaledZ,u_unpack:c.unpackVector}})(b.tileID,g),j.id,n,o,p),b.needsHillshadePrepare=!1}const k=(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image0:new a.Uniform1i(b,c.u_image0),u_skirt_height:new a.Uniform1f(b,c.u_skirt_height)}),qb=(a,b)=>({u_matrix:a,u_image0:0,u_skirt_height:b}),rb=(a,b,c,d,e)=>({u_proj_matrix:Float32Array.from(a),u_globe_matrix:b,u_merc_matrix:c,u_zoom_transition:d,u_merc_center:e,u_image0:0});function sb(a,b){return null!=a&&null!=b&&!(!a.hasData()||!b.hasData())&&null!=a.demTexture&&null!=b.demTexture&&a.tileID.key!==b.tileID.key}const tb=new class{constructor(){this.operations={}}newMorphing(a,d,b,e,f){if(a in this.operations){const c=this.operations[a];c.to.tileID.key!==b.tileID.key&&(c.queued=b)}else this.operations[a]={startTime:e,phase:0,duration:f,from:d,to:b,queued:null}}getMorphValuesForProxy(b){if(!(b in this.operations))return null;const a=this.operations[b];return{from:a.from,to:a.to,phase:a.phase}}update(b){for(const c in this.operations){const a=this.operations[c];for(a.phase=(b-a.startTime)/a.duration;a.phase>=1||!this._validOp(a);)if(!this._nextOp(a,b)){delete this.operations[c];break}}}_nextOp(a,b){return!!a.queued&&(a.from=a.to,a.to=a.queued,a.queued=null,a.phase=0,a.startTime=b,!0)}_validOp(a){return a.from.hasData()&&a.to.hasData()}},ub={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function vb(a,c){const b=1<({u_matrix:a});function xb(b,c,k,l,d){if(d>0){const e=a.exported.now(),f=(e-b.timeAdded)/d,m=c?(e-c.timeAdded)/d:-1,g=k.getSource(),h=l.coveringZoomLevel({tileSize:g.tileSize,roundZoom:g.roundZoom}),i=!c||Math.abs(c.tileID.overscaledZ-h)>Math.abs(b.tileID.overscaledZ-h),j=i&&b.refreshedUponExpiration?1:a.clamp(i?f:1-m,0,1);return b.refreshedUponExpiration&&f>=1&&(b.refreshedUponExpiration=!1),c?{opacity:1,mix:1-j}:{opacity:j,mix:0}}return{opacity:1,mix:0}}class yb extends a.SourceCache{constructor(a){const c={type:"raster-dem",maxzoom:a.transform.maxZoom},d=new n(oa(),null),b=ga("mock-dem",c,d,a.style);super("mock-dem",b,!1),b.setEventedParent(this),this._sourceLoaded=!0}_loadTile(a,b){a.state="loaded",b(null)}}class zb extends a.SourceCache{constructor(a){const b=ga("proxy",{type:"geojson",maxzoom:a.transform.maxZoom},new n(oa(),null),a.style);super("proxy",b,!1),b.setEventedParent(this),this.map=this.getSource().map=a,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(c,e,f){if(c.freezeTileCoverage)return;this.transform=c;const d=c.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((d,b)=>{if(d[b.key]="",!this._tiles[b.key]){const e=new a.Tile(b,this._source.tileSize*b.overscaleFactor(),c.tileZoom);e.state="loaded",this._tiles[b.key]=e}return d},{});for(const b in this._tiles)b in d||(this.freeFBO(b),this._tiles[b].unloadVectorData(),delete this._tiles[b])}freeFBO(a){const b=this.proxyCachedFBO[a];if(void 0!==b){const c=Object.values(b);this.renderCachePool.push(...c),delete this.proxyCachedFBO[a]}}deallocRenderCache(){this.renderCache.forEach(a=>a.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ab extends a.OverscaledTileID{constructor(a,b,c){super(a.overscaledZ,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y),this.proxyTileKey=b,this.projMatrix=c}}class Bb extends a.Elevation{constructor(c,d){super(),this.painter=c,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[e,g,h]=function(o){const e=new a.StructArrayLayout4i8,i=new a.StructArrayLayout3ui6;e.reserve(17161),i.reserve(33800);const b=a.EXTENT/128,f=a.EXTENT+b/2,j=f+b;for(let c=-b;cf||c<0||c>f?24575:0,k=a.clamp(Math.round(d),0,a.EXTENT),l=a.clamp(Math.round(c),0,a.EXTENT);e.emplaceBack(k+m,l,k,l)}const n=(b,c)=>{const a=131*c+b;i.emplaceBack(a+1,a,a+131),i.emplaceBack(a+131,a+131+1,a+1)};for(let g=1;g<129;g++)for(let h=1;h<129;h++)n(h,g);return[0,129].forEach(b=>{for(let a=0;a<130;a++)n(a,b),n(b,a)}),[e,i,32768]}(),f=c.context;this.gridBuffer=f.createVertexBuffer(e,a.boundsAttributes.members),this.gridIndexBuffer=f.createIndexBuffer(g),this.gridSegments=a.SegmentVector.simpleSegment(0,0,e.length,g.length),this.gridNoSkirtSegments=a.SegmentVector.simpleSegment(0,0,e.length,h),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new zb(d.map),this.orthoMatrix=a.create(),a.ortho(this.orthoMatrix,0,a.EXTENT,0,a.EXTENT,0,1);const b=f.gl;this._overlapStencilMode=new a.StencilMode({func:b.GEQUAL,mask:255},0,255,b.KEEP,b.KEEP,b.REPLACE),this._previousZoom=c.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=d,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new yb(d.map)}set style(a){a.on("data",this._onStyleDataEvent.bind(this)),a.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=a,this._checkRenderCacheEfficiency()}update(b,c,f){if(b&&b.terrain){this._style!==b&&(this.style=b),this.enabled=!0;const d=b.terrain.properties;this.sourceCache=0===b.terrain.drapeRenderMode?this._mockSourceCache:b._getSourceCache(d.get("source")),this._exaggeration=d.get("exaggeration");const e=()=>{this.sourceCache.used&&a.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const b=this.getScaledDemTileSize();this.sourceCache.update(c,b,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,e(),this._initializing=!0),e(),c.updateElevation(!f),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(c),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(a){this._findCoveringTileCache[a]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const b=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==b.efficiency&&a.warnOnce(`Terrain render cache efficiency is not optimal (${b.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${b.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(a){a.coord&&"source"===a.dataType?this._clearRenderCacheForTile(a.sourceCacheId,a.coord):"style"===a.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const a in this._style._sourceCaches)this._style._sourceCaches[a].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(a=>a.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const a=2*this.proxySourceCache.getSource().tileSize;return[a,a]}set useVertexMorphing(a){this._useVertexMorphing=a}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,d=this.painter.transform;this._initializing&&(this._initializing=0===d._centerAltitude&& -1===this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(d.center),-1),this._emptyDEMTextureDirty=!this._initializing);const c=this.proxyCoords=i.getIds().map(b=>{const a=i.getTileByID(b).tileID;return a.projMatrix=d.calculateProjMatrix(a.toUnwrapped()),a});(function(d,b){const c=b.transform.pointCoordinate(b.transform.getCameraPoint()),e=new a.pointGeometry(c.x,c.y);d.sort((b,c)=>{if(c.overscaledZ-b.overscaledZ)return c.overscaledZ-b.overscaledZ;const f=new a.pointGeometry(b.canonical.x+(1<{this.proxyToSource[a.key]={}}),this.terrainTileForTile={};const k=this._style._sourceCaches;for(const e in k){const b=k[e];if(!b.used)continue;if(b!==this.sourceCache&&this.resetTileLookupCache(b.id),this._setupProxiedCoordsForOrtho(b,h[e],j),b.usedForTerrain)continue;const m=h[e];b.getSource().reparseOverscaled&&this._assignTerrainTiles(m)}this.proxiedCoords[i.id]=c.map(a=>new Ab(a,a.key,this.orthoMatrix)),this._assignTerrainTiles(c),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(j),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();const l={};for(const n of(this._visibleDemTiles=[],this.proxyCoords)){const f=this.terrainTileForTile[n.key];if(!f)continue;const g=f.tileID.key;g in l||(this._visibleDemTiles.push(f),l[g]=g)}}_assignTerrainTiles(a){this._initializing||a.forEach(a=>{if(this.terrainTileForTile[a.key])return;const b=this._findTileCoveringTileID(a,this.sourceCache);b&&(this.terrainTileForTile[a.key]=b)})}_prepareDEMTextures(){const b=this.painter.context,d=b.gl;for(const e in this.terrainTileForTile){const a=this.terrainTileForTile[e],c=a.dem;c&&(!a.demTexture||a.needsDEMTextureUpload)&&(b.activeTexture.set(d.TEXTURE1),ob(this.painter,a,c))}}_prepareDemTileUniforms(f,a,d,g){if(!a||null==a.demTexture)return!1;const b=f.tileID.canonical,c=Math.pow(2,a.tileID.canonical.z-b.z),e=g||"";return d[`u_dem_tl${e}`]=[b.x*c%1,b.y*c%1],d[`u_dem_scale${e}`]=c,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const b=this.painter.context,c=b.gl;if(!this._emptyDepthBufferTexture){const d={width:1,height:1,data:new Uint8Array([255,255,255,255])};this._emptyDepthBufferTexture=new a.Texture(b,d,c.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let a=0;const b=this._visibleDemTiles.reduce((b,c)=>{if(!c.dem)return b;const d=c.dem.tree.minimums[0];return d>0&&a++,b+d},0);return a?b/a:0}_updateEmptyDEMTexture(){const c=this.painter.context,d=c.gl;c.activeTexture.set(d.TEXTURE2);const f=this._getLoadedAreaMinimum(),e={width:1,height:1,data:new Uint8Array(a.DEMData.pack(f,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let b=this._emptyDEMTexture;return b?b.update(e,{premultiply:!1}):b=this._emptyDEMTexture=new a.Texture(c,e,d.RGBA,{premultiply:!1}),b}setupElevationDraw(g,p,d){var n;const f=this.painter.context,b=f.gl,c=(n=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.DEMData.getUnpackVector(n),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});c.u_dem_size=this.sourceCache.getSource().tileSize,c.u_exaggeration=this.exaggeration();const j=this.painter.transform,h=j.projection.createTileTransform(j,j.worldSize),i=g.tileID.canonical;c.u_tile_tl_up=h.upVector(i,0,0),c.u_tile_tr_up=h.upVector(i,a.EXTENT,0),c.u_tile_br_up=h.upVector(i,a.EXTENT,a.EXTENT),c.u_tile_bl_up=h.upVector(i,0,a.EXTENT),c.u_tile_up_scale=h.upVectorScale(i);let e=null,k=null,o=1;if(d&&d.morphing&&this._useVertexMorphing){const l=d.morphing.srcDemTile,m=d.morphing.dstDemTile;o=d.morphing.phase,l&&m&&(this._prepareDemTileUniforms(g,l,c,"_prev")&&(k=l),this._prepareDemTileUniforms(g,m,c)&&(e=m))}if(k&&e?(f.activeTexture.set(b.TEXTURE2),e.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),f.activeTexture.set(b.TEXTURE4),k.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),c.u_dem_lerp=o):(e=this.terrainTileForTile[g.tileID.key],f.activeTexture.set(b.TEXTURE2),(this._prepareDemTileUniforms(g,e,c)?e.demTexture:this.emptyDEMTexture).bind(b.NEAREST,b.CLAMP_TO_EDGE)),f.activeTexture.set(b.TEXTURE3),d&&d.useDepthForOcclusion?(this._depthTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height]):(this.emptyDepthBufferTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),c.u_depth_size_inv=[1,1]),d&&d.useMeterToDem&&e){const q=(1<{if(l===c)return;const a=[];d&&a.push(ub[g]),a.push(ub[c]),a.push("PROJECTION_GLOBE_VIEW"),k=b.useProgram("globeRaster",null,a),l=c},n=b.colorModeForRenderPass(),o=new a.DepthMode(f.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);tb.update(d);const c=b.transform,p=a.calculateGlobeMatrix(c,c.worldSize),q=a.calculateGlobeMercatorMatrix(c),r=[a.mercatorXfromLng(c.center.lng),a.mercatorYfromLat(c.center.lat)],s=b.globeSharedBuffers;(g?[!1,!0]:[!1]).forEach(u=>{l=-1;const x=u?f.LINES:f.TRIANGLES;for(const g of j){const v=i.getTile(g),y=Math.pow(2,g.canonical.z),[D,E]=a.globeBuffersForTileMesh(b,v,g,y),z=a.StencilMode.disabled,A=h.prevTerrainTileForTile[g.key],B=h.terrainTileForTile[g.key];sb(A,B)&&tb.newMorphing(g.key,A,B,d,250),e.activeTexture.set(f.TEXTURE0),v.texture.bind(f.LINEAR,f.CLAMP_TO_EDGE);const t=tb.getMorphValuesForProxy(g.key),F=t?1:0,C={};t&&a.extend$1(C,{morphing:{srcDemTile:t.from,dstDemTile:t.to,phase:a.easeCubicInOut(t.phase)}});const G=a.globeMatrixForTile(g.canonical,p),H=rb(c.projMatrix,G,q,a.globeToMercatorTransition(c.zoom),r);if(m(F,u),h.setupElevationDraw(v,k,C),b.prepareDrawProgram(e,k,g.toUnwrapped()),s){const[I,J]=u?s.getWirefameBuffer(b.context):[s.gridIndexBuffer,s.gridSegments];k.draw(e,x,o,z,n,a.CullFaceMode.backCCW,H,"globe_raster",D,I,J)}if(!u){const K=[0===g.canonical.y?a.globePoleMatrixForTile(g.canonical,!1,c):null,g.canonical.y===y-1?a.globePoleMatrixForTile(g.canonical,!0,c):null];for(const w of K){if(!w)continue;const L=rb(c.projMatrix,w,w,0,r);s&&k.draw(e,x,o,z,n,a.CullFaceMode.disabled,L,"globe_pole_raster",E,s.poleIndexBuffer,s.poleSegments)}}}})}(b,c,e,f,d);else{const g=b.context,h=g.gl;let k,l;const i=b.options.showTerrainWireframe?2:0,m=(a,d)=>{if(l===a)return;const c=[ub[a]];d&&c.push(ub[i]),k=b.useProgram("terrainRaster",null,c),l=a},n=b.colorModeForRenderPass(),o=new a.DepthMode(h.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);tb.update(d);const j=b.transform,p=6*Math.pow(1.5,22-j.zoom)*c.exaggeration();(i?[!1,!0]:[!1]).forEach(r=>{l=-1;const w=r?h.LINES:h.TRIANGLES,[x,y]=r?c.getWirefameBuffer():[c.gridIndexBuffer,c.gridSegments];for(const i of f){const s=e.getTile(i),z=a.StencilMode.disabled,t=c.prevTerrainTileForTile[i.key],u=c.terrainTileForTile[i.key];sb(t,u)&&tb.newMorphing(i.key,t,u,d,250),g.activeTexture.set(h.TEXTURE0),s.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE,h.LINEAR_MIPMAP_NEAREST);const q=tb.getMorphValuesForProxy(i.key),A=q?1:0;let v;q&&(v={morphing:{srcDemTile:q.from,dstDemTile:q.to,phase:a.easeCubicInOut(q.phase)}});const B=qb(i.projMatrix,vb(i.canonical,j.renderWorldCopies)?p/10:p);m(A,r),c.setupElevationDraw(s,k,v),b.prepareDrawProgram(g,k,i.toUnwrapped()),k.draw(g,w,o,z,n,a.CullFaceMode.backCCW,B,"terrain_raster",c.gridBuffer,x,y)}})}})(c,this,this.proxySourceCache,b,this._updateTimestamp),this.renderingToTexture=!0,b.splice(0,b.length))}renderBatch(p){if(0===this._drapedRenderBatches.length)return p+1;this.renderingToTexture=!0;const c=this.painter,e=this.painter.context,f=this.proxySourceCache,s=this.proxiedCoords[f.id],k=this._drapedRenderBatches.shift(),h=[],t=c.style.order;let i=0;for(const g of s){const l=f.getTileByID(g.proxyTileKey),m=f.proxyCachedFBO[g.key]?f.proxyCachedFBO[g.key][p]:void 0,b=void 0!==m?f.renderCache[m]:this.pool[i++],q=void 0!==m;if(l.texture=b.tex,q&&!b.dirty){h.push(l.tileID);continue}let r;e.bindFramebuffer.set(b.fb.framebuffer),this.renderedToTile=!1,b.dirty&&(e.clear({color:a.Color.transparent,stencil:0}),b.dirty=!1);for(let n=k.start;n<=k.end;++n){const j=c.style._layers[t[n]];if(j.isHidden(c.transform.zoom))continue;const d=c.style._getLayerSourceCache(j),o=d?this.proxyToSource[g.key][d.id]:[g];if(!o)continue;const u=o;e.viewport.set([0,0,b.fb.width,b.fb.height]),r!==(d?d.id:null)&&(this._setupStencil(b,o,j,d),r=d?d.id:null),c.renderLayer(c,d,j,u)}this.renderedToTile?(b.dirty=!0,h.push(l.tileID)):q|| --i,5===i&&(i=0,this.renderToBackBuffer(h))}return this.renderToBackBuffer(h),this.renderingToTexture=!1,e.bindFramebuffer.set(null),e.viewport.set([0,0,c.width,c.height]),k.end+1}postRender(){}renderCacheEfficiency(a){const e=a.order.length;if(0===e)return{efficiency:100};let f,g=0,b=0,c=!1;for(let d=0;da.dem).forEach(b=>{a=Math.min(a,b.dem.tree.minimums[0])}),0===a?a:(a-30)*this._exaggeration}raycast(d,e,f){if(!this._visibleDemTiles)return null;const b=this._visibleDemTiles.filter(a=>a.dem).map(b=>{const c=b.tileID,a=Math.pow(2,c.overscaledZ),{x:g,y:h}=c.canonical,i=g/a,j=(g+1)/a,k=h/a,l=(h+1)/a;return{minx:i,miny:k,maxx:j,maxy:l,t:b.dem.tree.raycastRoot(i,k,j,l,d,e,f),tile:b}});for(const a of(b.sort((a,b)=>(null!==a.t?a.t:Number.MAX_VALUE)-(null!==b.t?b.t:Number.MAX_VALUE)),b)){if(null==a.t)return null;const c=a.tile.dem.tree.raycast(a.minx,a.miny,a.maxx,a.maxy,d,e,f);if(null!=c)return c}return null}_createFBO(){const b=this.painter.context,c=b.gl,d=this.drapeBufferSize;b.activeTexture.set(c.TEXTURE0);const f=new a.Texture(b,{width:d[0],height:d[1],data:null},c.RGBA);f.bind(c.LINEAR,c.CLAMP_TO_EDGE);const e=b.createFramebuffer(d[0],d[1],!1);return e.colorAttachment.set(f.texture),e.depthAttachment=new Z(b,e.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=b.createRenderbuffer(b.gl.DEPTH_STENCIL,d[0],d[1]),this._stencilRef=0,e.depthAttachment.set(this._sharedDepthStencil),b.clear({stencil:0})):e.depthAttachment.set(this._sharedDepthStencil),b.extTextureFilterAnisotropic&&!b.extTextureFilterAnisotropicForceOff&&c.texParameterf(c.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax),{fb:e,tex:f,dirty:!1}}_initFBOPool(){for(;this.pool.length{const a=this._style._layers[c],d=a.isHidden(this.painter.transform.zoom),b=a.getCrossfadeParameters(),e=!!b&&1!==b.t,f=a.hasTransition();return"custom"!==a.type&&!d&&(e||f)})}_clearRasterFadeFromRenderCache(){let e=!1;for(const h in this._style._sourceCaches)if(this._style._sourceCaches[h]._source instanceof r){e=!0;break}if(e)for(let c=0;ca.renderCachePool.length){const i=Object.values(a.proxyCachedFBO);a.proxyCachedFBO={};for(let e=0;e=0;g--){const b=f[g];if(a.getTileByID(b.key),void 0!==a.proxyCachedFBO[b.key]){const j=p[b.key],k=this.proxyToSource[b.key];let d=0;for(const l in k){const m=k[l],n=j[l];if(!n||n.length!==m.length||m.some((a,b)=>a!==n[b]||t[l]&&t[l].hasOwnProperty(a.key))){d=-1;break}++d}for(const r in a.proxyCachedFBO[b.key])a.renderCache[a.proxyCachedFBO[b.key][r]].dirty=d<0||d!==Object.values(j).length}}const o=[...this._drapedRenderBatches];for(const s of(o.sort((a,b)=>b.end-b.start-(a.end-a.start)),o))for(const h of f){if(a.proxyCachedFBO[h.key])continue;let c=a.renderCachePool.pop();void 0===c&&a.renderCache.length<50&&(c=a.renderCache.length,a.renderCache.push(this._createFBO())),void 0!==c&&(a.proxyCachedFBO[h.key]={},a.proxyCachedFBO[h.key][s.start]=c,a.renderCache[c].dirty=!0)}this._tilesDirty={}}_setupStencil(g,a,c,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const e=this.painter.context,f=e.gl;if(a.length<=1)return void(this._overlapStencilType=!1);let b;if(c.isTileClipped())b=a.length,this._overlapStencilMode.test={func:f.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(a[0].overscaledZ>a[a.length-1].overscaledZ))return void(this._overlapStencilType=!1);b=1,this._overlapStencilMode.test={func:f.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+b>255&&(e.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=b,this._overlapStencilMode.ref=this._stencilRef,c.isTileClipped()&&this._renderTileClippingMasks(a,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(b){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[b.key]),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(f,g){const b=this.painter,d=this.painter.context,c=d.gl;b._tileClippingMaskIDs={},d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);const h=b.useProgram("clippingMask");for(const e of f){const i=b._tileClippingMaskIDs[e.key]=--g;h.draw(d,c.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:c.ALWAYS,mask:0},i,255,c.KEEP,c.KEEP,c.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,wb(e.projMatrix),"$clipping",b.tileExtentBuffer,b.quadTriangleIndexBuffer,b.tileExtentSegments)}}pointCoordinate(e){const d=this.painter.transform;if(e.x<0||e.x>d.width||e.y<0||e.y>d.height)return null;const b=[e.x,e.y,1,1];a.transformMat4$1(b,b,d.pixelMatrixInverse),a.scale$1(b,b,1/b[3]),b[0]/=d.worldSize,b[1]/=d.worldSize;const g=d._camera.position,i=a.mercatorZfromAltitude(1,d.center.lat),c=[g[0],g[1],g[2]/i,0],f=a.subtract([],b.slice(0,3),c);a.normalize(f,f);const h=this.raycast(c,f,this._exaggeration);return null!==h&&h?(a.scaleAndAdd(c,c,f,h),c[3]=c[2],c[2]*=i,c):null}drawDepth(){const e=this.painter,b=e.context,i=this.proxySourceCache,c=Math.ceil(e.width),d=Math.ceil(e.height);if(this._depthFBO&&(this._depthFBO.width!==c||this._depthFBO.height!==d)&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const f=b.gl,g=b.createFramebuffer(c,d,!0);b.activeTexture.set(f.TEXTURE0);const h=new a.Texture(b,{width:c,height:d,data:null},f.RGBA);h.bind(f.NEAREST,f.CLAMP_TO_EDGE),g.colorAttachment.set(h.texture);const j=b.createRenderbuffer(b.gl.DEPTH_COMPONENT16,c,d);g.depthAttachment.set(j),this._depthFBO=g,this._depthTexture=h}b.bindFramebuffer.set(this._depthFBO.framebuffer),b.viewport.set([0,0,c,d]),(function(b,c,h,i){if("globe"===b.transform.projection.name)return;const d=b.context,e=d.gl;d.clear({depth:1});const f=b.useProgram("terrainDepth"),j=new a.DepthMode(e.LESS,a.DepthMode.ReadWrite,b.depthRangeFor3D);for(const g of i){const k=h.getTile(g),l=qb(g.projMatrix,0);c.setupElevationDraw(k,f),f.draw(d,e.TRIANGLES,j,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,l,"terrain_depth",c.gridBuffer,c.gridIndexBuffer,c.gridNoSkirtSegments)}})(e,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(a,f,c){if(a.getSource() instanceof s)return this._setupProxiedCoordsForImageSource(a,f,c);this._findCoveringTileCache[a.id]=this._findCoveringTileCache[a.id]||{};const k=this.proxiedCoords[a.id]=[],l=this.proxyCoords;for(let g=0;g(a.min.x=Math.min(a.min.x,b.x-o.x),a.min.y=Math.min(a.min.y,b.y-o.y),a.max.x=Math.max(a.max.x,b.x-o.x),a.max.y=Math.max(a.max.y,b.y-o.y),a),{min:new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),n=(b,c)=>{const d=b.wrap+b.canonical.x/(1<g+p.max.x||e+fh+p.max.y};for(let f=0;fa.key===c.tileID.key);if(j)return j}if(c.tileID.key!==b.key){const d=b.canonical.z-c.tileID.canonical.z;let f,g,h;e=a.create();const k=c.tileID.wrap-b.wrap<0?(g=(f=a.EXTENT>>d)*((c.tileID.canonical.x<=g){const h=c.canonical.z-g;d.getSource().reparseOverscaled?(e=Math.max(c.canonical.z+2,d.transform.tileZoom),f=new a.OverscaledTileID(e,c.wrap,g,c.canonical.x>>h,c.canonical.y>>h)):0!==h&&(e=g,f=new a.OverscaledTileID(e,c.wrap,g,c.canonical.x>>h,c.canonical.y>>h))}f.key!==c.key&&(m.push(f.key),b=d.getTile(f))}const n=a=>{m.forEach(b=>{l[b]=a}),m.length=0};for(e-=1;e>=o&&(!b||!b.hasData());e--){b&&n(b.tileID.key);const j=f.calculateScaledKey(e);if((b=d.getTileByID(j))&&b.hasData())break;const k=l[j];if(null===k)break;void 0===k?m.push(j):b=d.getTileByID(k)}return n(b?b.tileID.key:null),b&&b.hasData()?b:null}findDEMTileFor(a){return this.enabled?this._findTileCoveringTileID(a,this.sourceCache):null}prepareDrawTile(a){this.renderedToTile=!0}_clearRenderCacheForTile(b,c){let a=this._tilesDirty[b];a||(a=this._tilesDirty[b]={}),a[c.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const b=function(g){let f,e,b;const c=new a.StructArrayLayout2ui4,d=131;for(e=1;e<129;e++){for(f=1;f<129;f++)b=e*d+f,c.emplaceBack(b,b+1),c.emplaceBack(b,b+d),c.emplaceBack(b+1,b+d),128===e&&c.emplaceBack(b+d,b+d+1);c.emplaceBack(b+1,b+1+d)}return c}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(b),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,b.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function Cb(b){const c=[];for(let a=0;am.indexOf(t)&&m.push(t);let n=e?e.defines():[];n=n.concat(r.map(a=>`#define ${a}`));const D=n.concat("\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",jb,ib.fragmentSource,v.fragmentSource,k.fragmentSource).join("\n"),E=n.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",jb,ib.vertexSource,v.vertexSource,u.vertexSource,k.vertexSource).join("\n"),o=d.createShader(d.FRAGMENT_SHADER);if(d.isContextLost())return void(this.failedToCreate=!0);d.shaderSource(o,D),d.compileShader(o),d.attachShader(this.program,o);const p=d.createShader(d.VERTEX_SHADER);if(d.isContextLost())return void(this.failedToCreate=!0);d.shaderSource(p,E),d.compileShader(p),d.attachShader(this.program,p),this.attributes={};const i={};this.numAttributes=l.length;for(let f=0;f>16,g>>16],u_pixel_coord_lower:[65535&f,65535&g]}}const Fb=(h,f,i,j)=>{const b=f.style.light,c=b.properties.get("position"),d=[c.x,c.y,c.z],g=a.create$1();"viewport"===b.properties.get("anchor")&&(a.fromRotation(g,-f.transform.angle),a.transformMat3(d,d,g));const e=b.properties.get("color");return{u_matrix:h,u_lightpos:d,u_lightintensity:b.properties.get("intensity"),u_lightcolor:[e.r,e.g,e.b],u_vertical_gradient:+i,u_opacity:j}},Gb=(d,b,e,f,g,h,c)=>a.extend(Fb(d,b,e,f),Eb(h,b,c),{u_height_factor:-Math.pow(2,g.overscaledZ)/c.tileSize/8}),Hb=a=>({u_matrix:a}),Ib=(b,c,d,e)=>a.extend(Hb(b),Eb(d,c,e)),Jb=(a,b)=>({u_matrix:a,u_world:b}),Kb=(b,c,d,e,f)=>a.extend(Ib(b,c,d,e),{u_world:f}),Lb=(d,g,e,c)=>{const b=d.transform;let f;return f="map"===c.paint.get("circle-pitch-alignment")?b.calculatePixelsToTileUnitsMatrix(e):new Float32Array([b.pixelsToGLUnits[0],0,0,b.pixelsToGLUnits[1]]),{u_camera_to_center_distance:b.cameraToCenterDistance,u_matrix:d.translatePosMatrix(g.projMatrix,e,c.paint.get("circle-translate"),c.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:f}},Mb=b=>{const a=[];return"map"===b.paint.get("circle-pitch-alignment")&&a.push("PITCH_WITH_MAP"),"map"===b.paint.get("circle-pitch-scale")&&a.push("SCALE_WITH_MAP"),a},Nb=(d,b,e)=>{const c=a.EXTENT/e.tileSize;return{u_matrix:d,u_camera_to_center_distance:b.cameraToCenterDistance,u_extrude_scale:[b.pixelsToGLUnits[0]/c,b.pixelsToGLUnits[1]/c]}},Ob=(a,b,c=1)=>({u_matrix:a,u_color:b,u_overlay:0,u_overlay_scale:c}),Pb=(a,b,c,d)=>({u_matrix:a,u_extrude_scale:V(b,1,c),u_intensity:d}),Qb=(d,b,g,e,h,i)=>{const f=d.transform,j=f.calculatePixelsToTileUnitsMatrix(b),c={u_matrix:Tb(d,b,g,h),u_pixels_to_tile_units:j,u_device_pixel_ratio:a.exported.devicePixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(Ub(g)){const k=Sb(b,d.transform);c.u_texsize=b.lineAtlasTexture.size,c.u_scale=[k,e.fromScale,e.toScale],c.u_mix=e.t}return c},Rb=(e,b,f,d,g)=>{const c=e.transform,h=Sb(b,c);return{u_matrix:Tb(e,b,f,g),u_texsize:b.imageAtlasTexture.size,u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(b),u_device_pixel_ratio:a.exported.devicePixelRatio,u_image:0,u_scale:[h,d.fromScale,d.toScale],u_fade:d.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Sb(a,b){return 1/V(a,1,b.tileZoom)}function Tb(c,a,b,d){return c.translatePosMatrix(d||a.tileID.projMatrix,a,b.paint.get("line-translate"),b.paint.get("line-translate-anchor"))}function Ub(b){const a=b.paint.get("line-dasharray").value;return a.value||"constant"!==a.kind}const Vb=(e,f,g,d,a,h)=>{var b,c;return{u_matrix:e,u_tl_parent:f,u_scale_parent:g,u_fade_t:d.mix,u_opacity:d.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(c=a.paint.get("raster-saturation"))>0?1-1/(1.001-c):-c,u_contrast_factor:(b=a.paint.get("raster-contrast"))>0?1/(1-b):1+b,u_spin_weights:Wb(a.paint.get("raster-hue-rotate")),u_perspective_transform:h}};function Wb(a){a*=Math.PI/180;const c=Math.sin(a),b=Math.cos(a);return[(2*b+1)/3,(-Math.sqrt(3)*c-b+1)/3,(Math.sqrt(3)*c-b+1)/3]}const Xb=(a,b,e,f,d,g,h,i,j,k,l,m,n,o)=>{const c=d.transform;return{u_is_size_zoom_constant:+("constant"===a||"source"===a),u_is_size_feature_constant:+("constant"===a||"camera"===a),u_size_t:b?b.uSizeT:0,u_size:b?b.uSize:0,u_camera_to_center_distance:c.cameraToCenterDistance,u_pitch:c.pitch/360*2*Math.PI,u_rotate_symbol:+e,u_aspect_ratio:c.width/c.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:h,u_coord_matrix:i,u_is_text:+j,u_pitch_with_map:+f,u_texsize:k,u_tile_id:l,u_zoom_transition:m,u_inv_rot_matrix:n,u_merc_center:o,u_texture:0}},Yb=(d,e,f,c,b,g,h,i,j,k,l,m,n,o,p)=>{const{cameraToCenterDistance:q,_pitch:r}=b.transform;return a.extend(Xb(d,e,f,c,b,g,h,i,j,k,m,n,o,p),{u_gamma_scale:c?q*Math.cos(b.terrain?0:r):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+l})},Zb=(b,c,d,e,f,g,h,i,j,k,l,m,n,o)=>a.extend(Yb(b,c,d,e,f,g,h,i,!0,j,!0,l,m,n,o),{u_texsize_icon:k,u_texture_icon:1}),$b=(a,b,c)=>({u_matrix:a,u_opacity:b,u_color:c}),_b=(b,c,d,e,f,g)=>a.extend(function(f,c,b,a){const d=b.imageManager.getPattern(f.from.toString()),e=b.imageManager.getPattern(f.to.toString()),{width:k,height:l}=b.imageManager.getPixelSize(),g=Math.pow(2,a.tileID.overscaledZ),h=a.tileSize*Math.pow(2,b.transform.tileZoom)/g,i=h*(a.tileID.canonical.x+a.tileID.wrap*g),j=h*a.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:d.tl,u_pattern_br_a:d.br,u_pattern_tl_b:e.tl,u_pattern_br_b:e.br,u_texsize:[k,l],u_mix:c.t,u_pattern_size_a:d.displaySize,u_pattern_size_b:e.displaySize,u_scale_a:c.fromScale,u_scale_b:c.toScale,u_tile_units_to_pixels:1/V(a,1,b.transform.tileZoom),u_pixel_coord_upper:[i>>16,j>>16],u_pixel_coord_lower:[65535&i,65535&j]}}(e,g,d,f),{u_matrix:b,u_opacity:c}),ac={fillExtrusion:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fillExtrusionPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_height_factor:new a.Uniform1f(b,c.u_height_factor),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fill:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),fillPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),fillOutline:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world)}),fillOutlinePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),circle:(b,c)=>({u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.UniformMatrix2f(b,c.u_extrude_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),collisionBox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.Uniform2f(b,c.u_extrude_scale)}),collisionCircle:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_inv_matrix:new a.UniformMatrix4f(b,c.u_inv_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_viewport_size:new a.Uniform2f(b,c.u_viewport_size)}),debug:(b,c)=>({u_color:new a.UniformColor(b,c.u_color),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_overlay:new a.Uniform1i(b,c.u_overlay),u_overlay_scale:new a.Uniform1f(b,c.u_overlay_scale)}),clippingMask:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmap:(b,c)=>({u_extrude_scale:new a.Uniform1f(b,c.u_extrude_scale),u_intensity:new a.Uniform1f(b,c.u_intensity),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmapTexture:(b,c)=>({u_image:new a.Uniform1i(b,c.u_image),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_opacity:new a.Uniform1f(b,c.u_opacity)}),hillshade:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_latrange:new a.Uniform2f(b,c.u_latrange),u_light:new a.Uniform2f(b,c.u_light),u_shadow:new a.UniformColor(b,c.u_shadow),u_highlight:new a.UniformColor(b,c.u_highlight),u_accent:new a.UniformColor(b,c.u_accent)}),hillshadePrepare:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_dimension:new a.Uniform2f(b,c.u_dimension),u_zoom:new a.Uniform1f(b,c.u_zoom),u_unpack:new a.Uniform4f(b,c.u_unpack)}),line:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_dash_image:new a.Uniform1i(b,c.u_dash_image),u_gradient_image:new a.Uniform1i(b,c.u_gradient_image),u_image_height:new a.Uniform1f(b,c.u_image_height),u_texsize:new a.Uniform2f(b,c.u_texsize),u_scale:new a.Uniform3f(b,c.u_scale),u_mix:new a.Uniform1f(b,c.u_mix),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),linePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_image:new a.Uniform1i(b,c.u_image),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),raster:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_tl_parent:new a.Uniform2f(b,c.u_tl_parent),u_scale_parent:new a.Uniform1f(b,c.u_scale_parent),u_fade_t:new a.Uniform1f(b,c.u_fade_t),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image0:new a.Uniform1i(b,c.u_image0),u_image1:new a.Uniform1i(b,c.u_image1),u_brightness_low:new a.Uniform1f(b,c.u_brightness_low),u_brightness_high:new a.Uniform1f(b,c.u_brightness_high),u_saturation_factor:new a.Uniform1f(b,c.u_saturation_factor),u_contrast_factor:new a.Uniform1f(b,c.u_contrast_factor),u_spin_weights:new a.Uniform3f(b,c.u_spin_weights),u_perspective_transform:new a.Uniform2f(b,c.u_perspective_transform)}),symbolIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_texture:new a.Uniform1i(b,c.u_texture)}),symbolSDF:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texture:new a.Uniform1i(b,c.u_texture),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),symbolTextAndIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texsize_icon:new a.Uniform2f(b,c.u_texsize_icon),u_texture:new a.Uniform1i(b,c.u_texture),u_texture_icon:new a.Uniform1i(b,c.u_texture_icon),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),background:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_color:new a.UniformColor(b,c.u_color)}),backgroundPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image:new a.Uniform1i(b,c.u_image),u_pattern_tl_a:new a.Uniform2f(b,c.u_pattern_tl_a),u_pattern_br_a:new a.Uniform2f(b,c.u_pattern_br_a),u_pattern_tl_b:new a.Uniform2f(b,c.u_pattern_tl_b),u_pattern_br_b:new a.Uniform2f(b,c.u_pattern_br_b),u_texsize:new a.Uniform2f(b,c.u_texsize),u_mix:new a.Uniform1f(b,c.u_mix),u_pattern_size_a:new a.Uniform2f(b,c.u_pattern_size_a),u_pattern_size_b:new a.Uniform2f(b,c.u_pattern_size_b),u_scale_a:new a.Uniform1f(b,c.u_scale_a),u_scale_b:new a.Uniform1f(b,c.u_scale_b),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_tile_units_to_pixels:new a.Uniform1f(b,c.u_tile_units_to_pixels)}),terrainRaster:k,terrainDepth:k,skybox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_cubemap:new a.Uniform1i(b,c.u_cubemap),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxGradient:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_center_direction:new a.Uniform3f(b,c.u_center_direction),u_radius:new a.Uniform1f(b,c.u_radius),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxCapture:(b,c)=>({u_matrix_3f:new a.UniformMatrix3f(b,c.u_matrix_3f),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_sun_intensity:new a.Uniform1f(b,c.u_sun_intensity),u_color_tint_r:new a.Uniform4f(b,c.u_color_tint_r),u_color_tint_m:new a.Uniform4f(b,c.u_color_tint_m),u_luminance:new a.Uniform1f(b,c.u_luminance)}),globeRaster:(b,c)=>({u_proj_matrix:new a.UniformMatrix4f(b,c.u_proj_matrix),u_globe_matrix:new a.UniformMatrix4f(b,c.u_globe_matrix),u_merc_matrix:new a.UniformMatrix4f(b,c.u_merc_matrix),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_image0:new a.Uniform1i(b,c.u_image0)}),globeAtmosphere:(b,c)=>({u_center:new a.Uniform2f(b,c.u_center),u_radius:new a.Uniform1f(b,c.u_radius),u_screen_size:new a.Uniform2f(b,c.u_screen_size),u_pixel_ratio:new a.Uniform1f(b,c.u_pixel_ratio),u_opacity:new a.Uniform1f(b,c.u_opacity),u_fadeout_range:new a.Uniform1f(b,c.u_fadeout_range),u_start_color:new a.Uniform3f(b,c.u_start_color),u_end_color:new a.Uniform3f(b,c.u_end_color)})};let bc;function cc(b,H,s,A,t,I,B){var u;const f=b.context,C=f.gl,D=b.useProgram("collisionBox"),j=[];let g=0,E=0;for(let v=0;v0){const l=a.create(),J=x;a.mul(l,d.placementInvProjMatrix,b.transform.glCoordMatrix),a.mul(l,l,d.placementViewportMatrix),j.push({circleArray:y,circleOffset:E,transform:J,invTransform:l}),g+=y.length/4,E=g}e&&(b.terrain&&b.terrain.setupElevationDraw(k,D),D.draw(f,C.LINES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,Nb(x,b.transform,k),s.id,e.layoutVertexBuffer,e.indexBuffer,e.segments,null,b.transform.zoom,null,e.collisionVertexBuffer,e.collisionVertexBufferExt))}if(!B||!j.length)return;const K=b.useProgram("collisionCircle"),c=new a.StructArrayLayout2f1f2i16;c.resize(4*g),c._trim();let m=0;for(const h of j)for(let z=0;z[0,0,0];e.clear();for(let j=0;j=0&&(r[b.associatedIconIndex]={shiftedAnchor:x,angle:y})}else Oa(b.numGlyphs,e)}if(p){d.clear();const A=c.icon.placedSymbolArray;for(let f=0;f[0,0,0];Ga(d,g.projMatrix,b,i,C,W,j,da,ma,g)}const D=b.translatePosMatrix(g.projMatrix,e,J,K),E=n||i&&Q||la?dc:C,F=b.translatePosMatrix(W,e,J,K,!0),na=o&&0!==h.paint.get(i?"text-halo-width":"icon-halo-width").constantOr(1);let Y;const G=N.createInversionMatrix(g.toUnwrapped());Y=o?d.iconsInText?Zb(m.kind,y,u,j,b,D,E,F,p,T,z,x,G,v):Yb(m.kind,y,u,j,b,D,E,F,i,p,!0,z,x,G,v):Xb(m.kind,y,u,j,b,D,E,F,i,p,z,x,G,v);const Z={program:ga,buffers:l,uniformValues:Y,atlasTexture:A,atlasTextureIcon:U,atlasInterpolation:B,atlasInterpolationIcon:S,isSDF:o,hasHalo:na,tile:e,labelPlaneMatrixInv:ja};if(ea&&d.canOverlap){O=!0;const oa=l.segments.get();for(const $ of oa)r.push({segments:new a.SegmentVector([$]),sortKey:$.sortKey,state:Z})}else r.push({segments:l.segments,sortKey:0,state:Z})}for(const H of(O&&r.sort((a,b)=>a.sortKey-b.sortKey),r)){const c=H.state;if(b.terrain&&b.terrain.setupElevationDraw(c.tile,c.program,{useDepthForOcclusion:!w,labelPlaneMatrixInv:c.labelPlaneMatrixInv}),t.activeTexture.set(k.TEXTURE0),c.atlasTexture.bind(c.atlasInterpolation,k.CLAMP_TO_EDGE),c.atlasTextureIcon&&(t.activeTexture.set(k.TEXTURE1),c.atlasTextureIcon&&c.atlasTextureIcon.bind(c.atlasInterpolationIcon,k.CLAMP_TO_EDGE)),c.isSDF){const I=c.uniformValues;c.hasHalo&&(I.u_is_halo=1,ic(c.buffers,H.segments,h,b,c.program,P,L,M,I)),I.u_is_halo=0}ic(c.buffers,H.segments,h,b,c.program,P,L,M,c.uniformValues)}}function ic(b,f,c,d,g,h,i,j,k){const e=d.context;g.draw(e,e.gl.TRIANGLES,h,i,j,a.CullFaceMode.disabled,k,c.id,b.layoutVertexBuffer,b.indexBuffer,f,c.paint,d.transform.zoom,b.programConfigurations.get(c.id),b.dynamicLayoutVertexBuffer,b.opacityVertexBuffer)}function jc(b,y,c,z,A,B,s){const e=b.context.gl,l=c.paint.get("fill-pattern"),g=l&&l.constantOr(1),m=c.getCrossfadeParameters();let n,i,o,p,q;for(const h of(s?(i=g&&!c.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",n=e.LINES):(i=g?"fillPattern":"fill",n=e.TRIANGLES),z)){const d=y.getTile(h);if(g&&!d.patternsLoaded())continue;const f=d.getBucket(c);if(!f)continue;b.prepareDrawTile(h);const j=f.programConfigurations.get(c.id),t=b.useProgram(i,j);g&&(b.context.activeTexture.set(e.TEXTURE0),d.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),j.updatePaintBuffers(m));const r=l.constantOr(null);if(r&&d.imageAtlas){const u=d.imageAtlas,v=u.patternPositions[r.to.toString()],w=u.patternPositions[r.from.toString()];v&&w&&j.setConstantPatternPositions(v,w)}const k=b.translatePosMatrix(h.projMatrix,d,c.paint.get("fill-translate"),c.paint.get("fill-translate-anchor"));if(s){p=f.indexBuffer2,q=f.segments2;const x=b.terrain&&b.terrain.renderingToTexture?b.terrain.drapeBufferSize:[e.drawingBufferWidth,e.drawingBufferHeight];o="fillOutlinePattern"===i&&g?Kb(k,b,m,d,x):Jb(k,x)}else p=f.indexBuffer,q=f.segments,o=g?Ib(k,b,m,d):Hb(k);b.prepareDrawProgram(b.context,t,h.toUnwrapped()),t.draw(b.context,n,A,b.stencilModeForClipping(h),B,a.CullFaceMode.disabled,o,c.id,f.layoutVertexBuffer,p,q,c.paint,b.transform.zoom,j)}}function kc(b,m,c,x,y,z,A){const f=b.context,h=f.gl,n=c.paint.get("fill-extrusion-pattern"),k=n.constantOr(1),o=c.getCrossfadeParameters(),p=c.paint.get("fill-extrusion-opacity");for(const g of x){const e=m.getTile(g),d=e.getBucket(c);if(!d)continue;const i=d.programConfigurations.get(c.id),j=b.useProgram(k?"fillExtrusionPattern":"fillExtrusion",i);if(b.terrain){const q=b.terrain;if(!d.enableTerrain)continue;if(q.setupElevationDraw(e,j,{useMeterToDem:!0}),lc(f,m,g,d,c,q),!d.centroidVertexBuffer){const r=j.attributes.a_centroid_pos;void 0!==r&&h.vertexAttrib2f(r,0,0)}}k&&(b.context.activeTexture.set(h.TEXTURE0),e.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),i.updatePaintBuffers(o));const l=n.constantOr(null);if(l&&e.imageAtlas){const s=e.imageAtlas,t=s.patternPositions[l.to.toString()],u=s.patternPositions[l.from.toString()];t&&u&&i.setConstantPatternPositions(t,u)}const v=b.translatePosMatrix(g.projMatrix,e,c.paint.get("fill-extrusion-translate"),c.paint.get("fill-extrusion-translate-anchor")),w=c.paint.get("fill-extrusion-vertical-gradient"),B=k?Gb(v,b,w,p,g,o,e):Fb(v,b,w,p);b.prepareDrawProgram(f,j,g.toUnwrapped()),j.draw(f,f.gl.TRIANGLES,y,z,A,a.CullFaceMode.backCCW,B,c.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,c.paint,b.transform.zoom,i,b.terrain?d.centroidVertexBuffer:null)}}function lc(w,D,p,c,E,q){const x=[b=>{let c=b.canonical.x-1,d=b.wrap;return c<0&&(c=(1<{let c=b.canonical.x+1,d=b.wrap;return c===1<new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,(0===b.canonical.y?1<new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,b.canonical.y===(1<{const b=D.getSource().maxzoom,c=b=>{const a=D.getTileByID(b);if(a&&a.hasData())return a.getBucket(E)};let d,e,f;return(a.overscaledZ===a.canonical.z||a.overscaledZ>=b)&&(d=c(a.key)),a.overscaledZ>=b&&(e=c(a.calculateScaledKey(a.overscaledZ+1))),a.overscaledZ>b&&(f=c(a.calculateScaledKey(a.overscaledZ-1))),d||e||f},F=[0,0,0],G=(b,c)=>(F[0]=Math.min(b.min.y,c.min.y),F[1]=Math.max(b.max.y,c.max.y),F[2]=a.EXTENT-c.min.x>b.max.x?c.min.x-a.EXTENT:b.max.x,F),H=(b,c)=>(F[0]=Math.min(b.min.x,c.min.x),F[1]=Math.max(b.max.x,c.max.x),F[2]=a.EXTENT-c.min.y>b.max.y?c.min.y-a.EXTENT:b.max.y,F),z=[(a,b)=>G(a,b),(a,b)=>G(b,a),(a,b)=>H(a,b),(a,b)=>H(b,a)],j=new a.pointGeometry(0,0);let r,s,A;const B=(e,f,b,c,d)=>{const g=[[c?b:e,c?e:b,0],[c?b:f,c?f:b,0]],i=d<0?a.EXTENT+d:d,h=[c?i:(e+f)/2,c?(e+f)/2:i,0];return 0===b&&d<0||0!==b&&d>0?q.getForTilePoints(A,[h],!0,s):g.push(h),q.getForTilePoints(p,g,!0,r),Math.max(g[0][2],g[1][2],h[2])/q.exaggeration()};for(let d=0;d<4;d++){const k=c.borders[d];if(0===k.length&&(c.borderDone[d]=!0),c.borderDone[d])continue;const t=A=x[d](p),b=y(t);if(!b||!b.enableTerrain)continue;if(!(s=q.findDEMTileFor(t))||!s.dem)continue;if(!r){const l=q.findDEMTileFor(p);if(!l||!l.dem)return;r=l}const f=(d<2?1:5)-d,h=b.borders[f];let g=0;for(let m=0;mu[0]+3);)b.borderDone[f]||b.encodeCentroid(void 0,e,!1),g++;if(e&&gu[1]-3)&&(n++,++g!==h.length);)e=b.featuresOnBorder[h[g]];if(e=b.featuresOnBorder[h[v]],i.intersectsCount()>1||e.intersectsCount()>1||1!==n){1!==n&&(g=v),c.encodeCentroid(void 0,i,!1),b.borderDone[f]||b.encodeCentroid(void 0,e,!1);continue}const o=z[d](i,e),C=d%2?a.EXTENT-1:0;j.x=B(o[0],Math.min(a.EXTENT-1,o[1]),C,d<2,o[2]),j.y=0,c.encodeCentroid(j,i,!1),b.borderDone[f]||b.encodeCentroid(j,e,!1)}else c.encodeCentroid(void 0,i,!1)}c.borderDone[d]=c.needsCentroidUpdate=!0,b.borderDone[f]||(b.borderDone[f]=b.needsCentroidUpdate=!0)}(c.needsCentroidUpdate|| !c.centroidVertexBuffer&&0!==c.centroidVertexArray.length)&&c.uploadCentroid(w)}const mc=new a.Color(1,0,0,1),nc=new a.Color(0,1,0,1),oc=new a.Color(0,0,1,1),pc=new a.Color(1,0,1,1),qc=new a.Color(0,1,1,1);function rc(a,c,b,d){tc(a,0,c+b/2,a.transform.width,b,d)}function sc(a,c,b,d){tc(a,c-b/2,0,b,a.transform.height,d)}function tc(d,e,f,g,h,i){const c=d.context,b=c.gl;b.enable(b.SCISSOR_TEST),b.scissor(e*a.exported.devicePixelRatio,f*a.exported.devicePixelRatio,g*a.exported.devicePixelRatio,h*a.exported.devicePixelRatio),c.clear({color:i}),b.disable(b.SCISSOR_TEST)}function uc(b,h,c){const f=b.context,e=f.gl,i=c.projMatrix,g=b.useProgram("debug"),d=h.getTileByID(c.key);b.terrain&&b.terrain.setupElevationDraw(d,g);const j=a.DepthMode.disabled,k=a.StencilMode.disabled,o=b.colorModeForRenderPass(),l="$debug";f.activeTexture.set(e.TEXTURE0),b.emptyTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),d._makeDebugTileBoundsBuffers(b.context,b.transform.projection);const p=d._tileDebugBuffer||b.debugBuffer,q=d._tileDebugIndexBuffer||b.debugIndexBuffer,r=d._tileDebugSegments||b.debugSegments;g.draw(f,e.LINE_STRIP,j,k,o,a.CullFaceMode.disabled,Ob(i,a.Color.red),l,p,q,r);const m=d.latestRawTileData,s=Math.floor((m&&m.byteLength||0)/1024),t=h.getTile(c).tileSize,u=512/Math.min(t,512)*(c.overscaledZ/b.transform.zoom)*.5;let n=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(n+=` => ${c.overscaledZ}`),(function(b,d){b.initDebugOverlayCanvas();const c=b.debugOverlayCanvas,e=b.context.gl,a=b.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,c.width,c.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(d,5,5),a.strokeText(d,5,5),b.debugOverlayTexture.update(c),b.debugOverlayTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)})(b,`${n} ${s}kb`),g.draw(f,e.TRIANGLES,j,k,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,Ob(i,a.Color.transparent,u),l,b.debugBuffer,b.quadTriangleIndexBuffer,b.debugSegments)}const w=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:vc}=w;function wc(a,b,c,d){a.emplaceBack(b,c,d)}class xc{constructor(b){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,wc(this.vertexArray,-1,-1,1),wc(this.vertexArray,1,-1,1),wc(this.vertexArray,-1,1,1),wc(this.vertexArray,1,1,1),wc(this.vertexArray,-1,-1,-1),wc(this.vertexArray,1,-1,-1),wc(this.vertexArray,-1,1,-1),wc(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=b.createVertexBuffer(this.vertexArray,vc),this.indexBuffer=b.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function yc(f,b,j,k,l,m){var g,h,i,c,d;const e=f.gl,n=b.paint.get("sky-atmosphere-color"),o=b.paint.get("sky-atmosphere-halo-color"),p=b.paint.get("sky-atmosphere-sun-intensity"),q=(g=a.fromMat4([],k),h=l,i=p,c=n,d=o,{u_matrix_3f:g,u_sun_direction:h,u_sun_intensity:i,u_color_tint_r:[c.r,c.g,c.b,c.a],u_color_tint_m:[d.r,d.g,d.b,d.a],u_luminance:5e-5});e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+m,b.skyboxTexture,0),j.draw(f,e.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,q,"skyboxCapture",b.skyboxGeometry.vertexBuffer,b.skyboxGeometry.indexBuffer,b.skyboxGeometry.segment)}const zc={symbol:function(c,d,b,e,h){if("translucent"!==c.renderPass)return;const f=a.StencilMode.disabled,g=c.colorModeForRenderPass();b.layout.get("text-variable-anchor")&&(function(k,e,g,l,m,n,o){const b=e.transform,h="map"===m,i="map"===n,p=b.projection.createTileTransform(b,b.worldSize);for(const f of k){const d=l.getTile(f),c=d.getBucket(g);if(!c||c.projection!==b.projection.name||!c.text||!c.text.segments.get().length)continue;const j=a.evaluateSizeForZoom(c.textSizeData,b.zoom),q=e.transform.calculatePixelsToTileUnitsMatrix(d),r=Ba(f.projMatrix,d.tileID.canonical,i,h,e.transform,q),s="none"!==g.layout.get("icon-text-fit")&&c.hasIconData();if(j){const t=Math.pow(2,b.zoom-d.tileID.overscaledZ);fc(c,h,i,o,a.symbolSize,b,r,f,t,j,s,p)}}})(e,c,b,d,b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),h),0!==b.paint.get("icon-opacity").constantOr(1)&&hc(c,d,b,e,!1,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),b.layout.get("icon-rotation-alignment"),b.layout.get("icon-pitch-alignment"),b.layout.get("icon-keep-upright"),f,g),0!==b.paint.get("text-opacity").constantOr(1)&&hc(c,d,b,e,!0,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),b.layout.get("text-keep-upright"),f,g),d.map.showCollisionBoxes&&(cc(c,d,b,e,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),!0),cc(c,d,b,e,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),!1))},circle:function(b,r,c,j){if("translucent"!==b.renderPass)return;const s=c.paint.get("circle-opacity"),t=c.paint.get("circle-stroke-width"),u=c.paint.get("circle-stroke-opacity"),k=void 0!==c.layout.get("circle-sort-key").constantOr(1);if(0===s.constantOr(1)&&(0===t.constantOr(1)||0===u.constantOr(1)))return;const f=b.context,v=f.gl,w=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),x=a.StencilMode.disabled,y=b.colorModeForRenderPass(),e=[];for(let g=0;ga.sortKey-b.sortKey);const B={useDepthForOcclusion:"globe"!==b.transform.projection.name};for(const p of e){const{programConfiguration:C,program:i,layoutVertexBuffer:D,indexBuffer:E,uniformValues:F,tile:q}=p.state,G=p.segments;b.terrain&&b.terrain.setupElevationDraw(q,i,B),b.prepareDrawProgram(f,i,q.tileID.toUnwrapped()),i.draw(f,v.TRIANGLES,w,x,y,a.CullFaceMode.disabled,F,c.id,D,E,G,c.paint,b.transform.zoom,C)}},heatmap:function(b,k,c,l){if(0!==c.paint.get("heatmap-opacity"))if("offscreen"===b.renderPass){const d=b.context,g=d.gl,n=a.StencilMode.disabled,o=new a.ColorMode([g.ONE,g.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(b,c,e){const a=b.gl;b.activeTexture.set(a.TEXTURE1),b.viewport.set([0,0,c.width/4,c.height/4]);let d=e.heatmapFbo;if(d)a.bindTexture(a.TEXTURE_2D,d.colorAttachment.get()),b.bindFramebuffer.set(d.framebuffer);else{const f=a.createTexture();a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),d=e.heatmapFbo=b.createFramebuffer(c.width/4,c.height/4,!1),(function(b,c,d,e){const a=b.gl;a.texImage2D(a.TEXTURE_2D,0,a.RGBA,c.width/4,c.height/4,0,a.RGBA,b.extRenderToTextureHalfFloat?b.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),e.colorAttachment.set(d)})(b,c,f,d)}})(d,b,c),d.clear({color:a.Color.transparent});for(let h=0;h{const b=[];Ub(a)&&b.push("RENDER_LINE_DASH"),a.paint.get("line-gradient")&&b.push("RENDER_LINE_GRADIENT");const c=a.paint.get("line-pattern").constantOr(1),d=1!==a.paint.get("line-opacity").constantOr(1);return!c&&d&&b.push("RENDER_LINE_ALPHA_DISCARD"),b})(c);let m=v.includes("RENDER_LINE_ALPHA_DISCARD");for(const h of(b.terrain&&b.terrain.clipOrMaskOverlapStencilType()&&(m=!1),H)){const f=s.getTile(h);if(j&&!f.patternsLoaded())continue;const i=f.getBucket(c);if(!i)continue;b.prepareDrawTile(h);const k=i.programConfigurations.get(c.id),O=b.useProgram(N,k,v),n=u.constantOr(null);if(n&&f.imageAtlas){const w=f.imageAtlas,x=w.patternPositions[n.to.toString()],y=w.patternPositions[n.from.toString()];x&&y&&k.setConstantPatternPositions(x,y)}const o=t.constantOr(null),p=L.constantOr(null);if(!j&&o&&p&&f.lineAtlas){const z=f.lineAtlas,A=z.getDash(o.to,p),B=z.getDash(o.from,p);A&&B&&k.setConstantPatternPositions(A,B)}const C=b.terrain?h.projMatrix:null,D=j?Rb(b,f,c,l,C):Qb(b,f,c,l,C,i.lineClipsArray.length);if(M){const e=i.gradients[c.id];let E=e.texture;if(c.gradientVersion!==e.version){let F=256;if(c.stepInterpolant){const P=s.getSource().maxzoom,Q=h.canonical.z===P?Math.ceil(1<{O.draw(g,d.TRIANGLES,R,e,S,a.CullFaceMode.disabled,D,c.id,i.layoutVertexBuffer,i.indexBuffer,i.segments,c.paint,b.transform.zoom,k,i.layoutVertexBuffer2)};if(m){const r=b.stencilModeForClipping(h).ref;0===r&&b.terrain&&g.clear({stencil:0});const G={func:d.EQUAL,mask:255};D.u_alpha_discard_threshold=.8,q(new a.StencilMode(G,r,255,d.KEEP,d.KEEP,d.INVERT)),D.u_alpha_discard_threshold=0,q(new a.StencilMode(G,r,255,d.KEEP,d.KEEP,d.KEEP))}else q(b.stencilModeForClipping(h))}m&&(b.resetStencilClippingMasks(),b.terrain&&g.clear({stencil:0}))},fill:function(b,d,c,e){const h=c.paint.get("fill-color"),f=c.paint.get("fill-opacity");if(0===f.constantOr(1))return;const g=b.colorModeForRenderPass(),i=c.paint.get("fill-pattern"),j=b.opaquePassEnabledForLayer()&&!i.constantOr(1)&&1===h.constantOr(a.Color.transparent).a&&1===f.constantOr(0)?"opaque":"translucent";if(b.renderPass===j){const k=b.depthModeForSublayer(1,"opaque"===b.renderPass?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);jc(b,d,c,e,k,g,!1)}if("translucent"===b.renderPass&&c.paint.get("fill-antialias")){const l=b.depthModeForSublayer(c.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);jc(b,d,c,e,l,g,!0)}},"fill-extrusion":function(b,d,c,e){const g=c.paint.get("fill-extrusion-opacity");if(0!==g&&"translucent"===b.renderPass){const f=new a.DepthMode(b.context.gl.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);if(1!==g||c.paint.get("fill-extrusion-pattern").constantOr(1))kc(b,d,c,e,f,a.StencilMode.disabled,a.ColorMode.disabled),kc(b,d,c,e,f,b.stencilModeFor3D(),b.colorModeForRenderPass()),b.resetStencilClippingMasks();else{const h=b.colorModeForRenderPass();kc(b,d,c,e,f,a.StencilMode.disabled,h)}}},hillshade:function(b,j,e,f){if("offscreen"!==b.renderPass&&"translucent"!==b.renderPass)return;const k=b.context,g=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),h=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[l,m]="translucent"!==b.renderPass||i?[{},f]:b.stencilConfigForOverlap(f);for(const c of m){const d=j.getTile(c);if(d.needsHillshadePrepare&&"offscreen"===b.renderPass)pb(b,d,e,g,a.StencilMode.disabled,h);else if("translucent"===b.renderPass){const n=i&&b.terrain?b.terrain.stencilModeForRTTOverlap(c):l[c.overscaledZ];nb(b,c,d,e,g,n,h)}}k.viewport.set([0,0,b.width,b.height]),b.resetStencilClippingMasks()},raster:function(b,j,f,m,H,x){if("translucent"!==b.renderPass)return;if(0===f.paint.get("raster-opacity"))return;if(!m.length)return;const g=b.context,c=g.gl,h=j.getSource(),n=b.useProgram("raster"),q=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[y,o]=h instanceof s||i?[{},m]:b.stencilConfigForOverlap(m),z=o[o.length-1].overscaledZ,A=!b.options.moving;for(const e of o){const r=i?a.DepthMode.disabled:b.depthModeForSublayer(e.overscaledZ-z,1===f.paint.get("raster-opacity")?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,c.LESS),t=e.toUnwrapped(),d=j.getTile(e);if(i&&(!d||!d.hasData()))continue;const B=i?e.projMatrix:b.transform.calculateProjMatrix(t,A),C=b.terrain&&i?b.terrain.stencilModeForRTTOverlap(e):y[e.overscaledZ],u=x?0:f.paint.get("raster-fade-duration");d.registerFadeDuration(u);const k=j.findLoadedParent(e,0),D=xb(d,k,j,b.transform,u);let l,v;b.terrain&&b.terrain.prepareDrawTile(e);const p="nearest"===f.paint.get("raster-resampling")?c.NEAREST:c.LINEAR;g.activeTexture.set(c.TEXTURE0),d.texture.bind(p,c.CLAMP_TO_EDGE),g.activeTexture.set(c.TEXTURE1),k?(k.texture.bind(p,c.CLAMP_TO_EDGE),l=Math.pow(2,k.tileID.overscaledZ-d.tileID.overscaledZ),v=[d.tileID.canonical.x*l%1,d.tileID.canonical.y*l%1]):d.texture.bind(p,c.CLAMP_TO_EDGE);const w=Vb(B,v||[0,0],l||1,D,f,h instanceof s?h.perspectiveTransform:[0,0]);if(b.prepareDrawProgram(g,n,t),h instanceof s)n.draw(g,c.TRIANGLES,r,a.StencilMode.disabled,q,a.CullFaceMode.disabled,w,f.id,h.boundsBuffer,b.quadTriangleIndexBuffer,h.boundsSegments);else{const{tileBoundsBuffer:E,tileBoundsIndexBuffer:F,tileBoundsSegments:G}=b.getTileBoundsBuffers(d);n.draw(g,c.TRIANGLES,r,C,q,a.CullFaceMode.disabled,w,f.id,E,F,G)}}b.resetStencilClippingMasks()},background:function(b,j,e,k){const l=e.paint.get("background-color"),f=e.paint.get("background-opacity");if(0===f)return;const g=b.context,m=g.gl,n=b.transform,o=n.tileSize,d=e.paint.get("background-pattern");if(b.isPatternMissing(d))return;const p=!d&&1===l.a&&1===f&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==p)return;const t=a.StencilMode.disabled,u=b.depthModeForSublayer(0,"opaque"===p?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),v=b.colorModeForRenderPass(),q=b.useProgram(d?"backgroundPattern":"background");let h,i=k;i||(h=b.getBackgroundTiles(),i=Object.values(h).map(a=>a.tileID)),d&&(g.activeTexture.set(m.TEXTURE0),b.imageManager.bind(b.context));const w=e.getCrossfadeParameters();for(const c of i){const r=c.toUnwrapped(),s=k?c.projMatrix:b.transform.calculateProjMatrix(r);b.prepareDrawTile(c);const x=j?j.getTile(c):h?h[c.key]:new a.Tile(c,o,n.zoom,b),y=d?_b(s,f,b,d,{tileID:c,tileSize:o},w):$b(s,f,l);b.prepareDrawProgram(g,q,r);const{tileBoundsBuffer:z,tileBoundsIndexBuffer:A,tileBoundsSegments:B}=b.getTileBoundsBuffers(x);q.draw(g,m.TRIANGLES,u,t,v,a.CullFaceMode.disabled,y,e.id,z,A,B)}},sky:function(b,k,c){const d=b.transform,i="mercator"===d.projection.name||"globe"===d.projection.name?1:a.smoothstep(7,8,d.zoom),e=c.paint.get("sky-opacity")*i;if(0===e)return;const j=b.context,f=c.paint.get("sky-type"),g=new a.DepthMode(j.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),h=b.frameCounter/1e3%1;"atmosphere"===f?"offscreen"===b.renderPass?c.needsSkyboxCapture(b)&&((function(h,e,k,l){const d=h.context,b=d.gl;let i=e.skyboxFbo;if(!i){i=e.skyboxFbo=d.createFramebuffer(32,32,!1),e.skyboxGeometry=new xc(d),e.skyboxTexture=d.gl.createTexture(),b.bindTexture(b.TEXTURE_CUBE_MAP,e.skyboxTexture),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);for(let j=0;j<6;++j)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,b.RGBA,32,32,0,b.RGBA,b.UNSIGNED_BYTE,null)}d.bindFramebuffer.set(i.framebuffer),d.viewport.set([0,0,32,32]);const f=e.getCenter(h,!0),g=h.useProgram("skyboxCapture"),c=new Float64Array(16);a.identity(c),a.rotateY(c,c,-(.5*Math.PI)),yc(d,e,g,c,f,0),a.identity(c),a.rotateY(c,c,.5*Math.PI),yc(d,e,g,c,f,1),a.identity(c),a.rotateX(c,c,-(.5*Math.PI)),yc(d,e,g,c,f,2),a.identity(c),a.rotateX(c,c,.5*Math.PI),yc(d,e,g,c,f,3),a.identity(c),yc(d,e,g,c,f,4),a.identity(c),a.rotateY(c,c,Math.PI),yc(d,e,g,c,f,5),d.viewport.set([0,0,h.width,h.height])})(b,c),c.markSkyboxValid(b)):"sky"===b.renderPass&&(function(b,c,g,h,i){const d=b.context,e=d.gl,j=b.transform,f=b.useProgram("skybox");d.activeTexture.set(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,c.skyboxTexture);const k={u_matrix:j.skyboxMatrix,u_sun_direction:c.getCenter(b,!1),u_cubemap:0,u_opacity:h,u_temporal_offset:i};b.prepareDrawProgram(d,f),f.draw(d,e.TRIANGLES,g,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.backCW,k,"skybox",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)})(b,c,g,e,h):"gradient"===f&&"sky"===b.renderPass&&(function(c,b,m,n,o){var g,h,i,j,k;const d=c.context,e=d.gl,p=c.transform,l=c.useProgram("skyboxGradient");b.skyboxGeometry||(b.skyboxGeometry=new xc(d)),d.activeTexture.set(e.TEXTURE0);let f=b.colorRampTexture;f||(f=b.colorRampTexture=new a.Texture(d,b.colorRamp,e.RGBA)),f.bind(e.LINEAR,e.CLAMP_TO_EDGE);const q=(g=p.skyboxMatrix,h=b.getCenter(c,!1),i=b.paint.get("sky-gradient-radius"),j=n,k=o,{u_matrix:g,u_color_ramp:0,u_center_direction:h,u_radius:a.degToRad(i),u_opacity:j,u_temporal_offset:k});c.prepareDrawProgram(d,l),l.draw(d,e.TRIANGLES,m,a.StencilMode.disabled,c.colorModeForRenderPass(),a.CullFaceMode.backCW,q,"skyboxGradient",b.skyboxGeometry.vertexBuffer,b.skyboxGeometry.indexBuffer,b.skyboxGeometry.segment)})(b,c,g,e,h)},debug:function(c,d,b){for(let a=0;aa.getOpacity(this.transform.pitch)||.03>a.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);const[b,c]=a.getFovAdjustedRange(this.transform._fov);if(b>c)return void(this.transform.fogCullDistSq=null);const d=b+.78*(c-b);this.transform.fogCullDistSq=d*d}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(b,c){if(this.width=b*a.exported.devicePixelRatio,this.height=c*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const d of this.style.order)this.style._layers[d].resize()}setup(){const b=this.context,c=new a.StructArrayLayout2i4;c.emplaceBack(0,0),c.emplaceBack(a.EXTENT,0),c.emplaceBack(0,a.EXTENT),c.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=b.createVertexBuffer(c,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);const d=new a.StructArrayLayout2i4;d.emplaceBack(0,0),d.emplaceBack(a.EXTENT,0),d.emplaceBack(0,a.EXTENT),d.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=b.createVertexBuffer(d,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);const e=new a.StructArrayLayout2i4;e.emplaceBack(-1,-1),e.emplaceBack(1,-1),e.emplaceBack(-1,1),e.emplaceBack(1,1),this.viewportBuffer=b.createVertexBuffer(e,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);const f=new a.StructArrayLayout4i8;f.emplaceBack(0,0,0,0),f.emplaceBack(a.EXTENT,0,a.EXTENT,0),f.emplaceBack(0,a.EXTENT,0,a.EXTENT),f.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=b.createVertexBuffer(f,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);const h=new a.StructArrayLayout3ui6;h.emplaceBack(0,1,2),h.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=b.createIndexBuffer(h);const i=new a.StructArrayLayout1ui2;for(const j of[0,1,3,2,0])i.emplaceBack(j);this.debugIndexBuffer=b.createIndexBuffer(i),this.emptyTexture=new a.Texture(b,{width:1,height:1,data:new Uint8Array([0,0,0,0])},b.gl.RGBA),this.identityMat=a.create();const g=this.context.gl;this.stencilClearMode=new a.StencilMode({func:g.ALWAYS,mask:0},0,255,g.ZERO,g.ZERO,g.ZERO),this.loadTimeStamps.push(a.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(a){return a._makeTileBoundsBuffers(this.context,this.transform.projection),a._tileBoundsBuffer?{tileBoundsBuffer:a._tileBoundsBuffer,tileBoundsIndexBuffer:a._tileBoundsIndexBuffer,tileBoundsSegments:a._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const b=this.context,c=b.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(b,c.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,wb(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,d,b){if(!d||this.currentStencilSource===d.id||!h.isTileClipped()||!b||0===b.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let g=!1;for(const i of b)if(void 0===this._tileClippingMaskIDs[i.key]){g=!0;break}if(!g)return}this.currentStencilSource=d.id;const e=this.context,c=e.gl;this.nextStencilID+b.length>256&&this.clearStencil(),e.setColorMode(a.ColorMode.disabled),e.setDepthMode(a.DepthMode.disabled);const j=this.useProgram("clippingMask");for(const f of(this._tileClippingMaskIDs={},b)){const k=d.getTile(f),l=this._tileClippingMaskIDs[f.key]=this.nextStencilID++,{tileBoundsBuffer:m,tileBoundsIndexBuffer:n,tileBoundsSegments:o}=this.getTileBoundsBuffers(k);j.draw(e,c.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:c.ALWAYS,mask:0},l,255,c.KEEP,c.KEEP,c.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,wb(f.projMatrix),"$clipping",m,n,o)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const c=this.nextStencilID++,b=this.context.gl;return new a.StencilMode({func:b.NOTEQUAL,mask:255},c,255,b.KEEP,b.KEEP,b.REPLACE)}stencilModeForClipping(c){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(c);const b=this.context.gl;return new a.StencilMode({func:b.EQUAL,mask:255},this._tileClippingMaskIDs[c.key],0,b.KEEP,b.KEEP,b.REPLACE)}stencilConfigForOverlap(h){const c=this.context.gl,b=h.sort((a,b)=>b.overscaledZ-a.overscaledZ),f=b[b.length-1].overscaledZ,d=b[0].overscaledZ-f+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const g={};for(let e=0;e=0;this.currentLayer--){const k=this.style._layers[c[this.currentLayer]],l=b._getLayerSourceCache(k);if(k.isSky())continue;const x=l?g[l.id]:void 0;this._renderTileClippingMasks(k,l,x),this.renderLayer(this,l,k,x)}if(this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const a=b._getLayerSourceCache(c);a&&!c.isHidden(this.transform.zoom)&&(!t||t.getSource().maxzoom0?a.pop():null}isPatternMissing(a){if(!a)return!1;if(!a.from||!a.to)return!0;const b=this.imageManager.getPattern(a.from.toString()),c=this.imageManager.getPattern(a.to.toString());return!b||!c}currentGlobalDefines(){const b=this.terrain&&this.terrain.renderingToTexture,c=this.style&&this.style.fog,a=[];return this.terrain&&!this.terrain.renderingToTexture&&a.push("TERRAIN"),c&&!b&&0!==c.getOpacity(this.transform.pitch)&&a.push("FOG"),b&&a.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&a.push("OVERDRAW_INSPECTOR"),a}useProgram(a,c,e){this.cache=this.cache||{};const d=this.currentGlobalDefines().concat(e||[]),b=Db.cacheKey(a,d,c);return this.cache[b]||(this.cache[b]=new Db(this.context,a,kb[a],c,ac[a],d)),this.cache[b]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const a=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(a.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=a.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(a){this.terrain&&this.terrain.prepareDrawTile(a)}prepareDrawProgram(c,d,e){if(this.terrain&&this.terrain.renderingToTexture)return;const a=this.style.fog;if(a){const b=a.getOpacity(this.transform.pitch);0!==b&&d.setFogUniformValues(c,((b,c,d,e)=>{const a=c.properties.get("color"),f=b.frameCounter/1e3%1,g=[a.r/a.a,a.g/a.a,a.b/a.a,e];return{u_fog_matrix:d?b.transform.calculateFogTileMatrix(d):b.identityMat,u_fog_range:c.getFovAdjustedRange(b.transform._fov),u_fog_color:g,u_fog_horizon_blend:c.properties.get("horizon-blend"),u_fog_temporal_offset:f}})(this,a,e,b))}}setTileLoadedFlag(a){this.tileLoaded=a}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const a=this.context.gl,b=a.createTexture();return a.bindTexture(a.TEXTURE_2D,b),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,a.drawingBufferWidth,a.drawingBufferHeight,0),b}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const a=this.style&&this.style.fog;return!!a&&0!==a.getOpacity(this.transform.pitch)}getBackgroundTiles(){const d=this._backgroundTiles,c=this._backgroundTiles={},e=this.transform.coveringTiles({tileSize:512});for(const b of e)c[b.key]=d[b.key]||new a.Tile(b,512,this.transform.tileZoom,this);return c}clearBackgroundTiles(){this._backgroundTiles={}}}class Bc{constructor(a=0,b=0,c=0,d=0){if(isNaN(a)||a<0||isNaN(b)||b<0||isNaN(c)||c<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=a,this.bottom=b,this.left=c,this.right=d}interpolate(b,c,d){return null!=c.top&&null!=b.top&&(this.top=a.number(b.top,c.top,d)),null!=c.bottom&&null!=b.bottom&&(this.bottom=a.number(b.bottom,c.bottom,d)),null!=c.left&&null!=b.left&&(this.left=a.number(b.left,c.left,d)),null!=c.right&&null!=b.right&&(this.right=a.number(b.right,c.right,d)),this}getCenter(b,c){const d=a.clamp((this.left+b-this.right)/2,0,b),e=a.clamp((this.top+c-this.bottom)/2,0,c);return new a.pointGeometry(d,e)}equals(a){return this.top===a.top&&this.bottom===a.bottom&&this.left===a.left&&this.right===a.right}clone(){return new Bc(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Cc(b,c){const d=a.getColumn(b,3);a.fromQuat(b,c),a.setColumn(b,3,d)}function Dc(c,b){a.setColumn(c,3,[b[0],b[1],b[2],1])}function Ec(c,d){const b=a.identity$1([]);return a.rotateZ$1(b,b,-d),a.rotateX$1(b,b,-c),b}function Fc(b,c){const f=[b[0],b[1],0],d=[c[0],c[1],0];if(a.length(f)>=1e-15){const g=a.normalize([],f);a.scale$2(d,g,a.dot(d,g)),c[0]=d[0],c[1]=d[1]}const e=a.cross([],c,b);if(1e-15>a.len(e))return null;const h=Math.atan2(-e[1],e[0]);return Ec(Math.atan2(Math.sqrt(b[0]*b[0]+b[1]*b[1]),-b[2]),h)}class x{constructor(a,b){this.position=a,this.orientation=b}get position(){return this._position}set position(b){this._position=this._renderWorldCopies?(function(b){if(!b)return;const c=Array.isArray(b)?new a.MercatorCoordinate(b[0],b[1],b[2]):b;return c.x=a.wrap(c.x,0,1),c})(b):b}lookAtPoint(e,b){if(this.orientation=null,!this.position)return;const f=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(e)):0,c=this.position,d=a.MercatorCoordinate.fromLngLat(e,f),g=[d.x-c.x,d.y-c.y,d.z-c.z];b||(b=[0,0,1]),b[2]=Math.abs(b[2]),this.orientation=Fc(g,b)}setPitchBearing(b,c){this.orientation=Ec(a.degToRad(b),a.degToRad(-c))}}class Gc{constructor(b,c){this._transform=a.identity([]),this._orientation=a.identity$1([]),c&&(this._orientation=c,Cc(this._transform,this._orientation)),b&&Dc(this._transform,b)}get mercatorPosition(){const b=this.position;return new a.MercatorCoordinate(b[0],b[1],b[2])}get position(){const b=a.getColumn(this._transform,3);return[b[0],b[1],b[2]]}set position(a){Dc(this._transform,a)}get orientation(){return this._orientation}set orientation(a){this._orientation=a,Cc(this._transform,this._orientation)}getPitchBearing(){const a=this.forward(),b=this.right();return{bearing:Math.atan2(-b[1],b[0]),pitch:Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2])}}setPitchBearing(a,b){this._orientation=Ec(a,b),Cc(this._transform,this._orientation)}forward(){const b=a.getColumn(this._transform,2);return[-b[0],-b[1],-b[2]]}up(){const b=a.getColumn(this._transform,1);return[-b[0],-b[1],-b[2]]}right(){const b=a.getColumn(this._transform,0);return[b[0],b[1],b[2]]}getCameraToWorld(c,d){const b=new Float64Array(16);return a.invert(b,this.getWorldToCamera(c,d)),b}getWorldToCameraPosition(e,f,c){const d=this.position;a.scale$2(d,d,-e);const b=new Float64Array(16);return a.fromScaling(b,[c,c,c]),a.translate(b,b,d),b[10]*=f,b}getWorldToCamera(f,c){const b=new Float64Array(16),e=new Float64Array(4),d=this.position;return a.conjugate(e,this._orientation),a.scale$2(d,d,-f),a.fromQuat(b,e),a.translate(b,b,d),b[1]*=-1,b[5]*=-1,b[9]*=-1,b[13]*=-1,b[8]*=c,b[9]*=c,b[10]*=c,b[11]*=c,b}getCameraToClipPerspective(c,d,e,f){const b=new Float64Array(16);return a.perspective(b,c,d,e,f),b}getDistanceToElevation(b){const c=0===b?0:a.mercatorZfromAltitude(b,this.position[1]);return(c-this.position[2])/this.forward()[2]}clone(){return new Gc([...this.position],[...this.orientation])}}function Hc(b,e){const f=Jc(b),c=function(c,y,d,h,v){const l=new a.LngLat(d.lng-180*Kc,d.lat),m=new a.LngLat(d.lng+180*Kc,d.lat),n=c.project(l.lng,l.lat),o=c.project(m.lng,m.lat),e=-Math.atan2(o.y-n.y,o.x-n.x),i=a.MercatorCoordinate.fromLngLat(d);i.y=a.clamp(i.y,-0.999975,.999975);const f=i.toLngLat(),g=c.project(f.lng,f.lat),p=a.MercatorCoordinate.fromLngLat(f);p.x+=Kc;const q=p.toLngLat(),r=c.project(q.lng,q.lat),w=Mc(r.x-g.x,r.y-g.y,e),s=a.MercatorCoordinate.fromLngLat(f);s.y+=Kc;const t=s.toLngLat(),u=c.project(t.lng,t.lat),j=Mc(u.x-g.x,u.y-g.y,e),x=Math.abs(w.x)/Math.abs(j.y),k=a.identity([]);a.rotateZ(k,k,-e*(1-(v?0:h)));const b=a.identity([]);return a.scale(b,b,[1,1-(1-x)*h,1]),b[4]=-j.x/j.y*h,a.rotateZ(b,b,e),a.multiply$1(b,k,b),b}(b.projection,0,b.center,f,e),d=Ic(b);return a.scale(c,c,[d,d,1]),c}function Ic(b){const c=b.projection,d=Jc(b),e=Lc(c,b.center),f=Lc(c,a.LngLat.convert(c.center));return Math.pow(2,e*d+(1-d)*f)}function Jc(b){const c=b.projection.range;if(!c)return 0;const e=Math.max(b.width,b.height),d=Math.log(e/1024)/Math.LN2;return a.smoothstep(c[0]+d,c[1]+d,b.zoom)}const Kc=1/4e4;function Lc(d,c){const b=a.clamp(c.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),e=new a.LngLat(c.lng-180*Kc,b),f=new a.LngLat(c.lng+180*Kc,b),g=d.project(e.lng,b),h=d.project(f.lng,b),i=a.MercatorCoordinate.fromLngLat(e),j=a.MercatorCoordinate.fromLngLat(f),k=h.x-g.x,l=h.y-g.y,m=j.x-i.x,n=j.y-i.y;return Math.log(Math.sqrt((m*m+n*n)/(k*k+l*l)))/Math.LN2}function Mc(a,b,c){const d=Math.cos(c),e=Math.sin(c);return{x:a*d-b*e,y:a*e+b*d}}class Nc{constructor(e,f,b,c,d){this.tileSize=512,this._renderWorldCopies=void 0===d||d,this._minZoom=e||0,this._maxZoom=f||22,this._minPitch=null==b?0:b,this._maxPitch=null==c?60:c,this.setProjection(),this.setMaxBounds(),this.width=0,this.height=0,this._center=new a.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Bc,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Gc,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const a=new Nc(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return a.setProjection(this.getProjection()),a._elevation=this._elevation,a._centerAltitude=this._centerAltitude,a.tileSize=this.tileSize,a.setMaxBounds(this.getMaxBounds()),a.width=this.width,a.height=this.height,a.cameraElevationReference=this.cameraElevationReference,a._center=this._center,a._setZoom(this.zoom),a._cameraZoom=this._cameraZoom,a.angle=this.angle,a._fov=this._fov,a._pitch=this._pitch,a._nearZ=this._nearZ,a._farZ=this._farZ,a._averageElevation=this._averageElevation,a._unmodified=this._unmodified,a._edgeInsets=this._edgeInsets.clone(),a._camera=this._camera.clone(),a._calcMatrices(),a.freezeTileCoverage=this.freezeTileCoverage,a}get elevation(){return this._elevation}set elevation(a){this._elevation!==a&&(this._elevation=a,a?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(a){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),a&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels"])}setProjection(b){null==b&&(b={name:"mercator"}),this.projectionOptions=b;const c=this.projection?this.getProjection():void 0;return this.projection=a.getProjection(b),!D(c,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(a){this._minZoom!==a&&(this._minZoom=a,this.zoom=Math.max(this.zoom,a))}get maxZoom(){return this._maxZoom}set maxZoom(a){this._maxZoom!==a&&(this._maxZoom=a,this.zoom=Math.min(this.zoom,a))}get minPitch(){return this._minPitch}set minPitch(a){this._minPitch!==a&&(this._minPitch=a,this.pitch=Math.max(this.pitch,a))}get maxPitch(){return this._maxPitch}set maxPitch(a){this._maxPitch!==a&&(this._maxPitch=a,this.pitch=Math.min(this.pitch,a))}get renderWorldCopies(){return this._renderWorldCopies&& !0===this.projection.supportsWorldCopies}set renderWorldCopies(a){void 0===a?a=!0:null===a&&(a=!1),this._renderWorldCopies=a}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.pointGeometry(this.width,this.height)}get bearing(){return a.wrap(this.rotation,-180,180)}set bearing(a){this.rotation=a}get rotation(){return-this.angle/Math.PI*180}set rotation(m){var b,c,d,g,h,i,j,k,e,f;const l=-m*Math.PI/180;this.angle!==l&&(this._unmodified=!1,this.angle=l,this._calcMatrices(),b=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(b[1]=0,b[2]=0),b[0]=1,b[3]=1,this.rotationMatrix=b,c=this.rotationMatrix,d=this.rotationMatrix,g=this.angle,h=d[0],i=d[1],j=d[2],k=d[3],e=Math.sin(g),f=Math.cos(g),c[0]=h*f+j*e,c[1]=i*f+k*e,c[2]=-(h*e)+j*f,c[3]=-(i*e)+k*f)}get pitch(){return this._pitch/Math.PI*180}set pitch(c){const b=a.clamp(c,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==b&&(this._unmodified=!1,this._pitch=b,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(a){a=Math.max(.01,Math.min(60,a)),this._fov!==a&&(this._unmodified=!1,this._fov=a/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(a){this._averageElevation=a,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(b){const a=Math.min(Math.max(b,this.minZoom),this.maxZoom);this._zoom!==a&&(this._unmodified=!1,this._setZoom(a),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(a){this._zoom=a,this.scale=this.zoomScale(a),this.tileZoom=Math.floor(a),this.zoomFraction=a-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const a=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return -1===a?(this._cameraZoom=null,!1):(this._centerAltitude=a,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const i=this._elevation,d=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],f=this.horizonLineFromTop();let g=0,e=0;for(let b=0;bc.maxzoom&&(d=c.maxzoom);const r=this.locationCoordinate(this.center),e=1<{const d=1/4e4,g=new a.MercatorCoordinate(b.x+d,b.y,b.z),h=new a.MercatorCoordinate(b.x,b.y+d,b.z),i=b.toLngLat(),j=g.toLngLat(),k=h.toLngLat(),c=this.locationCoordinate(i),e=this.locationCoordinate(j),f=this.locationCoordinate(k),l=Math.hypot(e.x-c.x,e.y-c.y),m=Math.hypot(f.x-c.x,f.y-c.y);return Math.sqrt(l*m)*O/d},j=b=>{const c=F,d=N;return{aabb:a.tileAABB(this,e,0,0,0,b,d,c,this.projection),zoom:0,x:0,y:0,minZ:d,maxZ:c,wrap:b,fullyVisible:!1}},f=[];let h=[];const k=d,v=c.reparseOverscaled?A:d,G=a=>a*a,Q=G((u-this._centerAltitude)*E),H=b=>{if(!this._elevation||!b.tileID||!C)return;const c=this._elevation.getMinMaxForTile(b.tileID),a=b.aabb;c?(a.min[2]=c.min,a.max[2]=c.max,a.center[2]=(a.min[2]+a.max[2])/2):(b.shouldSplit=I(b),b.shouldSplit||(a.min[2]=a.max[2]=a.center[2]=this._centerAltitude))},I=b=>{if(b.zoom.85?1:h}const i=d*d+e*e+c;return i{if(b*G(.707)0;){const b=f.pop(),l=b.x,m=b.y;let n=b.fullyVisible;if(!n){const w=b.aabb.intersects(D);if(0===w)continue;n=2===w}if(b.zoom!==k&&I(b))for(let g=0;g<4;g++){const o=(l<<1)+g%2,p=(m<<1)+(g>>1),q={aabb:C?b.aabb.quadrant(g):a.tileAABB(this,e,b.zoom+1,o,p,b.wrap,b.minZ,b.maxZ,this.projection),zoom:b.zoom+1,x:o,y:p,wrap:b.wrap,fullyVisible:n,tileID:void 0,shouldSplit:void 0,minZ:b.minZ,maxZ:b.maxZ};B&&(q.tileID=new a.OverscaledTileID(b.zoom+1===k?v:b.zoom+1,b.wrap,b.zoom+1,o,p),H(q)),f.push(q)}else{const x=b.zoom===k?v:b.zoom;if(c.minzoom&&c.minzoom>x)continue;const y=s[0]-(.5+l+(b.wrap<{const e=[0,0,0,1],f=[a.EXTENT,a.EXTENT,0,1],i=this.calculateFogTileMatrix(d.tileID.toUnwrapped());a.transformMat4$1(e,e,i),a.transformMat4$1(f,f,i);const g=a.getAABBPointSquareDist(e,f);if(0===g)return!0;let j=!1;const k=this._elevation;if(k&&g>R&&0!==S){const m=this.calculateProjMatrix(d.tileID.toUnwrapped());let b;c.isTerrainDEM||(b=k.getMinMaxForTile(d.tileID)),b||(b={min:N,max:F});const l=a.furthestTileCorner(this.rotation),h=[l[0]*a.EXTENT,l[1]*a.EXTENT,b.max];a.transformMat4(h,h,m),j=(1-h[1])*this.height*.5a.distanceSq-b.distanceSq).map(a=>a.tileID)}resize(a,b){this.width=a,this.height=b,this.pixelsToGLUnits=[2/a,-2/b],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(a){return Math.pow(2,a)}scaleZoom(a){return Math.log(a)/Math.LN2}project(b){const d=a.clamp(b.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),c=this.projection.project(b.lng,d);return new a.pointGeometry(c.x*this.worldSize,c.y*this.worldSize)}unproject(a){return this.projection.unproject(a.x/this.worldSize,a.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,f){const b=this.pointCoordinate(f),c=this.pointCoordinate(this.centerPoint),d=this.locationCoordinate(e);this.setLocation(new a.MercatorCoordinate(d.x-(b.x-c.x),d.y-(b.y-c.y)))}setLocation(a){this.center=this.coordinateLocation(a),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(a){return this.projection.locationPoint(this,a)}locationPoint3D(a){return this._coordinatePoint(this.locationCoordinate(a),!0)}pointLocation(a){return this.coordinateLocation(this.pointCoordinate(a))}pointLocation3D(a){return this.coordinateLocation(this.pointCoordinate3D(a))}locationCoordinate(b,c){const e=c?a.mercatorZfromAltitude(c,b.lat):void 0,d=this.projection.project(b.lng,b.lat);return new a.MercatorCoordinate(d.x,d.y,e)}coordinateLocation(a){return this.projection.unproject(a.x,a.y)}pointRayIntersection(d,f){const h=null!=f?f:this._centerAltitude,b=[d.x,d.y,0,1],c=[d.x,d.y,1,1];a.transformMat4$1(b,b,this.pixelMatrixInverse),a.transformMat4$1(c,c,this.pixelMatrixInverse);const i=c[3];a.scale$1(b,b,1/b[3]),a.scale$1(c,c,1/i);const e=b[2],g=c[2];return{p0:b,p1:c,t:e===g?0:(h-e)/(g-e)}}screenPointToMercatorRay(d){const b=[d.x,d.y,0,1],c=[d.x,d.y,1,1];return a.transformMat4$1(b,b,this.pixelMatrixInverse),a.transformMat4$1(c,c,this.pixelMatrixInverse),a.scale$1(b,b,1/b[3]),a.scale$1(c,c,1/c[3]),b[2]=a.mercatorZfromAltitude(b[2],this._center.lat)*this.worldSize,c[2]=a.mercatorZfromAltitude(c[2],this._center.lat)*this.worldSize,a.scale$1(b,b,1/this.worldSize),a.scale$1(c,c,1/this.worldSize),new a.Ray([b[0],b[1],b[2]],a.normalize([],a.sub([],c,b)))}rayIntersectionCoordinate(e){const{p0:b,p1:c,t:d}=e,f=a.mercatorZfromAltitude(b[2],this._center.lat),g=a.mercatorZfromAltitude(c[2],this._center.lat);return new a.MercatorCoordinate(a.number(b[0],c[0],d)/this.worldSize,a.number(b[1],c[1],d)/this.worldSize,a.number(f,g,d))}pointCoordinate(a,b=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(a.x,a.y,b)}pointCoordinate3D(c){if(!this.elevation)return this.pointCoordinate(c);const i=this.elevation;let b=this.elevation.pointCoordinate(c);if(b)return new a.MercatorCoordinate(b[0],b[1],b[2]);let f=0,d=this.horizonLineFromTop();if(c.y>d)return this.pointCoordinate(c);const j=.02*d,e=c.clone();for(let g=0;g<10&&d-f>j;g++){e.y=a.number(f,d,.66);const h=i.pointCoordinate(e);h?(d=e.y,b=h):f=e.y}return b?new a.MercatorCoordinate(b[0],b[1],b[2]):this.pointCoordinate(c)}isPointAboveHorizon(a){if(this.elevation)return!this.elevation.pointCoordinate(a);{const b=this.horizonLineFromTop();return a.y0?new a.pointGeometry(b[0]/b[3],b[1]/b[3]):new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(h,i){var b,c,b,c,b,c,b,c;const j=new a.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),k=new a.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),l=new a.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),m=new a.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let d=this.pointCoordinate(j,h),e=this.pointCoordinate(k,h);const f=this.pointCoordinate(l,i),g=this.pointCoordinate(m,i);return d.y>1&&e.y>=0?d=new a.MercatorCoordinate((1-g.y)/(b=g,((c=d).y-b.y)/(c.x-b.x))+g.x,1):d.y<0&&e.y<=1&&(d=new a.MercatorCoordinate(-g.y/(b=g,((c=d).y-b.y)/(c.x-b.x))+g.x,0)),e.y>1&&d.y>=0?e=new a.MercatorCoordinate((1-f.y)/(b=f,((c=e).y-b.y)/(c.x-b.x))+f.x,1):e.y<0&&d.y<=1&&(e=new a.MercatorCoordinate(-f.y/(b=f,((c=e).y-b.y)/(c.x-b.x))+f.x,0)),(new a.LngLatBounds).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(e)).extend(this.coordinateLocation(g)).extend(this.coordinateLocation(f))}_getBounds3D(){const a=this.elevation;if(!a.visibleDemTiles.length)return this._getBounds(0,0);const b=a.visibleDemTiles.reduce((a,b)=>{if(b.dem){const c=b.dem.tree;a.min=Math.min(a.min,c.minimums[0]),a.max=Math.max(a.max,c.maximums[0])}return a},{min:Number.MAX_VALUE,max:0});return this._getBounds(b.min*a.exaggeration(),b.max*a.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(b=!0){const c=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,a=this.height/2-c*(1-this._horizonShift);return b?Math.max(0,a):a}getMaxBounds(){return this.maxBounds}setMaxBounds(b){this.maxBounds=b,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,b&&(this.minLat=b.getSouth(),this.maxLat=b.getNorth(),this.minLng=b.getWest(),this.maxLng=b.getEast(),this.maxLngi&&(g=i-l),i-he&&(b=e-k),e-d.5?j-1:j,k>.5?k-1:k,0]),this.alignedProjMatrix=l,b=a.create(),a.scale(b,b,[this.width/2,-this.height/2,1]),a.translate(b,b,[1,-1,0]),this.labelPlaneMatrix=b,b=a.create(),a.scale(b,b,[1,-1,1]),a.translate(b,b,[-1,-1,0]),a.scale(b,b,[2/this.width,2/this.height,1]),this.glCoordMatrix=b,this.pixelMatrix=a.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},b=a.invert(new Float64Array(16),this.pixelMatrix),!b)throw new Error("failed to invert matrix");this.pixelMatrixInverse=b,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,f=this.cameraPixelsPerMeter,b=this._camera.position,g=1/this.height,d=[e,e,f];a.scale$2(d,d,g),a.scale$2(b,b,-1),a.multiply$2(b,b,d);const c=a.create();a.translate(c,c,b),a.scale(c,c,d),this.mercatorFogMatrix=c,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,f,g)}_computeCameraPosition(a){const e=(a=a||this.pixelsPerMeter)/this.pixelsPerMeter,b=this._camera.forward(),d=this.point,c=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*e-a/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-b[0]*c,d.y/this.worldSize-b[1]*c,a/this.worldSize*this._centerAltitude-b[2]*c]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(b){const e=this._maxCameraBoundsDistance()*Math.cos(this._pitch),c=b[2];let d=1;c>0&&(d=Math.min((e-this._camera.position[2])/c,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,b,d),this._updateStateFromCamera()}_updateStateFromCamera(){const b=this._camera.position,e=this._camera.forward(),{pitch:c,bearing:f}=this._camera.getPitchBearing(),g=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,h=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),d=Math.max((b[2]-g)/Math.cos(c),h),i=this._zoomFromMercatorZ(d);a.scaleAndAdd(b,b,e,d),this._pitch=a.clamp(c,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(f,-Math.PI,Math.PI),this._setZoom(a.clamp(i,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new a.MercatorCoordinate(b[0],b[1],b[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(a){return Math.pow(2,a)*this.tileSize}_mercatorZfromZoom(a){return this.cameraToCenterDistance/this._worldSizeFromZoom(a)}_minimumHeightOverTerrain(){const a=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(a)}_zoomFromMercatorZ(a){return this.scaleZoom(this.cameraToCenterDistance/(a*this.tileSize))}_terrainEnabled(){return!(!this._elevation|| !this.projection.supportsTerrain&&(a.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(b,c){const f=Math.min(b.x,c.x),g=Math.max(b.x,c.x),e=Math.min(b.y,c.y),h=Math.max(b.y,c.y);if(el||d.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.pointGeometry(0,0),new a.pointGeometry(this.width,this.height))}zoomDeltaToMovement(c,d){const b=a.length(a.sub([],this._camera.position,c)),e=this._zoomFromMercatorZ(b)+d;return b-this._mercatorZfromZoom(e)}getCameraPoint(){const b=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.pointGeometry(0,b))}}function Oc(a,b){let c=!1,d=null;const e=()=>{d=null,c&&(a(),d=setTimeout(e,b),c=!1)};return()=>(c=!0,d||e(),d)}const d={linearity:.3,easing:a.bezier(0,0,.3,1)},Pc=a.extend({deceleration:2500,maxSpeed:1400},d),Qc=a.extend({deceleration:20,maxSpeed:1400},d),Rc=a.extend({deceleration:1e3,maxSpeed:360},d),Sc=a.extend({deceleration:1e3,maxSpeed:90},d);function Tc(a,b){(!a.duration||a.durationf.unproject(a)),g=d.reduce((a,b,d,c)=>a.add(b.div(c.length)),new a.pointGeometry(0,0));super(e,{points:d,point:g,lngLats:i,lngLat:f.unproject(g),originalEvent:c}),this._defaultPrevented=!1}}class Xc extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(a,c,b){super(a,{originalEvent:b}),this._defaultPrevented=!1}}class Yc{constructor(a,b){this._map=a,this._clickTolerance=b.clickTolerance}reset(){delete this._mousedownPos}wheel(a){return this._firePreventable(new Xc(a.type,this._map,a))}mousedown(a,b){return this._mousedownPos=b,this._firePreventable(new Vc(a.type,this._map,a))}mouseup(a){this._map.fire(new Vc(a.type,this._map,a))}preclick(c){const b=a.extend({},c);b.type="preclick",this._map.fire(new Vc(b.type,this._map,b))}click(a,b){this._mousedownPos&&this._mousedownPos.dist(b)>=this._clickTolerance||(this.preclick(a),this._map.fire(new Vc(a.type,this._map,a)))}dblclick(a){return this._firePreventable(new Vc(a.type,this._map,a))}mouseover(a){this._map.fire(new Vc(a.type,this._map,a))}mouseout(a){this._map.fire(new Vc(a.type,this._map,a))}touchstart(a){return this._firePreventable(new Wc(a.type,this._map,a))}touchmove(a){this._map.fire(new Wc(a.type,this._map,a))}touchend(a){this._map.fire(new Wc(a.type,this._map,a))}touchcancel(a){this._map.fire(new Wc(a.type,this._map,a))}_firePreventable(a){if(this._map.fire(a),a.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Zc{constructor(a){this._map=a}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(a){this._map.fire(new Vc(a.type,this._map,a))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Vc("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(a){this._delayContextMenu?this._contextMenuEvent=a:this._map.fire(new Vc(a.type,this._map,a)),this._map.listens("contextmenu")&&a.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class $c{constructor(a,b){this._map=a,this._el=a.getCanvasContainer(),this._container=a.getContainer(),this._clickTolerance=b.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(a,c){this.isEnabled()&&a.shiftKey&&0===a.button&&(b.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(d,e){if(!this._active)return;const a=e;if(this._lastPos.equals(a)|| !this._box&&a.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${f}px,${h}px)`,this._box.style.width=g-f+"px",this._box.style.height=i-h+"px")})}mouseupWindow(c,f){if(!this._active)return;if(0!==c.button)return;const d=this._startPos,e=f;if(this.reset(),b.suppressClick(),d.x!==e.x||d.y!==e.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:c})),{cameraAnimation:a=>a.fitScreenCoordinates(d,e,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",c)}keydown(a){this._active&&27===a.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",a))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),b.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(b,c){return this._map.fire(new a.Event(b,{originalEvent:c}))}}function _c(b,d){const c={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=d.timeStamp),b.length===this.numTouches&&(this.centroid=(function(b){const c=new a.pointGeometry(0,0);for(const d of b)c._add(d);return c.div(b.length)})(c),this.touches=_c(b,c)))}touchmove(g,c,d){if(this.aborted||!this.centroid)return;const e=_c(d,c);for(const a in this.touches){const f=this.touches[a],b=e[a];(!b||b.dist(f)>30)&&(this.aborted=!0)}}touchend(b,d,c){if((!this.centroid||b.timeStamp-this.startTime>500)&&(this.aborted=!0),0===c.length){const a=!this.aborted&&this.centroid;if(this.reset(),a)return a}}}(b),this.numTaps=b.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(a,b,c){this.singleTap.touchstart(a,b,c)}touchmove(a,b,c){this.singleTap.touchmove(a,b,c)}touchend(b,c,d){const a=this.singleTap.touchend(b,c,d);if(a){const e=b.timeStamp-this.lastTime<500,f=!this.lastTap||30>this.lastTap.dist(a);if(e&&f||this.reset(),this.count++,this.lastTime=b.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class bd{constructor(){this._zoomIn=new ad({numTouches:1,numTaps:2}),this._zoomOut=new ad({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(a,b,c){this._zoomIn.touchstart(a,b,c),this._zoomOut.touchstart(a,b,c)}touchmove(a,b,c){this._zoomIn.touchmove(a,b,c),this._zoomOut.touchmove(a,b,c)}touchend(a,b,c){const d=this._zoomIn.touchend(a,b,c),e=this._zoomOut.touchend(a,b,c);return d?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()+1,around:b.unproject(d)},{originalEvent:a})}):e?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()-1,around:b.unproject(e)},{originalEvent:a})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const cd={0:1,2:2};class f{constructor(a){this.reset(),this._clickTolerance=a.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(a,b){return!1}_move(a,b){return{}}mousedown(a,d){if(this._lastPoint)return;const c=b.mouseButton(a);this._correctButton(a,c)&&(this._lastPoint=d,this._eventButton=c)}mousemoveWindow(c,a){const b=this._lastPoint;if(b){if(c.preventDefault(),(function(a,c){const b=cd[c];return void 0===a.buttons||(a.buttons&b)!==b})(c,this._eventButton))this.reset();else if(this._moved||!(a.dist(b)0&&(this._active=!0);const b=_c(g,k),h=new a.pointGeometry(0,0),d=new a.pointGeometry(0,0);let c=0;for(const e in b){const f=b[e],i=this._touches[e];i&&(h._add(f),d._add(f.sub(i)),c++,b[e]=f)}if(this._touches=b,c{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class g{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(a){}_move(a,b,c){return{}}touchstart(c,b,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier],this._start([b[0],b[1]]))}touchmove(c,d,e){if(!this._firstTwoTouches)return;c.preventDefault();const[f,g]=this._firstTwoTouches,a=hd(e,d,f),b=hd(e,d,g);if(!a||!b)return;const h=this._aroundCenter?null:a.add(b).div(2);return this._move([a,b],h,c)}touchend(h,a,c){if(!this._firstTwoTouches)return;const[d,e]=this._firstTwoTouches,f=hd(c,a,d),g=hd(c,a,e);f&&g||(this._active&&b.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(a){this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function hd(b,c,d){for(let a=0;aMath.abs(id(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:id(this._distance,c),pinchAround:b}}}function kd(a,b){return 180*a.angleWith(b)/Math.PI}class ld extends g{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(a){this._startVector=this._vector=a[0].sub(a[1]),this._minDiameter=a[0].dist(a[1])}_move(a,b){const c=this._vector;if(this._vector=a[0].sub(a[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:kd(this._vector,c),pinchAround:b}}_isBelowThreshold(a){this._minDiameter=Math.min(this._minDiameter,a.mag());const b=25/(Math.PI*this._minDiameter)*360,c=kd(a,this._startVector);return Math.abs(c)Math.abs(a.x)}class nd extends g{constructor(a){super(),this._map=a}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(a){this._lastPoints=a,md(a[0].sub(a[1]))&&(this._valid=!1)}_move(a,e,b){const c=a[0].sub(this._lastPoints[0]),d=a[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&b.touches.length<3)&&(this._valid=this.gestureBeginsVertically(c,d,b.timeStamp),this._valid))return this._lastPoints=a,this._active=!0,{pitchDelta:-((c.y+d.y)/2*.5)}}gestureBeginsVertically(a,b,c){if(void 0!==this._valid)return this._valid;const d=a.mag()>=2,e=b.mag()>=2;if(!d&&!e)return;if(!d||!e)return void 0===this._firstMove&&(this._firstMove=c),c-this._firstMove<100&&void 0;const f=a.y>0==b.y>0;return md(a)&&md(b)&&f}}class od{constructor(){this._panStep=100,this._bearingStep=15,this._pitchStep=10,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(a){if(a.altKey||a.ctrlKey||a.metaKey)return;let d=0,b=0,c=0,e=0,f=0;switch(a.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:a.shiftKey?b=-1:(a.preventDefault(),e=-1);break;case 39:a.shiftKey?b=1:(a.preventDefault(),e=1);break;case 38:a.shiftKey?c=1:(a.preventDefault(),f=-1);break;case 40:a.shiftKey?c=-1:(a.preventDefault(),f=1);break;default:return}return this._rotationDisabled&&(b=0,c=0),{cameraAnimation:g=>{const h=g.getZoom();g.easeTo({duration:300,easeId:"keyboardHandler",easing:pd,zoom:d?Math.round(h)+d*(a.shiftKey?2:1):h,bearing:g.getBearing()+b*this._bearingStep,pitch:g.getPitch()+c*this._pitchStep,offset:[-e*this._panStep,-f*this._panStep],center:g.getCenter()},{originalEvent:a})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function pd(a){return a*(2-a)}const qd=4.000244140625;class rd{constructor(b,c){this._map=b,this._el=b.getCanvasContainer(),this._handler=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(a){this._defaultZoomRate=a}setWheelZoomRate(a){this._wheelZoomRate=a}isEnabled(){return!!this._enabled}isActive(){return!!this._active|| void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(a){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(b){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(b.ctrlKey||b.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let c=b.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*b.deltaY:b.deltaY;const d=a.exported.now(),e=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,0!==c&&c%qd==0?this._type="wheel":0!==c&&4>Math.abs(c)?this._type="trackpad":e>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,b)):this._type||(this._type=200>Math.abs(e*c)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),b.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=b,this._delta-=c,this._active||this._start(b)),b.preventDefault()}_onTimeout(a){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)}_start(a){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const c=b.mousePos(this._el,a);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:c,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const b=this._map.transform,c=()=>b._terrainEnabled()&&this._aroundCoord?b.computeZoomRelativeTo(this._aroundCoord):b.zoom;if(0!==this._delta){const k="wheel"===this._type&&Math.abs(this._delta)>qd?this._wheelZoomRate:this._defaultZoomRate;let d=2/(1+Math.exp(-Math.abs(this._delta*k)));this._delta<0&&0!==d&&(d=1/d);const l=c(),m=Math.pow(2,l),n="number"==typeof this._targetZoom?b.zoomScale(this._targetZoom):m;this._targetZoom=Math.min(b.maxZoom,Math.max(b.minZoom,b.scaleZoom(n*d))),"wheel"===this._type&&(this._startZoom=c(),this._easing=this._smoothOutEasing(200)),this._delta=0}const g="number"==typeof this._targetZoom?this._targetZoom:c(),h=this._startZoom,i=this._easing;let f,e=!1;if("wheel"===this._type&&h&&i){const j=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),o=i(j);f=a.number(h,g,o),j<1?this._frameId||(this._frameId=!0):e=!0}else f=g,e=!0;return this._active=!0,e&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!e,zoomDelta:f-c(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(g){let c=a.ease;if(this._prevEase){const b=this._prevEase,e=(a.exported.now()-b.start)/b.duration,f=b.easing(e+.01)-b.easing(e),d=.27/Math.sqrt(f*f+1e-4)*.01,h=Math.sqrt(.0729-d*d);c=a.bezier(d,h,.25,1)}return this._prevEase={start:a.exported.now(),duration:g,easing:c},c}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=b.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(a.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!a.window.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class sd{constructor(a,b){this._clickZoom=a,this._tapZoom=b}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class td{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(a,b){return a.preventDefault(),{cameraAnimation:c=>{c.easeTo({duration:300,zoom:c.getZoom()+(a.shiftKey?-1:1),around:c.unproject(b)},{originalEvent:a})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ud{constructor(){this._tap=new ad({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(b,c,a){this._swipePoint||(this._tapTime&&b.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?a.length>0&&(this._swipePoint=c[0],this._swipeTouch=a[0].identifier):this._tap.touchstart(b,c,a))}touchmove(a,b,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;const d=b[0],e=d.y-this._swipePoint.y;return this._swipePoint=d,a.preventDefault(),this._active=!0,{zoomDelta:e/128}}}else this._tap.touchmove(a,b,c)}touchend(a,c,b){this._tapTime?this._swipePoint&&0===b.length&&this.reset():this._tap.touchend(a,c,b)&&(this._tapTime=a.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class vd{constructor(a,b,c){this._el=a,this._mousePan=b,this._touchPan=c}enable(a){this._inertiaOptions=a||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class wd{constructor(a,b,c){this._pitchWithRotate=a.pitchWithRotate,this._mouseRotate=b,this._mousePitch=c}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class xd{constructor(a,b,c,d){this._el=a,this._touchZoom=b,this._touchRotate=c,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(a){this._touchZoom.enable(a),this._rotationDisabled||this._touchRotate.enable(a),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const yd=a=>a.zoom||a.drag||a.pitch||a.rotate;class zd extends a.Event{}function Ad(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}const Bd="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Cd extends a.Evented{constructor(b,c){super(),this._moving=!1,this._zooming=!1,this.transform=b,this._bearingSnap=c.bearingSnap,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(a,b){return this.jumpTo({center:a},b)}panBy(b,c,d){return b=a.pointGeometry.convert(b).mult(-1),this.panTo(this.transform.center,a.extend({offset:b},c),d)}panTo(b,c,d){return this.easeTo(a.extend({center:b},c),d)}getZoom(){return this.transform.zoom}setZoom(a,b){return this.jumpTo({zoom:a},b),this}zoomTo(b,c,d){return this.easeTo(a.extend({zoom:b},c),d)}zoomIn(a,b){return this.zoomTo(this.getZoom()+1,a,b),this}zoomOut(a,b){return this.zoomTo(this.getZoom()-1,a,b),this}getBearing(){return this.transform.bearing}setBearing(a,b){return this.jumpTo({bearing:a},b),this}getPadding(){return this.transform.padding}setPadding(a,b){return this.jumpTo({padding:a},b),this}rotateTo(b,c,d){return this.easeTo(a.extend({bearing:b},c),d)}resetNorth(b,c){return this.rotateTo(0,a.extend({duration:1e3},b),c),this}resetNorthPitch(b,c){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},b),c),this}snapToNorth(a,b){return Math.abs(this.getBearing())i=>{if(t&&(c.zoom=a.number(d,g,i)),u&&(c.bearing=a.number(e,n,i)),v&&(c.pitch=a.number(f,o,i)),w&&(c.interpolatePadding(z,p,i),h=c.centerPoint.add(q)),k)c.setLocationAtPoint(k,s);else{const l=c.zoomScale(c.zoom-d),x=g>d?Math.min(2,B):Math.max(.5,B),y=Math.pow(x,1-i),j=c.unproject(r.add(A.mult(i*y)).mult(l));c.setLocationAtPoint(c.renderWorldCopies?j.wrap():j,h)}return b.preloadOnly||this._fireMoveEvents(m),c};if(b.preloadOnly){const x=this._emulate(l,b.duration,c);return this._preloadTiles(x),this}const y={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=t,this._rotating=u,this._pitching=v,this._padding=w,this._easeId=b.easeId,this._prepareEase(m,b.noMoveStart,y),this._ease(l(c),a=>{c.recenterOnTerrain(),this._afterEase(m,a)},b),this}_prepareEase(b,d,c={}){this._moving=!0,this.transform.cameraElevationReference="sea",d||c.moving||this.fire(new a.Event("movestart",b)),this._zooming&&!c.zooming&&this.fire(new a.Event("zoomstart",b)),this._rotating&&!c.rotating&&this.fire(new a.Event("rotatestart",b)),this._pitching&&!c.pitching&&this.fire(new a.Event("pitchstart",b))}_fireMoveEvents(b){this.fire(new a.Event("move",b)),this._zooming&&this.fire(new a.Event("zoom",b)),this._rotating&&this.fire(new a.Event("rotate",b)),this._pitching&&this.fire(new a.Event("pitch",b))}_afterEase(b,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId,this.transform.cameraElevationReference="ground";const d=this._zooming,e=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new a.Event("zoomend",b)),e&&this.fire(new a.Event("rotateend",b)),f&&this.fire(new a.Event("pitchend",b)),this.fire(new a.Event("moveend",b))}flyTo(b,g){if(!b.essential&&a.exported.prefersReducedMotion){const r=a.pick(b,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,g)}this.stop(),b=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},b);const c=this.transform,f=this.getZoom(),h=this.getBearing(),k=this.getPitch(),J=this.getPadding(),l="zoom"in b?a.clamp(+b.zoom,c.minZoom,c.maxZoom):f,s="bearing"in b?this._normalizeBearing(b.bearing,h):h,t="pitch"in b?+b.pitch:k,u="padding"in b?b.padding:c.padding,v=c.zoomScale(l-f),w=a.pointGeometry.convert(b.offset);let x=c.centerPoint.add(w);const m=c.pointLocation(x),n=a.LngLat.convert(b.center||m);this._normalizeCenter(n);const y=c.project(m),z=c.project(n).sub(y);let d=b.curve;const e=Math.max(c.width,c.height),i=e/v,o=z.mag();if("minZoom"in b){const A=a.clamp(Math.min(b.minZoom,f,l),c.minZoom,c.maxZoom),B=e/c.zoomScale(A-f);d=Math.sqrt(B/o*2)}const K=d*d;function p(b){const a=(i*i-e*e+(b?-1:1)*K*K*o*o)/(2*(b?i:e)*K*o);return Math.log(Math.sqrt(a*a+1)-a)}function L(a){return(Math.exp(a)-Math.exp(-a))/2}function M(a){return(Math.exp(a)+Math.exp(-a))/2}const C=p(0);let D=function(a){return M(C)/M(C+d*a)},E=function(b){var a;return e*((M(C)*(L(a=C+d*b)/M(a))-L(C))/K)/o},j=(p(1)-C)/d;if(1e-6>Math.abs(o)||!isFinite(j)){if(1e-6>Math.abs(e-i))return this.easeTo(b,g);const N=ib.maxDuration&&(b.duration=0);const F=h!==s,G=t!==k,H=!c.isPaddingEqual(u),q=c=>d=>{const e=d*j,i=1/D(e);c.zoom=1===d?l:f+c.scaleZoom(i),F&&(c.bearing=a.number(h,s,d)),G&&(c.pitch=a.number(k,t,d)),H&&(c.interpolatePadding(J,u,d),x=c.centerPoint.add(w));const m=1===d?n:c.unproject(y.add(z.mult(E(e))).mult(i));return c.setLocationAtPoint(c.renderWorldCopies?m.wrap():m,x),c._updateCenterElevation(),b.preloadOnly||this._fireMoveEvents(g),c};if(b.preloadOnly){const I=this._emulate(q,b.duration,c);return this._preloadTiles(I),this}return this._zooming=!0,this._rotating=F,this._pitching=G,this._padding=H,this._prepareEase(g,!1),this._ease(q(c),()=>this._afterEase(g),b),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(b,c){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const d=this._onEaseEnd;delete this._onEaseEnd,d.call(this,c)}if(!b){const a=this.handlers;a&&a.stop(!1)}return this}_ease(c,d,b){!1===b.animate||0===b.duration?(c(1),d()):(this._easeStart=a.exported.now(),this._easeOptions=b,this._onEaseFrame=c,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const b=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(b)),b<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(b,c){b=a.wrap(b,-180,180);const d=Math.abs(b-c);return Math.abs(b-360-c)180?-360:c< -180?360:0}_emulate(d,e,f){const b=Math.ceil(15*e/1e3),c=[],g=d(f.clone());for(let a=0;a<=b;a++){const h=g(a/b);c.push(h.clone())}return c}}class y{constructor(b={}){this.options=b,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(c){const a=this.options&&this.options.compact;return this._map=c,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=b.create("button","mapboxgl-ctrl-attrib-button",this._container),b.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=b.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),a&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===a&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(a,c){const b=this._map._getUIString(`AttributionControl.${c}`);a.setAttribute("aria-label",b),a.removeAttribute("title"),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let b=this._editLink;b||(b=this._editLink=this._container.querySelector(".mapbox-improve-map"));const c=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN}];if(b){const d=c.reduce((b,a,d)=>(a.value&&(b+=`${a.key}=${a.value}${da.indexOf(b.attribution)&&a.push(b.attribution)}}a.sort((a,b)=>a.length-b.length),a=a.filter((c,d)=>{for(let b=d+1;b=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?a=[...this.options.customAttribution,...a]:a.unshift(this.options.customAttribution));const c=a.join(" | ");c!==this._attribHTML&&(this._attribHTML=c,a.length?(this._innerContainer.innerHTML=c,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Dd{constructor(){a.bindAll(["_updateLogo"],this),a.bindAll(["_updateCompact"],this)}onAdd(c){this._map=c,this._container=b.create("div","mapboxgl-ctrl");const a=b.create("a","mapboxgl-ctrl-logo");return a.target="_blank",a.rel="noopener nofollow",a.href="https://www.mapbox.com/",a.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),a.setAttribute("rel","noopener nofollow"),this._container.appendChild(a),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(a){a&&"metadata"!==a.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const a=this._map.style._sourceCaches;if(0===Object.entries(a).length)return!0;for(const c in a){const b=a[c].getSource();if(b.hasOwnProperty("mapbox_logo")&&!b.mapbox_logo)return!1}return!0}_updateCompact(){const a=this._container.children;if(a.length){const b=a[0];this._map.getCanvasContainer().offsetWidth<250?b.classList.add("mapboxgl-compact"):b.classList.remove("mapboxgl-compact")}}}class Ed{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(b){const a=++this._id;return this._queue.push({callback:b,id:a,cancelled:!1}),a}remove(c){const a=this._currentlyRunning,d=a?this._queue.concat(a):this._queue;for(const b of d)if(b.id===c)return void(b.cancelled=!0)}run(b=0){const c=this._currentlyRunning=this._queue;for(const a of(this._queue=[],c))if(!a.cancelled&&(a.callback(b),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Fd(b,d,c){if(b=new a.LngLat(b.lng,b.lat),d){const f=new a.LngLat(b.lng-360,b.lat),g=new a.LngLat(b.lng+360,b.lat),h=360*Math.ceil(Math.abs(b.lng-c.center.lng)/360),i=c.locationPoint(b).distSqr(d),j=d.x<0||d.y<0||d.x>c.width||d.y>c.height;c.locationPoint(f).distSqr(d)180;){const e=c.locationPoint(b);if(e.x>=0&&e.y>=0&&e.x<=c.width&&e.y<=c.height)break;b.lng>c.center.lng?b.lng-=360:b.lng+=360}return b}const Gd={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class z extends a.Evented{constructor(c,e){if(super(),(c instanceof a.window.HTMLElement||e)&&(c=a.extend({element:c},e)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=c&&c.anchor||"center",this._color=c&&c.color||"#3FB1CE",this._scale=c&&c.scale||1,this._draggable=c&&c.draggable||!1,this._clickTolerance=c&&c.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=c&&c.rotation||0,this._rotationAlignment=c&&c.rotationAlignment||"auto",this._pitchAlignment=c&&c.pitchAlignment&&"auto"!==c.pitchAlignment?c.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),c&&c.element)this._element=c.element,this._offset=a.pointGeometry.convert(c&&c.offset||[0,0]);else{this._defaultMarker=!0,this._element=b.create("div");const f=41,g=27,d=b.createSVG("svg",{display:"block",height:f*this._scale+"px",width:g*this._scale+"px",viewBox:`0 0 ${g} ${f}`},this._element),h=b.createSVG("radialGradient",{id:"shadowGradient"},b.createSVG("defs",{},d));b.createSVG("stop",{offset:"10%","stop-opacity":.4},h),b.createSVG("stop",{offset:"100%","stop-opacity":.05},h),b.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},d),b.createSVG("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},d),b.createSVG("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},d),b.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},d),this._offset=a.pointGeometry.convert(c&&c.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",a=>{a.preventDefault()}),this._element.addEventListener("mousedown",a=>{a.preventDefault()});const i=this._element.classList;for(const j in Gd)i.remove(`mapboxgl-marker-anchor-${j}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(a){return a===this._map||(this.remove(),this._map=a,a.getCanvasContainer().appendChild(this._element),a.on("move",this._updateMoving),a.on("moveend",this._update),a.on("remove",this._clearFadeTimer),a._addMarker(this),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick)),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(c){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),c){if(!("offset"in c.options)){const b=38.1,a=13.5,d=Math.sqrt(Math.pow(a,2)/2);c.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-b],"bottom-left":[d,-1*(b-a+d)],"bottom-right":[-d,-1*(b-a+d)],left:[a,-1*(b-a)],right:[-a,-1*(b-a)]}:this._offset}this._popup=c,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(a){const b=a.code,c=a.charCode||a.keyCode;"Space"!==b&&"Enter"!==b&&32!==c&&13!==c||this.togglePopup()}_onMapClick(c){const a=c.originalEvent.target,b=this._element;this._popup&&(a===b||b.contains(a))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const a=this._popup;return a&&(a.isOpen()?(a.remove(),this._element.setAttribute("aria-expanded","false")):(a.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_evaluateOpacity(){const a=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(a))return void this._clearFadeTimer();const b=this._map.unproject(a);let c=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const d=this._map.getFreeCameraOptions();if(d.position){const e=d.position.toLngLat();c=e.distanceTo(b)<.9*e.distanceTo(this._lngLat)}}const f=(1-this._map._queryFogOpacity(b))*(c?.2:1);this._element.style.opacity=`${f}`,this._popup&&this._popup._setOpacity(`${f}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(a){const b=this._map.transform;return!!a&&a.x>=0&&a.x=0&&a.y{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(this._map.getTerrain()||this._map.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const b=this._map.transform,a=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&a._rotate(b.angle),"map"===this._pitchAlignment&&(a.y*=Math.cos(b._pitch)),a}getOffset(){return this._offset}setOffset(b){return this._offset=a.pointGeometry.convert(b),this._update(),this}_onMove(b){if(!this._isDragging){const c=this._clickTolerance||this._map._clickTolerance;this._isDragging=b.point.dist(this._pointerdownPos)>=c}this._isDragging&&(this._pos=b.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new a.Event("dragstart"))),this.fire(new a.Event("drag")))}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new a.Event("dragend")),this._state="inactive"}_addDragHandler(a){this._element.contains(a.originalEvent.target)&&(a.preventDefault(),this._positionDelta=a.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=a.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(a){return this._draggable=!!a,this._map&&(a?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(a){return this._rotation=a||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(a){return this._rotationAlignment=a||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(a){return this._pitchAlignment=a&&"auto"!==a?a:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const{HTMLImageElement:Hd,HTMLElement:Id,ImageBitmap:Jd}=a.window;function Kd(a){a.parentNode&&a.parentNode.removeChild(a)}class Ld{constructor(c,b,d=!1){this._clickTolerance=10,this.element=b,this.mouseRotate=new ed({clickTolerance:c.dragRotate._mouseRotate._clickTolerance}),this.map=c,d&&(this.mousePitch=new fd({clickTolerance:c.dragRotate._mousePitch._clickTolerance})),a.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),b.addEventListener("mousedown",this.mousedown),b.addEventListener("touchstart",this.touchstart,{passive:!1}),b.addEventListener("touchmove",this.touchmove),b.addEventListener("touchend",this.touchend),b.addEventListener("touchcancel",this.reset)}down(a,c){this.mouseRotate.mousedown(a,c),this.mousePitch&&this.mousePitch.mousedown(a,c),b.disableDrag()}move(d,e){const a=this.map,b=this.mouseRotate.mousemoveWindow(d,e);if(b&&b.bearingDelta&&a.setBearing(a.getBearing()+b.bearingDelta),this.mousePitch){const c=this.mousePitch.mousemoveWindow(d,e);c&&c.pitchDelta&&a.setPitch(a.getPitch()+c.pitchDelta)}}off(){const a=this.element;a.removeEventListener("mousedown",this.mousedown),a.removeEventListener("touchstart",this.touchstart,{passive:!1}),a.removeEventListener("touchmove",this.touchmove),a.removeEventListener("touchend",this.touchend),a.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){b.enableDrag(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(c){this.down(a.extend({},c,{ctrlKey:!0,preventDefault:()=>c.preventDefault()}),b.mousePos(this.element,c)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(a){this.move(a,b.mousePos(this.element,a))}mouseup(a){this.mouseRotate.mouseupWindow(a),this.mousePitch&&this.mousePitch.mouseupWindow(a),this.offTemp()}touchstart(a){1!==a.targetTouches.length?this.reset():(this._startPos=this._lastPos=b.touchPos(this.element,a.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>a.preventDefault()},this._startPos))}touchmove(a){1!==a.targetTouches.length?this.reset():(this._lastPos=b.touchPos(this.element,a.targetTouches)[0],this.move({preventDefault:()=>a.preventDefault()},this._lastPos))}touchend(a){0===a.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)5280?Qd(d,c,f/5280,a._getUIString("ScaleControl.Miles"),a):Qd(d,c,f,a._getUIString("ScaleControl.Feet"),a)}else b&&"nautical"===b.unit?Qd(d,c,e/1852,a._getUIString("ScaleControl.NauticalMiles"),a):e>=1e3?Qd(d,c,e/1e3,a._getUIString("ScaleControl.Kilometers"),a):Qd(d,c,e,a._getUIString("ScaleControl.Meters"),a)}function Qd(d,e,a,f,b){const c=function(b){const c=Math.pow(10,`${Math.floor(b)}`.length-1);let a=b/c;return c*(a=a>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:(function(a){const b=Math.pow(10,Math.ceil(-Math.log(a)/Math.LN10));return Math.round(a*b)/b})(a))}(a),g=c/a;b._requestDomTask(()=>{d.style.width=e*g+"px",d.innerHTML=`${c} ${f}`})}const A={version:a.version,supported:l,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends Cd{constructor(c){if(null!=(c=a.extend({},{center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},c)).minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Nc(c.minZoom,c.maxZoom,c.minPitch,c.maxPitch,c.renderWorldCopies),c),this._interactive=c.interactive,this._minTileCacheSize=c.minTileCacheSize,this._maxTileCacheSize=c.maxTileCacheSize,this._failIfMajorPerformanceCaveat=c.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=c.preserveDrawingBuffer,this._antialias=c.antialias,this._trackResize=c.trackResize,this._bearingSnap=c.bearingSnap,this._refreshExpiredTiles=c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=c.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=c.collectResourceTiming,this._optimizeForTerrain=c.optimizeForTerrain,this._renderTaskQueue=new Ed,this._domRenderTaskQueue=new Ed,this._controls=[],this._markers=[],this._mapId=a.uniqueId(),this._locale=a.extend({},{"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},c.locale),this._clickTolerance=c.clickTolerance,this._cooperativeGestures=c.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new class{constructor(a){this.jumpTo(a)}getValue(b){if(b<=this._startTime)return this._start;if(b>=this._endTime)return this._end;const c=a.easeCubicInOut((b-this._startTime)/(this._endTime-this._startTime));return this._start*(1-c)+this._end*c}isEasing(a){return a>=this._startTime&&a<=this._endTime}jumpTo(a){this._startTime=-1/0,this._endTime=-1/0,this._start=a,this._end=a}easeTo(b,a,c){this._start=this.getValue(a),this._end=b,this._startTime=a,this._endTime=a+c}}(0),this._requestManager=new a.RequestManager(c.transformRequest,c.accessToken,c.testMode),this._silenceAuthErrors=!!c.testMode,"string"==typeof c.container){if(this._container=a.window.document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof Id))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(this._container.childNodes.length>0&&a.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),c.maxBounds&&this.setMaxBounds(c.maxBounds),a.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==a.window&&(a.window.addEventListener("online",this._onWindowOnline,!1),a.window.addEventListener("resize",this._onWindowResize,!1),a.window.addEventListener("orientationchange",this._onWindowResize,!1),a.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new class{constructor(c,d){this._map=c,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new class{constructor(a){this._map=a,this.clear()}clear(){this._inertiaBuffer=[]}record(b){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:b})}_drainInertiaBuffer(){const b=this._inertiaBuffer,c=a.exported.now();for(;b.length>0&&c-b[0].time>160;)b.shift()}_onMoveEnd(k){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const b={zoom:0,bearing:0,pitch:0,pan:new a.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)b.zoom+=d.zoomDelta||0,b.bearing+=d.bearingDelta||0,b.pitch+=d.pitchDelta||0,d.panDelta&&b.pan._add(d.panDelta),d.around&&(b.around=d.around),d.pinchAround&&(b.pinchAround=d.pinchAround);const e=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(b.pan.mag()){const f=Uc(b.pan.mag(),e,a.extend({},Pc,k||{}));c.offset=b.pan.mult(f.amount/b.pan.mag()),c.center=this._map.transform.center,Tc(c,f)}if(b.zoom){const g=Uc(b.zoom,e,Qc);c.zoom=this._map.transform.zoom+g.amount,Tc(c,g)}if(b.bearing){const h=Uc(b.bearing,e,Rc);c.bearing=this._map.transform.bearing+a.clamp(h.amount,-179,179),Tc(c,h)}if(b.pitch){const i=Uc(b.pitch,e,Sc);c.pitch=this._map.transform.pitch+i.amount,Tc(c,i)}if(c.zoom||c.bearing){const j=void 0===b.pinchAround?b.around:b.pinchAround;c.around=j?this._map.unproject(j):this._map.getCenter()}return this.clear(),a.extend(c,{noMoveStart:!0})}}(c),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new class{constructor(){this.constants=[1,1,.01],this.radius=0}setup(c,d){const b=a.sub([],d,c);this.radius=a.length(b[2]<0?a.div([],b,this.constants):[b[0],b[1],0])}projectRay(c){a.div(c,c,this.constants),a.normalize(c,c),a.mul$1(c,c,this.constants);const b=a.scale$2([],c,this.radius);if(b[2]>0){const e=a.scale$2([],[0,0,1],a.dot(b,[0,0,1])),f=a.scale$2([],a.normalize([],[b[0],b[1],0]),this.radius),d=a.add([],b,a.scale$2([],a.sub([],a.add([],f,e),b),2));b[0]=d[0],b[1]=d[1]}return b}},this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(d),a.bindAll(["handleEvent","handleWindowEvent"],this);const b=this._el;for(const[e,f,g]of(this._listeners=[[b,"touchstart",{passive:!0}],[b,"touchmove",{passive:!1}],[b,"touchend",void 0],[b,"touchcancel",void 0],[b,"mousedown",void 0],[b,"mousemove",void 0],[b,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0}],[a.window.document,"mouseup",void 0],[b,"mouseover",void 0],[b,"mouseout",void 0],[b,"dblclick",void 0],[b,"click",void 0],[b,"keydown",{capture:!1}],[b,"keyup",void 0],[b,"wheel",{passive:!1}],[b,"contextmenu",void 0],[a.window,"blur",void 0]],this._listeners))e.addEventListener(f,e===a.window.document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[b,c,d]of this._listeners)b.removeEventListener(c,b===a.window.document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(b){const a=this._map,d=a.getCanvasContainer();this._add("mapEvent",new Yc(a,b));const n=a.boxZoom=new $c(a,b);this._add("boxZoom",n);const e=new bd,f=new td;a.doubleClickZoom=new sd(f,e),this._add("tapZoom",e),this._add("clickZoom",f);const g=new ud;this._add("tapDragZoom",g);const o=a.touchPitch=new nd(a);this._add("touchPitch",o);const h=new ed(b),i=new fd(b);a.dragRotate=new wd(b,h,i),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",i,["mouseRotate"]);const j=new dd(b),k=new gd(a,b);a.dragPan=new vd(d,j,k),this._add("mousePan",j),this._add("touchPan",k,["touchZoom","touchRotate"]);const l=new ld,m=new jd;a.touchZoomRotate=new xd(d,m,l,g),this._add("touchRotate",l,["touchPan","touchZoom"]),this._add("touchZoom",m,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Zc(a));const p=a.scrollZoom=new rd(a,this);this._add("scrollZoom",p,["mousePan"]);const q=a.keyboard=new od;for(const c of(this._add("keyboard",q),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"]))b.interactive&&b[c]&&a[c].enable(b[c])}_add(a,b,c){this._handlers.push({handlerName:a,handler:b,allowed:c}),this._handlersById[a]=b}stop(a){if(!this._updatingCamera){for(const{handler:b}of this._handlers)b.reset();this._inertia.clear(),this._fireEvents({},{},a),this._changes=[]}}isActive(){for(const{handler:a}of this._handlers)if(a.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(yd(this._eventsInProgress))||this.isZooming()}_blockedByActive(c,a,d){for(const b in c)if(b!==d&&(!a||0>a.indexOf(b)))return!0;return!1}handleWindowEvent(a){this.handleEvent(a,`${a.type}Window`)}_getMapTouches(c){const a=[];for(const b of c)this._el.contains(b.target)&&a.push(b);return a}handleEvent(a,j){this._updatingCamera=!0;const k="renderFrame"===a.type,l=k?void 0:a,d={needsRenderFrame:!1},m={},e={},g=a.touches?this._getMapTouches(a.touches):void 0,p=g?b.touchPos(this._el,g):k?void 0:b.mousePos(this._el,a);for(const{handlerName:h,handler:c,allowed:q}of this._handlers){if(!c.isEnabled())continue;let f;this._blockedByActive(e,q,h)?c.reset():c[j||a.type]&&(f=c[j||a.type](a,p,g),this.mergeHandlerResult(d,m,f,h,l),f&&f.needsRenderFrame&&this._triggerRenderFrame()),(f||c.isActive())&&(e[h]=c)}const i={};for(const n in this._previousActiveHandlers)e[n]||(i[n]=l);this._previousActiveHandlers=e,(Object.keys(i).length||Ad(d))&&(this._changes.push([d,m,i]),this._triggerRenderFrame()),(Object.keys(e).length||Ad(d))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:o}=d;o&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],o(this._map))}mergeHandlerResult(e,c,b,f,g){if(!b)return;a.extend(e,b);const d={handlerName:f,originalEvent:b.originalEvent||g};void 0!==b.zoomDelta&&(c.zoom=d),void 0!==b.panDelta&&(c.drag=d),void 0!==b.pitchDelta&&(c.pitch=d),void 0!==b.bearingDelta&&(c.rotate=d)}_applyChanges(){const c={},d={},e={};for(const[b,f,g]of this._changes)b.panDelta&&(c.panDelta=(c.panDelta||new a.pointGeometry(0,0))._add(b.panDelta)),b.zoomDelta&&(c.zoomDelta=(c.zoomDelta||0)+b.zoomDelta),b.bearingDelta&&(c.bearingDelta=(c.bearingDelta||0)+b.bearingDelta),b.pitchDelta&&(c.pitchDelta=(c.pitchDelta||0)+b.pitchDelta),void 0!==b.around&&(c.around=b.around),void 0!==b.aroundCoord&&(c.aroundCoord=b.aroundCoord),void 0!==b.pinchAround&&(c.pinchAround=b.pinchAround),b.noInertia&&(c.noInertia=b.noInertia),a.extend(d,f),a.extend(e,g);this._updateMapTransform(c,d,e),this._changes=[]}_updateMapTransform(d,f,k){const g=this._map,b=g.transform,l=a=>[a.x,a.y,a.z];if((b=>{const a=this._eventsInProgress.drag;return a&&!this._handlersById[a.handlerName].isActive()})()&&!Ad(d)){const t=b.zoom;b.cameraElevationReference="sea",b.recenterOnTerrain(),b.cameraElevationReference="ground",t!==b.zoom&&this._map._update(!0)}if(!Ad(d))return this._fireEvents(f,k,!0);let{panDelta:m,zoomDelta:h,bearingDelta:n,pitchDelta:o,around:c,aroundCoord:u,pinchAround:p}=d;void 0!==p&&(c=p),f.drag&&!this._eventsInProgress.drag&&c&&(this._dragOrigin=l(b.pointCoordinate3D(c)),this._trackingEllipsoid.setup(b._camera.position,this._dragOrigin)),b.cameraElevationReference="sea",g._stop(!0),c=c||g.transform.centerPoint,n&&(b.bearing+=n),o&&(b.pitch+=o),b._updateCameraState();const e=[0,0,0];if(m){const i=b.pointCoordinate(c),j=b.pointCoordinate(c.sub(m));i&&j&&(e[0]=j.x-i.x,e[1]=j.y-i.y)}const v=b.zoom,q=[0,0,0];if(h){const r=l(u||b.pointCoordinate3D(c)),s={dir:a.normalize([],a.sub([],r,b._camera.position))};if(s.dir[2]<0){const w=b.zoomDeltaToMovement(r,h);a.scale$2(q,s.dir,w)}}const x=a.add(e,e,q);b._translateCameraConstrained(x),h&&Math.abs(b.zoom-v)>1e-4&&b.recenterOnTerrain(),b.cameraElevationReference="ground",this._map._update(),d.noInertia||this._inertia.record(d),this._fireEvents(f,k,!0)}_fireEvents(b,p,q){const j=yd(this._eventsInProgress),c=yd(b),g={};for(const d in b){const{originalEvent:r}=b[d];this._eventsInProgress[d]||(g[`${d}start`]=r),this._eventsInProgress[d]=b[d]}for(const k in!j&&c&&this._fireEvent("movestart",c.originalEvent),g)this._fireEvent(k,g[k]);for(const l in c&&this._fireEvent("move",c.originalEvent),b){const{originalEvent:s}=b[l];this._fireEvent(l,s)}const h={};let e;for(const i in this._eventsInProgress){const{handlerName:m,originalEvent:t}=this._eventsInProgress[i];this._handlersById[m].isActive()||(delete this._eventsInProgress[i],e=p[m]||t,h[`${i}end`]=e)}for(const n in h)this._fireEvent(n,h[n]);const u=yd(this._eventsInProgress);if(q&&(j||c)&&!u){this._updatingCamera=!0;const f=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),o=a=>0!==a&& -this._bearingSnap{delete this._frameId,this.handleEvent(new zd("renderFrame",{timeStamp:a})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}(this,c),this._localFontFamily=c.localFontFamily,this._localIdeographFontFamily=c.localIdeographFontFamily,c.style&&this.setStyle(c.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),c.projection&&this.setProjection(c.projection),this._hash=c.hash&&new class{constructor(b){this._hashName=b&&encodeURIComponent(b),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Oc(this._updateHashUnthrottled.bind(this),300)}addTo(b){return this._map=b,a.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return a.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(k){const f=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,c=Math.pow(10,Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10)),g=Math.round(f.lng*c)/c,h=Math.round(f.lat*c)/c,i=this._map.getBearing(),e=this._map.getPitch();let b="";if(b+=k?`/${g}/${h}/${d}`:`${d}/${h}/${g}`,(i||e)&&(b+="/"+Math.round(10*i)/10),e&&(b+=`/${Math.round(e)}`),this._hashName){const l=this._hashName;let m=!1;const j=a.window.location.hash.slice(1).split("&").map(a=>{const c=a.split("=")[0];return c===l?(m=!0,`${c}=${b}`):a}).filter(a=>a);return m||j.push(`${l}=${b}`),`#${j.join("&")}`}return`#${b}`}_getCurrentHash(){const b=a.window.location.hash.replace("#","");if(this._hashName){let c;return b.split("&").map(a=>a.split("=")).forEach(a=>{a[0]===this._hashName&&(c=a)}),(c&&c[1]||"").split("/")}return b.split("/")}_onHashChange(){const a=this._getCurrentHash();if(a.length>=3&&!a.some(a=>isNaN(a))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(a[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+a[2],+a[1]],zoom:+a[0],bearing:b,pitch:+(a[4]||0)}),!0}return!1}_updateHashUnthrottled(){const b=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,b)}}("string"==typeof c.hash&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.extend({},c.fitBoundsOptions,{duration:0})))),this.resize(),c.attributionControl&&this.addControl(new y({customAttribution:c.customAttribution})),this._logoControl=new Dd,this.addControl(this._logoControl,c.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",b=>{this._update("style"===b.dataType),this.fire(new a.Event(`${b.dataType}data`,b))}),this.on("dataloading",b=>{this.fire(new a.Event(`${b.dataType}dataloading`,b))})}_getMapId(){return this._mapId}addControl(b,c){if(void 0===c&&(c=b.getDefaultPosition?b.getDefaultPosition():"top-right"),!b||!b.onAdd)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const e=b.onAdd(this);this._controls.push(b);const d=this._controlPositions[c];return -1!==c.indexOf("bottom")?d.insertBefore(e,d.firstChild):d.appendChild(e),this}removeControl(b){if(!b||!b.onRemove)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const c=this._controls.indexOf(b);return c> -1&&this._controls.splice(c,1),b.onRemove(this),this}hasControl(a){return this._controls.indexOf(a)> -1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(b){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const c=!this._moving;return c&&this.fire(new a.Event("movestart",b)).fire(new a.Event("move",b)),this.fire(new a.Event("resize",b)),c&&this.fire(new a.Event("moveend",b)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(b){return this.transform.setMaxBounds(a.LngLatBounds.convert(b)),this._update()}setMinZoom(b){if((b=null==b?-2:b)>= -2&&b<=this.transform.maxZoom)return this.transform.minZoom=b,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=b,this._update(),this.getZoom()>b?this.setZoom(b):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(b){if((b=null==b?0:b)<0)throw new Error("minPitch must be greater than or equal to 0");if(b>=0&&b<=this.transform.maxPitch)return this.transform.minPitch=b,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(b>=this.transform.minPitch)return this.transform.maxPitch=b,this._update(),this.getPitch()>b?this.setPitch(b):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(a){return this.transform.renderWorldCopies=a,this._update()}getProjection(){return this.transform.getProjection()}setProjection(a){return this._lazyInitEmptyStyle(),"string"==typeof a&&(a={name:a}),this._runtimeProjection=a,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(b){return this.transform.locationPoint3D(a.LngLat.convert(b))}unproject(b){return this.transform.pointLocation3D(a.pointGeometry.convert(b))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(a,b,c){if("mouseenter"===a||"mouseover"===a){let h=!1;const d=d=>{const e=b.filter(a=>this.getLayer(a)),f=e.length?this.queryRenderedFeatures(d.point,{layers:e}):[];f.length?h||(h=!0,c.call(this,new Vc(a,this,d.originalEvent,{features:f}))):h=!1},e=()=>{h=!1};return{layers:new Set(b),listener:c,delegates:{mousemove:d,mouseout:e}}}if("mouseleave"===a||"mouseout"===a){let i=!1;const f=d=>{const e=b.filter(a=>this.getLayer(a));(e.length?this.queryRenderedFeatures(d.point,{layers:e}):[]).length?i=!0:i&&(i=!1,c.call(this,new Vc(a,this,d.originalEvent)))},g=b=>{i&&(i=!1,c.call(this,new Vc(a,this,b.originalEvent)))};return{layers:new Set(b),listener:c,delegates:{mousemove:f,mouseout:g}}}return{layers:new Set(b),listener:c,delegates:{[a]:a=>{const d=b.filter(a=>this.getLayer(a)),e=d.length?this.queryRenderedFeatures(a.point,{layers:d}):[];e.length&&(a.features=e,c.call(this,a),delete a.features)}}}}on(a,b,d){if(void 0===d)return super.on(a,b);Array.isArray(b)||(b=[b]);const c=this._createDelegatedListener(a,b,d);for(const e in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[a]=this._delegatedListeners[a]||[],this._delegatedListeners[a].push(c),c.delegates)this.on(e,c.delegates[e]);return this}once(b,a,c){if(void 0===c)return super.once(b,a);Array.isArray(a)||(a=[a]);const d=this._createDelegatedListener(b,a,c);for(const e in d.delegates)this.once(e,d.delegates[e]);return this}off(b,a,d){if(void 0===d)return super.off(b,a);a=new Set(Array.isArray(a)?a:[a]);const e=(a,b)=>{if(a.size!==b.size)return!1;for(const c of a)if(!b.has(c))return!1;return!0},c=this._delegatedListeners?this._delegatedListeners[b]:void 0;return c&&(f=>{for(let b=0;b{b?this.fire(new a.ErrorEvent(b)):d&&this._updateDiff(d,c)})}else"object"==typeof b&&this._updateDiff(b,c)}_updateDiff(c,d){try{this.style.setState(c)&&this._update(!0)}catch(b){a.warnOnce(`Unable to perform style diff: ${b.message||b.error||b}. Rebuilding the style from scratch.`),this._updateStyle(c,d)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.warnOnce("There is no style added to the map.")}addSource(a,b){return this._lazyInitEmptyStyle(),this.style.addSource(a,b),this._update(!0)}isSourceLoaded(b){const c=this.style&&this.style._getSourceCaches(b);if(0!==c.length)return c.every(a=>a.loaded());this.fire(new a.ErrorEvent(new Error(`There is no source with ID '${b}'`)))}areTilesLoaded(){const a=this.style&&this.style._sourceCaches;for(const d in a){const b=a[d]._tiles;for(const e in b){const c=b[e];if("loaded"!==c.state&&"errored"!==c.state)return!1}}return!0}addSourceType(a,b,c){return this._lazyInitEmptyStyle(),this.style.addSourceType(a,b,c)}removeSource(a){return this.style.removeSource(a),this._updateTerrain(),this._update(!0)}getSource(a){return this.style.getSource(a)}addImage(c,b,{pixelRatio:e=1,sdf:f=!1,stretchX:g,stretchY:h,content:i}={}){if(this._lazyInitEmptyStyle(),b instanceof Hd||Jd&&b instanceof Jd){const{width:j,height:k,data:l}=a.exported.getImageData(b);this.style.addImage(c,{data:new a.RGBAImage({width:j,height:k},l),pixelRatio:e,stretchX:g,stretchY:h,content:i,sdf:f,version:0})}else{if(void 0===b.width|| void 0===b.height)return this.fire(new a.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:m,height:n,data:o}=b,d=b;this.style.addImage(c,{data:new a.RGBAImage({width:m,height:n},new Uint8Array(o)),pixelRatio:e,stretchX:g,stretchY:h,content:i,sdf:f,version:0,userImage:d}),d.onAdd&&d.onAdd(this,c)}}}updateImage(d,b){const c=this.style.getImage(d);if(!c)return this.fire(new a.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const g=b instanceof Hd||Jd&&b instanceof Jd?a.exported.getImageData(b):b,{width:e,height:f,data:h}=g;return void 0===e|| void 0===f?this.fire(new a.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`"))):e!==c.data.width||f!==c.data.height?this.fire(new a.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image"))):(c.data.replace(h,!(b instanceof Hd||Jd&&b instanceof Jd)),void this.style.updateImage(d,c))}hasImage(b){return b?!!this.style.getImage(b):(this.fire(new a.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(a){this.style.removeImage(a)}loadImage(b,c){a.getImage(this._requestManager.transformRequest(b,a.ResourceType.Image),(d,b)=>{c(d,b instanceof Hd?a.exported.getImageData(b):b)})}listImages(){return this.style.listImages()}addLayer(a,b){return this._lazyInitEmptyStyle(),this.style.addLayer(a,b),this._update(!0)}moveLayer(a,b){return this.style.moveLayer(a,b),this._update(!0)}removeLayer(a){return this.style.removeLayer(a),this._update(!0)}getLayer(a){return this.style.getLayer(a)}setLayerZoomRange(a,b,c){return this.style.setLayerZoomRange(a,b,c),this._update(!0)}setFilter(a,b,c={}){return this.style.setFilter(a,b,c),this._update(!0)}getFilter(a){return this.style.getFilter(a)}setPaintProperty(a,b,c,d={}){return this.style.setPaintProperty(a,b,c,d),this._update(!0)}getPaintProperty(a,b){return this.style.getPaintProperty(a,b)}setLayoutProperty(a,b,c,d={}){return this.style.setLayoutProperty(a,b,c,d),this._update(!0)}getLayoutProperty(a,b){return this.style.getLayoutProperty(a,b)}setLight(a,b={}){return this._lazyInitEmptyStyle(),this.style.setLight(a,b),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(a){return this._lazyInitEmptyStyle(),!a&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(a),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){"globe"===this.transform.projection.name&&this.transform.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(a){return this._lazyInitEmptyStyle(),this.style.setFog(a),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(b){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.LngLat.convert(b),this.transform):0}setFeatureState(a,b){return this.style.setFeatureState(a,b),this._update()}removeFeatureState(a,b){return this.style.removeFeatureState(a,b),this._update()}getFeatureState(a){return this.style.getFeatureState(a)}_updateContainerDimensions(){if(!this._container)return;const d=this._container.getBoundingClientRect().width||400,e=this._container.getBoundingClientRect().height||300;let b,c=this._container;for(;c&&!b;){const f=a.window.getComputedStyle(c).transform;f&&"none"!==f&&(b=f.match(/matrix.*\((.+)\)/)[1].split(", ")),c=c.parentElement}b?(this._containerWidth=b[0]&&"0"!==b[0]?Math.abs(d/b[0]):d,this._containerHeight=b[3]&&"0"!==b[3]?Math.abs(e/b[3]):e):(this._containerWidth=d,this._containerHeight=e)}_detectMissingCSS(){"rgb(250, 128, 114)"!==a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&a.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const a=this._container;a.classList.add("mapboxgl-map"),(this._missingCSSCanary=b.create("div","mapboxgl-canary",a)).style.visibility="hidden",this._detectMissingCSS();const c=this._canvasContainer=b.create("div","mapboxgl-canvas-container",a);this._interactive&&c.classList.add("mapboxgl-interactive"),this._canvas=b.create("canvas","mapboxgl-canvas",c),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const d=this._controlContainer=b.create("div","mapboxgl-control-container",a),e=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(a=>{e[a]=b.create("div",`mapboxgl-ctrl-${a}`,d)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(b,c){const d=a.exported.devicePixelRatio||1;this._canvas.width=d*Math.ceil(b),this._canvas.height=d*Math.ceil(c),this._canvas.style.width=`${b}px`,this._canvas.style.height=`${c}px`}_addMarker(a){this._markers.push(a)}_removeMarker(b){const a=this._markers.indexOf(b);-1!==a&&this._markers.splice(a,1)}_setupPainter(){const c=a.extend({},l.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),b=this._canvas.getContext("webgl",c)||this._canvas.getContext("experimental-webgl",c);b?(a.storeAuthState(b,!0),this.painter=new Ac(b,this.transform),this.on("data",a=>{"source"===a.dataType&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(b)):this.fire(new a.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(b){b.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:b}))}_contextRestored(b){this._setupPainter(),this.resize(),this._update(),this.fire(new a.Event("webglcontextrestored",{originalEvent:b}))}_onMapScroll(a){if(a.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(a){return this.style&&(this._styleDirty=this._styleDirty||a,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(a){return this._update(),this._renderTaskQueue.add(a)}_cancelRenderFrame(a){this._renderTaskQueue.remove(a)}_requestDomTask(a){!this.loaded()||this.loaded()&&!this.isMoving()?a():this._domRenderTaskQueue.add(a)}_render(h){let c;const b=this.painter.context.extTimerQuery,d=a.exported.now();this.listens("gpu-timing-frame")&&(c=b.createQueryEXT(),b.beginQueryEXT(b.TIME_ELAPSED_EXT,c));let e=this._updateAverageElevation(d);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._domRenderTaskQueue.run(h),this._removed)return;this._updateProjection();let i=!1;const f=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const j=this.transform.zoom,o=this.transform.pitch,k=a.exported.now();this.style.zoomHistory.update(j,k);const l=new a.EvaluationParameters(j,{now:k,fadeDuration:f,pitch:o,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=l.crossFadingFactor();1===g&&g===this._crossFadingFactor||(i=!0,this._crossFadingFactor=g),this.style.update(l)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,f,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:f,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.Event("load"))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const q=a.exported.now()-d;b.endQueryEXT(b.TIME_ELAPSED_EXT,c),setTimeout(()=>{const d=b.getQueryObjectEXT(c,b.QUERY_RESULT_EXT)/1e6;b.deleteQueryEXT(c),this.fire(new a.Event("gpu-timing-frame",{cpuTime:q,gpuTime:d}))},50)}if(this.listens("gpu-timing-layer")){const r=this.painter.collectGpuTimers();setTimeout(()=>{const b=this.painter.queryGpuTimers(r);this.fire(new a.Event("gpu-timing-layer",{layerTimes:b}))},50)}const m=this._sourcesDirty||this._styleDirty||this._placementDirty||e;if(m||this._repaint)this.triggerRepaint();else{const n=!this.isMoving()&&this.loaded();if(n&&(e=this._updateAverageElevation(d,!0)),e)this.triggerRepaint();else if(this._triggerFrame(!1),n&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const p=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:p})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||m||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const a of this._markers)a._update()}_updateAverageElevation(b,e=!1){const c=a=>(this.transform.averageElevation=a,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&c(0);if((e||b-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(b)){const f=this.transform.averageElevation;let a=this.transform.sampleAverageElevation();isNaN(a)?a=0:this._averageElevationLastSampledAt=b;const d=Math.abs(f-a);if(d>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(a),c(a);this._averageElevation.easeTo(a,b,300)}else if(d>1e-4)return this._averageElevation.jumpTo(a),c(a)}return!!this._averageElevation.isEasing(b)&&c(this._averageElevation.getValue(b))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,c=>{if(c&&(c.message===a.AUTH_ERR_MSG||401===c.status)){const b=this.painter.context.gl;a.storeAuthState(b,!1),this._logoControl instanceof Dd&&this._logoControl._updateLogo(),b&&b.clear(b.DEPTH_BUFFER_BIT|b.COLOR_BUFFER_BIT|b.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),a.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const d=this.painter.canvasCopy(),a=this.painter.getCanvasCopiesAndTimestamps();a.timeStamps.push(performance.now());const b=this.painter.context.gl,e=b.createFramebuffer();function c(c){b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,c,0);const a=new Uint8Array(b.drawingBufferWidth*b.drawingBufferHeight*4);return b.readPixels(0,0,b.drawingBufferWidth,b.drawingBufferHeight,b.RGBA,b.UNSIGNED_BYTE,a),a}return b.bindFramebuffer(b.FRAMEBUFFER,e),this._canvasPixelComparison(c(d),a.canvasCopies.map(c),a.timeStamps)}_canvasPixelComparison(b,f,e){let g=e[1]-e[0];const i=b.length/4;for(let c=0;c{const b=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,b&&this._render(a)}))}_preloadTiles(c){const b=this.style&&Object.values(this.style._sourceCaches)||[];return a.asyncAll(b,(a,b)=>a._preloadTiles(c,b),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(a){this._trackResize&&this.resize({originalEvent:a})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(a){this._showTileBoundaries!==a&&(this._showTileBoundaries=a,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(a){this._showTerrainWireframe!==a&&(this._showTerrainWireframe=a,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(a){this._speedIndexTiming!==a&&(this._speedIndexTiming=a,this._update())}get showPadding(){return!!this._showPadding}set showPadding(a){this._showPadding!==a&&(this._showPadding=a,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(a){this._showCollisionBoxes!==a&&(this._showCollisionBoxes=a,a?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(a){this._showOverdrawInspector!==a&&(this._showOverdrawInspector=a,this._update())}get repaint(){return!!this._repaint}set repaint(a){this._repaint!==a&&(this._repaint=a,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(a){this._vertices=a,this._update()}_setCacheLimits(b,c){a.setCacheLimits(b,c)}get version(){return a.version}},NavigationControl:class{constructor(c){this.options=a.extend({},{showCompass:!0,showZoom:!0,visualizePitch:!1},c),this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",a=>a.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",a=>this._map.zoomIn({},{originalEvent:a})),b.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",a=>this._map.zoomOut({},{originalEvent:a})),b.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",a=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:a}):this._map.resetNorth({},{originalEvent:a})}),this._compassIcon=b.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const a=this._map.getZoom(),b=a===this._map.getMaxZoom(),c=a===this._map.getMinZoom();this._zoomInButton.disabled=b,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",b.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.toString())}_rotateCompassArrow(){const a=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=a)})}onAdd(a){return this._map=a,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ld(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(c,d){const a=b.create("button",c,this._container);return a.type="button",a.addEventListener("click",d),a}_setButtonTitle(a,c){const b=this._map._getUIString(`NavigationControl.${c}`);a.setAttribute("aria-label",b),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}},GeolocateControl:class extends a.Evented{constructor(b){super(),this.options=a.extend({},{positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},b),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation"],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=Oc(this._updateMarkerRotation,20)}onAdd(d){var c;return this._map=d,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),c=this._setupUI,void 0!==Md?c(Md):void 0!==a.window.navigator.permissions?a.window.navigator.permissions.query({name:"geolocation"}).then(a=>{c(Md="denied"!==a.state)}):c(Md=!!a.window.navigator.geolocation),this._container}onRemove(){void 0!==this._geolocationWatchID&&(a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,Nd=0,Od=!1}_isOutOfMapMaxBounds(c){const a=this._map.getMaxBounds(),b=c.coords;return a&&(b.longitudea.getEast()||b.latitudea.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(b){if(this._map){if(this._isOutOfMapMaxBounds(b))return this._setErrorState(),this.fire(new a.Event("outofmaxbounds",b)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=b,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(b),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(b),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("geolocate",b)),this._finish()}}_updateCamera(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude),d=b.coords.accuracy,e=this._map.getBearing(),f=a.extend({bearing:e},this.options.fitBoundsOptions);this._map.fitBounds(c.toBounds(d),f,{geolocateSource:!0})}_updateMarker(b){if(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=b.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const a=this._map._containerHeight/2,c=this._map.unproject([0,a]),d=this._map.unproject([100,a]),e=c.distanceTo(d)/100,b=Math.ceil(2*this._accuracy/e);this._circleElement.style.width=`${b}px`,this._circleElement.style.height=`${b}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(b){if(this._map){if(this.options.trackUserLocation)if(1===b.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===b.code&&Od)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",b)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",a=>a.preventDefault()),this._geolocateButton=b.create("button","mapboxgl-ctrl-geolocate",this._container),b.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===e){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c)}else{const d=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",d),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",d)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=b.create("div","mapboxgl-user-location"),this._dotElement.appendChild(b.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(b.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new z({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=b.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new z({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",b=>{b.geolocateSource||"ACTIVE_LOCK"!==this._watchState||b.originalEvent&&"resize"===b.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.Event("trackuserlocationend")))})}_onDeviceOrientation(a){this._userLocationDotMarker&&(a.webkitCompassHeading?this._heading=a.webkitCompassHeading:!0===a.absolute&&(this._heading=-1*a.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new a.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Nd--,Od=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new a.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&& void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let b;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Nd++,Nd>1?(b={maximumAge:6e5,timeout:0},Od=!0):(b=this.options.positionOptions,Od=!1),this._geolocationWatchID=a.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,b),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else a.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const b=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};void 0!==a.window.DeviceMotionEvent&&"function"==typeof a.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(a=>{"granted"===a&&b()}).catch(console.error):b()}_clearWatch(){a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),a.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:y,ScaleControl:class{constructor(b){this.options=a.extend({},{maxWidth:100,unit:"metric"},b),a.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){Pd(this._map,this._container,this.options)}onAdd(a){return this._map=a,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",a.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(a){this.options.unit=a,Pd(this._map,this._container,this.options)}},FullscreenControl:class{constructor(b){this._fullscreen=!1,b&&b.container&&(b.container instanceof a.window.HTMLElement?this._container=b.container:a.warnOnce("Full screen control 'container' must be a DOM element.")),a.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in a.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in a.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(c){return this._map=c,this._container||(this._container=this._map.getContainer()),this._controlContainer=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,a.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!a.window.document.fullscreenEnabled&&!a.window.document.webkitFullscreenEnabled)}_setupUI(){const c=this._fullscreenButton=b.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);b.create("span","mapboxgl-ctrl-icon",c).setAttribute("aria-hidden",!0),c.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const a=this._getTitle();this._fullscreenButton.setAttribute("aria-label",a),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",a)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(a.window.document.fullscreenElement||a.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?a.window.document.exitFullscreen?a.window.document.exitFullscreen():a.window.document.webkitCancelFullScreen&&a.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.Evented{constructor(b){super(),this.options=a.extend(Object.create({closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"}),b),a.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this),this._classList=new Set(b&&b.className?b.className.trim().split(/\s+/):[])}addTo(b){return this._map&&this.remove(),this._map=b,this.options.closeOnClick&&this._map.on("preclick",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new a.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(b){return this.setDOMContent(a.window.document.createTextNode(b))}setHTML(e){const b=a.window.document.createDocumentFragment(),c=a.window.document.createElement("body");let d;for(c.innerHTML=e;d=c.firstChild;)b.appendChild(d);return this.setDOMContent(b)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(a){return this.options.maxWidth=a,this._update(),this}setDOMContent(a){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=b.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(a),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(a){return this._classList.add(a),this._container&&this._updateClassList(),this}removeClassName(a){return this._classList.delete(a),this._container&&this._updateClassList(),this}setOffset(a){return this.options.offset=a,this._update(),this}toggleClassName(b){let a;return this._classList.delete(b)?a=!1:(this._classList.add(b),a=!0),this._container&&this._updateClassList(),a}_createCloseButton(){this.options.closeButton&&(this._closeButton=b.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(a){this._update(a.point)}_onMouseMove(a){this._update(a.point)}_onDrag(a){this._update(a.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const b=this._pos,c=this._container.offsetWidth,d=this._container.offsetHeight;let a;return a=b.y+e.bottom.ythis._map.transform.height-d?["bottom"]:[],b.xthis._map.transform.width-c/2&&a.push("right"),0===a.length?"bottom":a.join("-")}_updateClassList(){const a=[...this._classList];a.push("mapboxgl-popup"),this._anchor&&a.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&a.push("mapboxgl-popup-track-pointer"),this._container.className=a.join(" ")}_update(c){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=b.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=b.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Fd(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||c){const e=this._pos=this._trackPointer&&c?c:this._map.project(this._lngLat),d=function(b){if(b||(b=new a.pointGeometry(0,0)),"number"==typeof b){const d=Math.round(Math.sqrt(.5*Math.pow(b,2)));return{center:new a.pointGeometry(0,0),top:new a.pointGeometry(0,b),"top-left":new a.pointGeometry(d,d),"top-right":new a.pointGeometry(-d,d),bottom:new a.pointGeometry(0,-b),"bottom-left":new a.pointGeometry(d,-d),"bottom-right":new a.pointGeometry(-d,-d),left:new a.pointGeometry(b,0),right:new a.pointGeometry(-b,0)}}if(b instanceof a.pointGeometry||Array.isArray(b)){const c=a.pointGeometry.convert(b);return{center:c,top:c,"top-left":c,"top-right":c,bottom:c,"bottom-left":c,"bottom-right":c,left:c,right:c}}return{center:a.pointGeometry.convert(b.center||[0,0]),top:a.pointGeometry.convert(b.top||[0,0]),"top-left":a.pointGeometry.convert(b["top-left"]||[0,0]),"top-right":a.pointGeometry.convert(b["top-right"]||[0,0]),bottom:a.pointGeometry.convert(b.bottom||[0,0]),"bottom-left":a.pointGeometry.convert(b["bottom-left"]||[0,0]),"bottom-right":a.pointGeometry.convert(b["bottom-right"]||[0,0]),left:a.pointGeometry.convert(b.left||[0,0]),right:a.pointGeometry.convert(b.right||[0,0])}}(this.options.offset),f=this._anchor=this._getAnchor(d),g=e.add(d[f]).round();this._map._requestDomTask(()=>{this._container&&f&&(this._container.style.transform=`${Gd[f]} translate(${g.x}px,${g.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const a=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");a&&a.focus()}_onClose(){this.remove()}_setOpacity(a){this._content&&(this._content.style.opacity=a),this._tip&&(this._tip.style.opacity=a)}},Marker:z,Style:c,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.pointGeometry,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:x,Evented:a.Evented,config:a.config,prewarm:function(){oa().acquire(ma)},clearPrewarmedResources:function(){const a=na;a&&(a.isPreloaded()&&1===a.numActive()?(a.release(ma),na=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return a.config.ACCESS_TOKEN},set accessToken(t){a.config.ACCESS_TOKEN=t},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(t){a.config.API_URL=t},get workerCount(){return e.workerCount},set workerCount(e){e.workerCount=e},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){a.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(b){a.clearTileCache(b)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return A}),b})}}]) diff --git a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js index 656c0806cde..27ca7d02552 100644 --- a/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js +++ b/crates/swc_ecma_minifier/tests/full/feedback-mapbox/785-e1932cc99ac3bb67/output.js @@ -1 +1 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[785],{840:function(a,b,c){var d;!function(e,f,g,h){"use strict";var i,j=["","webkit","Moz","MS","ms","o"],k=f.createElement("div"),l=Math.round,m=Math.abs,n=Date.now;function o(a,b,c){return setTimeout(v(a,c),b)}function p(a,b,c){return!!Array.isArray(a)&&(q(a,c[b],c),!0)}function q(a,b,c){var d;if(a)if(a.forEach)a.forEach(b,c);else if(h!==a.length)for(d=0;d\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",f=e.console&&(e.console.warn||e.console.log);return f&&f.call(e.console,d,c),a.apply(this,arguments)}}i="function"!=typeof Object.assign?function(a){if(a===h||null===a)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(a),c=1;c -1}function C(a){return a.trim().split(/\s+/g)}function D(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0;dD(e,g)&&d.push(a[f]),e[f]=g,f++}return c&&(d=b?d.sort(function(a,c){return a[b]>c[b]}):d.sort()),d}function G(a,b){for(var c,d,e=b[0].toUpperCase()+b.slice(1),f=0;f1&&!c.firstMultiple?c.firstMultiple=V(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=b.center=W(d);b.timeStamp=n(),b.deltaTime=b.timeStamp-f.timeStamp,b.angle=$(h,i),b.distance=Z(h,i),T(c,b),b.offsetDirection=Y(b.deltaX,b.deltaY);var j=X(b.deltaTime,b.deltaX,b.deltaY);b.overallVelocityX=j.x,b.overallVelocityY=j.y,b.overallVelocity=m(j.x)>m(j.y)?j.x:j.y,b.scale=g?aa(g.pointers,d):1,b.rotation=g?_(g.pointers,d):0,b.maxPointers=c.prevInput?b.pointers.length>c.prevInput.maxPointers?b.pointers.length:c.prevInput.maxPointers:b.pointers.length,U(c,b);var k=a.element;A(b.srcEvent.target,k)&&(k=b.srcEvent.target),b.target=k}function T(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function U(a,b){var c,d,e,f,g=a.lastInterval||b,i=b.timeStamp-g.timeStamp;if(8!=b.eventType&&(i>25||h===g.velocity)){var j=b.deltaX-g.deltaX,k=b.deltaY-g.deltaY,l=X(i,j,k);d=l.x,e=l.y,c=m(l.x)>m(l.y)?l.x:l.y,f=Y(j,k),a.lastInterval=b}else c=g.velocity,d=g.velocityX,e=g.velocityY,f=g.direction;b.velocity=c,b.velocityX=d,b.velocityY=e,b.direction=f}function V(a){for(var b=[],c=0;c=m(b)?a<0?2:4:b<0?8:16}function Z(a,b,c){c||(c=O);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function $(a,b,c){c||(c=O);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function _(a,b){return $(b[1],b[0],P)+$(a[1],a[0],P)}function aa(a,b){return Z(b[0],b[1],P)/Z(a[0],a[1],P)}Q.prototype={handler:function(){},init:function(){this.evEl&&y(this.element,this.evEl,this.domHandler),this.evTarget&&y(this.target,this.evTarget,this.domHandler),this.evWin&&y(I(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&z(this.element,this.evEl,this.domHandler),this.evTarget&&z(this.target,this.evTarget,this.domHandler),this.evWin&&z(I(this.element),this.evWin,this.domHandler)}};var ba={mousedown:1,mousemove:2,mouseup:4};function ca(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,Q.apply(this,arguments)}u(ca,Q,{handler:function(a){var b=ba[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:N,srcEvent:a}))}});var da={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},ea={2:M,3:"pen",4:N,5:"kinect"},fa="pointerdown",ga="pointermove pointerup pointercancel";function ha(){this.evEl=fa,this.evWin=ga,Q.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(fa="MSPointerDown",ga="MSPointerMove MSPointerUp MSPointerCancel"),u(ha,Q,{handler:function(a){var b=this.store,c=!1,d=da[a.type.toLowerCase().replace("ms","")],e=ea[a.pointerType]||a.pointerType,f=D(b,a.pointerId,"pointerId");1&d&&(0===a.button||e==M)?f<0&&(b.push(a),f=b.length-1):12&d&&(c=!0),!(f<0)&&(b[f]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:e,srcEvent:a}),c&&b.splice(f,1))}});var ia={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ja(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Q.apply(this,arguments)}function ka(a,b){var c=E(a.touches),d=E(a.changedTouches);return 12&b&&(c=F(c.concat(d),"identifier",!0)),[c,d]}u(ja,Q,{handler:function(a){var b=ia[a.type];if(1===b&&(this.started=!0),this.started){var c=ka.call(this,a,b);12&b&&c[0].length-c[1].length==0&&(this.started=!1),this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:M,srcEvent:a})}}});var la={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ma(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},Q.apply(this,arguments)}function na(a,b){var c=E(a.touches),d=this.targetIds;if(3&b&&1===c.length)return d[c[0].identifier]=!0,[c,c];var e,f,g=E(a.changedTouches),h=[],i=this.target;if(f=c.filter(function(a){return A(a.target,i)}),1===b)for(e=0;e -1&&d.splice(a,1)},2500)}}function ra(a){for(var b=a.srcEvent.clientX,c=a.srcEvent.clientY,d=0;d -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){var b=this,c=this.state;function d(c){b.manager.emit(c,a)}c<8&&d(b.options.event+Da(c)),d(b.options.event),a.additionalEvent&&d(a.additionalEvent),c>=8&&d(b.options.event+Da(c))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ab.threshold&&e&b.direction},attrTest:function(a){return Ga.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=Ea(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),u(Ia,Ga,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[xa]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),u(Ja,Ca,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[va]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=o(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=n(),this.manager.emit(this.options.event,this._input)))}}),u(Ka,Ga,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[xa]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),u(La,Ga,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Ha.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&m(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=Ea(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),u(Ma,Ca,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[wa]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var c=1;ca.length)&&(b=a.length);for(var c=0,d=new Array(b);cc?c:a}Math.PI,Math.hypot||(Math.hypot=function(){for(var a=0,b=arguments.length;b--;)a+=arguments[b]*arguments[b];return Math.sqrt(a)}),l=new m(4),m!=Float32Array&&(l[0]=0,l[1]=0,l[2]=0,l[3]=0);const s=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function t(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],p=b[12],q=b[13],r=b[14],s=b[15],t=c[0],u=c[1],v=c[2],w=c[3];return a[0]=t*d+u*h+v*l+w*p,a[1]=t*e+u*i+v*m+w*q,a[2]=t*f+u*j+v*n+w*r,a[3]=t*g+u*k+v*o+w*s,t=c[4],u=c[5],v=c[6],w=c[7],a[4]=t*d+u*h+v*l+w*p,a[5]=t*e+u*i+v*m+w*q,a[6]=t*f+u*j+v*n+w*r,a[7]=t*g+u*k+v*o+w*s,t=c[8],u=c[9],v=c[10],w=c[11],a[8]=t*d+u*h+v*l+w*p,a[9]=t*e+u*i+v*m+w*q,a[10]=t*f+u*j+v*n+w*r,a[11]=t*g+u*k+v*o+w*s,t=c[12],u=c[13],v=c[14],w=c[15],a[12]=t*d+u*h+v*l+w*p,a[13]=t*e+u*i+v*m+w*q,a[14]=t*f+u*j+v*n+w*r,a[15]=t*g+u*k+v*o+w*s,a}function u(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=c[0],q=c[1],r=c[2];return b===a?(a[12]=b[0]*p+b[4]*q+b[8]*r+b[12],a[13]=b[1]*p+b[5]*q+b[9]*r+b[13],a[14]=b[2]*p+b[6]*q+b[10]*r+b[14],a[15]=b[3]*p+b[7]*q+b[11]*r+b[15]):(d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=j,a[7]=k,a[8]=l,a[9]=m,a[10]=n,a[11]=o,a[12]=d*p+h*q+l*r+b[12],a[13]=e*p+i*q+m*r+b[13],a[14]=f*p+j*q+n*r+b[14],a[15]=g*p+k*q+o*r+b[15]),a}function v(a,b,c){var d=c[0],e=c[1],f=c[2];return a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d,a[3]=b[3]*d,a[4]=b[4]*e,a[5]=b[5]*e,a[6]=b[6]*e,a[7]=b[7]*e,a[8]=b[8]*f,a[9]=b[9]*f,a[10]=b[10]*f,a[11]=b[11]*f,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function w(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function x(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function y(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function z(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}mc=new m(2),m!=Float32Array&&(mc[0]=0,mc[1]=0),nc=new m(3),m!=Float32Array&&(nc[0]=0,nc[1]=0,nc[2]=0);const A=Math.PI,B=A/4,C=A/180,D=180/A;function E(a){return Math.pow(2,a)}function F([a,b]){return z(Number.isFinite(a)),z(Number.isFinite(b)&&b>= -90&&b<=90,"invalid latitude"),[512*(a*C+A)/(2*A),512*(A+Math.log(Math.tan(B+.5*(b*C))))/(2*A)]}function G([a,b]){return[(a/512*(2*A)-A)*D,2*(Math.atan(Math.exp(b/512*(2*A)-A))-B)*D]}function H(a){return 2*Math.atan(.5/a)*D}function I(a){return .5/Math.tan(.5*a*C)}function J(a,b,c=0){const[d,e,f]=a;if(z(Number.isFinite(d)&&Number.isFinite(e),"invalid pixel coordinate"),Number.isFinite(f)){const g=o(b,[d,e,f,1]);return g}const h=o(b,[d,e,0,1]),i=o(b,[d,e,1,1]),j=h[2],k=i[2];return y([],h,i,j===k?0:((c||0)-j)/(k-j))}const K=Math.PI/180;function L(a,b,c){const{pixelUnprojectionMatrix:d}=a,e=o(d,[b,0,1,1]),f=o(d,[b,a.height,1,1]),g=c*a.distanceScales.unitsPerMeter[2],h=(g-e[2])/(f[2]-e[2]),i=y([],e,f,h),j=G(i);return j[2]=c,j}class M{constructor({width:N,height:O,latitude:P=0,longitude:Q=0,zoom:R=0,pitch:S=0,bearing:T=0,altitude:U=null,fovy:V=null,position:W=null,nearZMultiplier:X=.02,farZMultiplier:Y=1.01}={width:1,height:1}){N=N||1,O=O||1,null===V&&null===U?V=H(U=1.5):null===V?V=H(U):null===U&&(U=I(V));const Z=E(R);U=Math.max(.75,U);const $=function({latitude:a,longitude:b,highPrecision:c=!1}){z(Number.isFinite(a)&&Number.isFinite(b));const d={},e=Math.cos(a*C),f=1.4222222222222223/e,g=12790407194604047e-21/e;if(d.unitsPerMeter=[g,g,g],d.metersPerUnit=[1/g,1/g,1/g],d.unitsPerDegree=[1.4222222222222223,f,g],d.degreesPerUnit=[.703125,1/f,1/g],c){const h=C*Math.tan(a*C)/e,i=1.4222222222222223*h/2,j=12790407194604047e-21*h,k=j/f*g;d.unitsPerDegree2=[0,i,j],d.unitsPerMeter2=[k,0,k]}return d}({longitude:Q,latitude:P}),_=F([Q,P]);if(_[2]=0,W){var aa,ba,ca,da,ea,fa;da=_,ea=_,aa=[],ba=W,ca=$.unitsPerMeter,aa[0]=ba[0]*ca[0],aa[1]=ba[1]*ca[1],aa[2]=ba[2]*ca[2],fa=aa,da[0]=ea[0]+fa[0],da[1]=ea[1]+fa[1],da[2]=ea[2]+fa[2]}this.projectionMatrix=(function({width:a,height:b,pitch:c,altitude:d,fovy:e,nearZMultiplier:f,farZMultiplier:g}){var h,i,j,k,l,m,n;const{fov:o,aspect:p,near:q,far:r}=function({width:a,height:b,fovy:c=H(1.5),altitude:d,pitch:e=0,nearZMultiplier:f=1,farZMultiplier:g=1}){void 0!==d&&(c=H(d));const h=.5*c*C,i=I(c),j=e*C;return{fov:2*h,aspect:a/b,focalDistance:i,near:f,far:(Math.sin(j)*(Math.sin(h)*i/Math.sin(Math.min(Math.max(Math.PI/2-j-h,.01),Math.PI-.01)))+i)*g}}({width:a,height:b,altitude:d,fovy:e,pitch:c,nearZMultiplier:f,farZMultiplier:g}),s=(h=[],i=o,j=p,k=q,l=r,n=1/Math.tan(i/2),h[0]=n/j,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=n,h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[11]=-1,h[12]=0,h[13]=0,h[15]=0,null!=l&&l!==1/0?(m=1/(k-l),h[10]=(l+k)*m,h[14]=2*l*k*m):(h[10]=-1,h[14]=-2*k),h);return s})({width:N,height:O,pitch:S,fovy:V,nearZMultiplier:X,farZMultiplier:Y}),this.viewMatrix=(function({height:a,pitch:b,bearing:c,altitude:d,scale:e,center:f=null}){var g,h,i,j,k,l,m,o,p,q,r,s,t,w,x,y,z,A,B,D,E,F,G,H,I,J,K,L;const M=n();return u(M,M,[0,0,-d]),g=M,h=M,i=-b*C,j=Math.sin(i),k=Math.cos(i),l=h[4],m=h[5],o=h[6],p=h[7],q=h[8],r=h[9],s=h[10],t=h[11],h!==g&&(g[0]=h[0],g[1]=h[1],g[2]=h[2],g[3]=h[3],g[12]=h[12],g[13]=h[13],g[14]=h[14],g[15]=h[15]),g[4]=l*k+q*j,g[5]=m*k+r*j,g[6]=o*k+s*j,g[7]=p*k+t*j,g[8]=q*k-l*j,g[9]=r*k-m*j,g[10]=s*k-o*j,g[11]=t*k-p*j,w=M,x=M,y=c*C,z=Math.sin(y),A=Math.cos(y),B=x[0],D=x[1],E=x[2],F=x[3],G=x[4],H=x[5],I=x[6],J=x[7],x!==w&&(w[8]=x[8],w[9]=x[9],w[10]=x[10],w[11]=x[11],w[12]=x[12],w[13]=x[13],w[14]=x[14],w[15]=x[15]),w[0]=B*A+G*z,w[1]=D*A+H*z,w[2]=E*A+I*z,w[3]=F*A+J*z,w[4]=G*A-B*z,w[5]=H*A-D*z,w[6]=I*A-E*z,w[7]=J*A-F*z,v(M,M,[e/=a,e,e]),f&&u(M,M,(K=[],L=f,K[0]=-L[0],K[1]=-L[1],K[2]=-L[2],K)),M})({height:O,scale:Z,center:_,pitch:S,bearing:T,altitude:U}),this.width=N,this.height=O,this.scale=Z,this.latitude=P,this.longitude=Q,this.zoom=R,this.pitch=S,this.bearing=T,this.altitude=U,this.fovy=V,this.center=_,this.meterOffset=W||[0,0,0],this.distanceScales=$,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 ga,ha,ia,ja,ka,la,ma,na,oa,pa,qa,ra,sa,ta,ua,va,wa,xa,ya,za,Aa,Ba,Ca,Da,Ea,Fa,Ga,Ha,Ia,Ja,Ka;const{width:La,height:Ma,projectionMatrix:Na,viewMatrix:Oa}=this,Pa=n();t(Pa,Pa,Na),t(Pa,Pa,Oa),this.viewProjectionMatrix=Pa;const Qa=n();v(Qa,Qa,[La/2,-Ma/2,1]),u(Qa,Qa,[1,-1,0]),t(Qa,Qa,Pa);const Ra=(ga=n(),ia=(ha=Qa)[0],ja=ha[1],ka=ha[2],la=ha[3],ma=ha[4],na=ha[5],oa=ha[6],pa=ha[7],qa=ha[8],ra=ha[9],sa=ha[10],ta=ha[11],ua=ha[12],va=ha[13],wa=ha[14],xa=ha[15],ya=ia*na-ja*ma,za=ia*oa-ka*ma,Aa=ia*pa-la*ma,Ba=ja*oa-ka*na,Ca=ja*pa-la*na,Da=ka*pa-la*oa,Ea=qa*va-ra*ua,Fa=qa*wa-sa*ua,Ga=qa*xa-ta*ua,Ha=ra*wa-sa*va,Ia=ra*xa-ta*va,Ja=sa*xa-ta*wa,Ka=ya*Ja-za*Ia+Aa*Ha+Ba*Ga-Ca*Fa+Da*Ea,Ka?(Ka=1/Ka,ga[0]=(na*Ja-oa*Ia+pa*Ha)*Ka,ga[1]=(ka*Ia-ja*Ja-la*Ha)*Ka,ga[2]=(va*Da-wa*Ca+xa*Ba)*Ka,ga[3]=(sa*Ca-ra*Da-ta*Ba)*Ka,ga[4]=(oa*Ga-ma*Ja-pa*Fa)*Ka,ga[5]=(ia*Ja-ka*Ga+la*Fa)*Ka,ga[6]=(wa*Aa-ua*Da-xa*za)*Ka,ga[7]=(qa*Da-sa*Aa+ta*za)*Ka,ga[8]=(ma*Ia-na*Ga+pa*Ea)*Ka,ga[9]=(ja*Ga-ia*Ia-la*Ea)*Ka,ga[10]=(ua*Ca-va*Aa+xa*ya)*Ka,ga[11]=(ra*Aa-qa*Ca-ta*ya)*Ka,ga[12]=(na*Fa-ma*Ha-oa*Ea)*Ka,ga[13]=(ia*Ha-ja*Fa+ka*Ea)*Ka,ga[14]=(va*za-ua*Ba-wa*ya)*Ka,ga[15]=(qa*Ba-ra*za+sa*ya)*Ka,ga):null);if(!Ra)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=Qa,this.pixelUnprojectionMatrix=Ra}equals(Sa){return Sa instanceof M&&Sa.width===this.width&&Sa.height===this.height&&w(Sa.projectionMatrix,this.projectionMatrix)&&w(Sa.viewMatrix,this.viewMatrix)}project(Ta,{topLeft:Ua=!0}={}){const Va=this.projectPosition(Ta),Wa=function(a,b){const[c,d,e=0]=a;return z(Number.isFinite(c)&&Number.isFinite(d)&&Number.isFinite(e)),o(b,[c,d,e,1])}(Va,this.pixelProjectionMatrix),[Xa,Ya]=Wa,Za=Ua?Ya:this.height-Ya;return 2===Ta.length?[Xa,Za]:[Xa,Za,Wa[2]]}unproject($a,{topLeft:_a=!0,targetZ:ab}={}){const[bb,cb,db]=$a,eb=_a?cb:this.height-cb,fb=ab&&ab*this.distanceScales.unitsPerMeter[2],gb=J([bb,eb,db],this.pixelUnprojectionMatrix,fb),[hb,ib,jb]=this.unprojectPosition(gb);return Number.isFinite(db)?[hb,ib,jb]:Number.isFinite(ab)?[hb,ib,ab]:[hb,ib]}projectPosition(kb){const[lb,mb]=F(kb),nb=(kb[2]||0)*this.distanceScales.unitsPerMeter[2];return[lb,mb,nb]}unprojectPosition(ob){const[pb,qb]=G(ob),rb=(ob[2]||0)*this.distanceScales.metersPerUnit[2];return[pb,qb,rb]}projectFlat(sb){return F(sb)}unprojectFlat(tb){return G(tb)}getMapCenterByLngLatPosition({lngLat:ub,pos:vb}){var wb,xb;const yb=J(vb,this.pixelUnprojectionMatrix),zb=F(ub),Ab=x([],zb,(wb=[],xb=yb,wb[0]=-xb[0],wb[1]=-xb[1],wb)),Bb=x([],this.center,Ab);return G(Bb)}getLocationAtPoint({lngLat:Cb,pos:Db}){return this.getMapCenterByLngLatPosition({lngLat:Cb,pos:Db})}fitBounds(Eb,Fb={}){const{width:Gb,height:Hb}=this,{longitude:Ib,latitude:Jb,zoom:Kb}=function({width:a,height:b,bounds:c,minExtent:d=0,maxZoom:e=24,padding:f=0,offset:g=[0,0]}){const[[h,i],[j,k]]=c;if(Number.isFinite(f)){const l=f;f={top:l,bottom:l,left:l,right:l}}else z(Number.isFinite(f.top)&&Number.isFinite(f.bottom)&&Number.isFinite(f.left)&&Number.isFinite(f.right));const m=F([h,r(k,-85.051129,85.051129)]),n=F([j,r(i,-85.051129,85.051129)]),o=[Math.max(Math.abs(n[0]-m[0]),d),Math.max(Math.abs(n[1]-m[1]),d)],p=[a-f.left-f.right-2*Math.abs(g[0]),b-f.top-f.bottom-2*Math.abs(g[1])];z(p[0]>0&&p[1]>0);const q=p[0]/o[0],t=p[1]/o[1],u=(f.right-f.left)/2/q,v=(f.bottom-f.top)/2/t,w=[(n[0]+m[0])/2+u,(n[1]+m[1])/2+v],x=G(w),y=Math.min(e,s(Math.abs(Math.min(q,t))));return z(Number.isFinite(y)),{longitude:x[0],latitude:x[1],zoom:y}}(Object.assign({width:Gb,height:Hb,bounds:Eb},Fb));return new M({width:Gb,height:Hb,longitude:Ib,latitude:Jb,zoom:Kb})}getBounds(Lb){const Mb=this.getBoundingRegion(Lb),Nb=Math.min(...Mb.map(a=>a[0])),Ob=Math.max(...Mb.map(a=>a[0])),Pb=Math.min(...Mb.map(a=>a[1])),Qb=Math.max(...Mb.map(a=>a[1]));return[[Nb,Pb],[Ob,Qb]]}getBoundingRegion(Rb={}){return(function(a,b=0){const{width:c,height:d,unproject:e}=a,f={targetZ:b},g=e([0,d],f),h=e([c,d],f);let i,j;const k=a.fovy?.5*a.fovy*K:Math.atan(.5/a.altitude),l=(90-a.pitch)*K;return k>l-.01?(i=L(a,0,b),j=L(a,c,b)):(i=e([0,0],f),j=e([c,0],f)),[g,h,j,i]})(this,Rb.z||0)}}const Sb=["longitude","latitude","zoom"],Tb={curve:1.414,speed:1.2};function Ub(a,b,c){var d,e,f,g,h,i;c=Object.assign({},Tb,c);const j=c.curve,k=a.zoom,l=[a.longitude,a.latitude],m=E(k),n=b.zoom,o=[b.longitude,b.latitude],p=E(n-k),q=F(l),r=F(o),s=(d=[],e=r,f=q,d[0]=e[0]-f[0],d[1]=e[1]-f[1],d),t=Math.max(a.width,a.height),u=t/p,v=(h=(g=s)[0],i=g[1],Math.hypot(h,i)*m),w=Math.max(v,.01),x=j*j,y=(u*u-t*t+x*x*w*w)/(2*t*x*w),z=(u*u-t*t-x*x*w*w)/(2*u*x*w),A=Math.log(Math.sqrt(y*y+1)-y),B=Math.log(Math.sqrt(z*z+1)-z);return{startZoom:k,startCenterXY:q,uDelta:s,w0:t,u1:v,S:(B-A)/j,rho:j,rho2:x,r0:A,r1:B}}var Vb=function(){if("undefined"!=typeof Map)return Map;function a(a,b){var c=-1;return a.some(function(a,d){return a[0]===b&&(c=d,!0)}),c}return(function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(b){var c=a(this.__entries__,b),d=this.__entries__[c];return d&&d[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(b){var c=this.__entries__,d=a(c,b);~d&&c.splice(d,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(a,b){void 0===b&&(b=null);for(var c=0,d=this.__entries__;c0},a.prototype.connect_=function(){!Wb||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),$b?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){Wb&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(a){var b=a.propertyName,c=void 0===b?"":b;Zb.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a()),this.instance_},a.instance_=null,a}(),ac=function(a,b){for(var c=0,d=Object.keys(b);c0},a}(),kc="undefined"!=typeof WeakMap?new WeakMap():new Vb(),lc=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=_b.getInstance(),d=new jc(b,c,this);kc.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){lc.prototype[a]=function(){var b;return(b=kc.get(this))[a].apply(b,arguments)}});var mc,nc,oc=void 0!==Xb.ResizeObserver?Xb.ResizeObserver:lc;function pc(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function qc(a,b){for(var c=0;c=a.length?{done:!0}:{done:!1,value:a[c++]}},e:function(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function wc(a,b){if(a){if("string"==typeof a)return xc(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c)return Array.from(a);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return xc(a,b)}}function xc(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c1&& void 0!==arguments[1]?arguments[1]:"component";a.debug&&j.checkPropTypes(Bc,a,"prop",b)}var Ec=function(){function a(b){var c=this;if(pc(this,a),g(this,"props",Cc),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return rc(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var c=this._map.getContainer(),d=b.container;for(d.classList.add("mapboxgl-map");c.childNodes.length>0;)d.appendChild(c.childNodes[0]);this._map._container=d,a.savedMap=null,b.mapStyle&&this._map.setStyle(zc(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=c,b.gl}}var d={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:zc(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(d.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},d,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var b=this;Dc(a=Object.assign({},Cc,a),"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||Cc.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var c=a.container;Object.defineProperty(c,"offsetWidth",{configurable:!0,get:function(){return b.width}}),Object.defineProperty(c,"clientWidth",{configurable:!0,get:function(){return b.width}}),Object.defineProperty(c,"offsetHeight",{configurable:!0,get:function(){return b.height}}),Object.defineProperty(c,"clientHeight",{configurable:!0,get:function(){return b.height}});var d=this._map.getCanvas();d&&(d.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(a,b){if(this._map){Dc(b=Object.assign({},this.props,b),"Mapbox");var c=this._updateMapViewport(a,b),d=this._updateMapSize(a,b);this._updateMapStyle(a,b),!b.asyncRender&&(c||d)&&this.redraw(),this.props=b}}},{key:"_updateMapStyle",value:function(a,b){a.mapStyle!==b.mapStyle&&this._map.setStyle(zc(b.mapStyle),{diff:!b.preventStyleDiffing})}},{key:"_updateMapSize",value:function(a,b){var c=a.width!==b.width||a.height!==b.height;return c&&(this.width=b.width,this.height=b.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(a,b){var c=this._getViewState(a),d=this._getViewState(b),e=d.latitude!==c.latitude||d.longitude!==c.longitude||d.zoom!==c.zoom||d.pitch!==c.pitch||d.bearing!==c.bearing||d.altitude!==c.altitude;return e&&(this._map.jumpTo(this._viewStateToMapboxProps(d)),d.altitude!==c.altitude&&(this._map.transform.altitude=d.altitude)),e}},{key:"_getViewState",value:function(a){var b=a.viewState||a,c=b.longitude,d=b.latitude,e=b.zoom,f=b.pitch,g=b.bearing,h=b.altitude;return{longitude:c,latitude:d,zoom:e,pitch:void 0===f?0:f,bearing:void 0===g?0:g,altitude:void 0===h?1.5:h}}},{key:"_checkStyleSheet",value:function(){var a=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==sc)try{var b=sc.createElement("div");if(b.className="mapboxgl-map",b.style.display="none",sc.body.appendChild(b),!("static"!==window.getComputedStyle(b).position)){var c=sc.createElement("link");c.setAttribute("rel","stylesheet"),c.setAttribute("type","text/css"),c.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(a,"/mapbox-gl.css")),sc.head.appendChild(c)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}}]),a}();g(Ec,"initialized",!1),g(Ec,"propTypes",Bc),g(Ec,"defaultProps",Cc),g(Ec,"savedMap",null);var Fc=c(6158),Gc=c.n(Fc);function Hc(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function Ic(a,b){if(a===b)return!0;if(Hc(a)&&Hc(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function Jc(a,b,c){return Math.max(b,Math.min(c,a))}function Kc(a,b,c){return Hc(a)?a.map(function(a,d){return Kc(a,b[d],c)}):c*b+(1-c)*a}function Lc(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function Mc(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function Nc(a){for(var b=1;b0,"`scale` must be a positive number");var e=this._state,f=e.startZoom,g=e.startZoomLngLat;Number.isFinite(f)||(f=this._viewportProps.zoom,g=this._unproject(c)||this._unproject(b)),Lc(g,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var h=this._calculateNewZoom({scale:d,startZoom:f||0}),i=new M(Object.assign({},this._viewportProps,{zoom:h})),j=i.getMapCenterByLngLatPosition({lngLat:g,pos:b}),l=k(j,2),m=l[0],n=l[1];return this._getUpdatedMapState({zoom:h,longitude:m,latitude:n})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=Jc(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=Jc(g,f,e),Object.assign(a,function({width:a,height:b,longitude:c,latitude:d,zoom:e,pitch:f=0,bearing:g=0}){(c< -180||c>180)&&(c=p(c+180,360)-180),(g< -180||g>180)&&(g=p(g+180,360)-180);const h=s(b/512);if(e<=h)e=h,d=0;else{const i=b/2/Math.pow(2,e),j=G([0,i])[1];if(dk&&(d=k)}}return{width:a,height:b,longitude:c,latitude:d,zoom:e,pitch:f,bearing:g}}(a)),a}},{key:"_unproject",value:function(a){var b=new M(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new M(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var b=a.scale,c=a.startZoom,d=this._viewportProps,e=d.maxZoom,f=d.minZoom;return Jc(c+Math.log2(b),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(a){var b=a.deltaScaleX,c=a.deltaScaleY,d=a.startBearing,e=a.startPitch;c=Jc(c,-1,1);var f=this._viewportProps,g=f.minPitch,h=f.maxPitch,i=e;return c>0?i=e+c*(h-e):c<0&&(i=e-c*(g-e)),{pitch:i,bearing:d+180*b}}},{key:"_getRotationParams",value:function(a,b){var c=a[0]-b[0],d=a[1]-b[1],e=a[1],f=b[1],g=this._viewportProps,h=g.width,i=g.height,j=0;return d>0?Math.abs(i-f)>5&&(j=d/(f-i)*1.2):d<0&&f>5&&(j=1-e/f),{deltaScaleX:c/h,deltaScaleY:j=Math.min(1,Math.max(-1,j))}}}]),a}();function Rc(a){return a[0].toLowerCase()+a.slice(1)}function Sc(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function Tc(a){for(var b=1;b1&& void 0!==arguments[1]?arguments[1]:{},d=a.current&&a.current.getMap();return d&&d.queryRenderedFeatures(b,c)}}},[]);var q=(0,i.useCallback)(function(a){var b=a.target;b===n.current&&b.scrollTo(0,0)},[]),r=p&&i.createElement(Vc,{value:$c($c({},o),{},{viewport:o.viewport||ad($c({map:p,props:a},g)),map:p,container:o.container||m.current})},i.createElement("div",{key:"map-overlays",className:"overlays",ref:n,style:bd,onScroll:q},a.children)),s=a.className,t=a.width,u=a.height,v=a.style,w=a.visibilityConstraints,x=Object.assign({position:"relative"},v,{width:t,height:u}),y=a.visible&&function(a){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:Oc;for(var c in b){var d=c.slice(0,3),e=Rc(c.slice(3));if("min"===d&&a[e]b[c])return!1}return!0}(a.viewState||a,w),z=Object.assign({},bd,{visibility:y?"inherit":"hidden"});return i.createElement("div",{key:"map-container",ref:m,style:x},i.createElement("div",{key:"map-mapbox",ref:l,style:z,className:s}),r,!d&&!a.disableTokenWarning&&i.createElement(ed,null))});fd.supported=function(){return Gc()&&Gc().supported()},fd.propTypes=cd,fd.defaultProps=dd;var gd=fd;function hd(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c=a.length?{done:!0}:{done:!1,value:a[c++]}},e:function(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(d.s();!(c=d.n()).done;){var e=c.value;if(!Ic(a[e],b[e]))return!1}}catch(f){d.e(f)}finally{d.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){Lc(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(a,b){return b.transitionDuration}}]),a}();function jd(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function kd(a,b){return(kd=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function ld(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&kd(a,b)}function md(a){return(md="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function nd(a,b){if(b&&("object"===md(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return jd(a)}function od(a){return(od=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var pd={longitude:1,bearing:1};function qd(a){return Number.isFinite(a)||Array.isArray(a)}function rd(a,b,c){return a in pd&&Math.abs(c-b)>180&&(c=c<0?c+360:c-360),c}function sd(a,b){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=td(a))||b&&a&&"number"==typeof a.length){e&&(a=e);var c=0,d=function(){};return{s:d,n:function(){return c>=a.length?{done:!0}:{done:!1,value:a[c++]}},e:function(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function td(a,b){if(a){if("string"==typeof a)return ud(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c)return Array.from(a);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return ud(a,b)}}function ud(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c=a.length?{done:!0}:{done:!1,value:a[c++]}},e:function(a){throw a},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function Ad(a,b){if(a){if("string"==typeof a)return Bd(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c)return Array.from(a);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return Bd(a,b)}}function Bd(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c0&& void 0!==arguments[0]?arguments[0]:{};return pc(this,e),g(jd(a=d.call(this)),"propNames",vd),a.props=Object.assign({},yd,b),a}rc(e,[{key:"initializeProps",value:function(a,b){var c,d={},e={},f=sd(wd);try{for(f.s();!(c=f.n()).done;){var g=c.value,h=a[g],i=b[g];Lc(qd(h)&&qd(i),"".concat(g," must be supplied for transition")),d[g]=h,e[g]=rd(g,h,i)}}catch(j){f.e(j)}finally{f.f()}var k,l=sd(xd);try{for(l.s();!(k=l.n()).done;){var m=k.value,n=a[m]||0,o=b[m]||0;d[m]=n,e[m]=rd(m,n,o)}}catch(p){l.e(p)}finally{l.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(a,b,c){var d,e=function(a,b,c,d={}){var e,f,g;const h={},{startZoom:i,startCenterXY:j,uDelta:k,w0:l,u1:m,S:n,rho:o,rho2:p,r0:r}=Ub(a,b,d);if(m<.01){for(const t of Sb){const u=a[t],v=b[t];h[t]=q(u,v,c)}return h}const w=c*n,y=i+s(1/(Math.cosh(r)/Math.cosh(r+o*w))),z=(e=[],f=k,g=l*((Math.cosh(r)*Math.tanh(r+o*w)-Math.sinh(r))/p)/m,e[0]=f[0]*g,e[1]=f[1]*g,e);x(z,z,j);const A=G(z);return h.longitude=A[0],h.latitude=A[1],h.zoom=y,h}(a,b,c,this.props),f=sd(xd);try{for(f.s();!(d=f.n()).done;){var g=d.value;e[g]=Kc(a[g],b[g],c)}}catch(h){f.e(h)}finally{f.f()}return e}},{key:"getDuration",value:function(a,b){var c=b.transitionDuration;return"auto"===c&&(c=(function(a,b,c={}){c=Object.assign({},Tb,c);const{screenSpeed:d,speed:e,maxDuration:f}=c,{S:g,rho:h}=Ub(a,b,c),i=1e3*g;let j;return j=Number.isFinite(d)?i/(d/h):i/e,Number.isFinite(f)&&j>f?0:j})(a,b,this.props)),c}}])}(id);var Cd=["longitude","latitude","zoom","bearing","pitch"],Dd=function(a){ld(e,a);var b,c,d=(b=e,c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,d=od(b);if(c){var e=od(this).constructor;a=Reflect.construct(d,arguments,e)}else a=d.apply(this,arguments);return nd(this,a)});function e(){var a,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return pc(this,e),a=d.call(this),Array.isArray(b)&&(b={transitionProps:b}),a.propNames=b.transitionProps||Cd,b.around&&(a.around=b.around),a}return rc(e,[{key:"initializeProps",value:function(a,b){var c={},d={};if(this.around){c.around=this.around;var e=new M(a).unproject(this.around);Object.assign(d,b,{around:new M(b).project(e),aroundLngLat:e})}var f,g=zd(this.propNames);try{for(g.s();!(f=g.n()).done;){var h=f.value,i=a[h],j=b[h];Lc(qd(i)&&qd(j),"".concat(h," must be supplied for transition")),c[h]=i,d[h]=rd(h,i,j)}}catch(k){g.e(k)}finally{g.f()}return{start:c,end:d}}},{key:"interpolateProps",value:function(a,b,c){var d,e={},f=zd(this.propNames);try{for(f.s();!(d=f.n()).done;){var g=d.value;e[g]=Kc(a[g],b[g],c)}}catch(h){f.e(h)}finally{f.f()}if(b.around){var i=k(new M(Object.assign({},b,e)).getMapCenterByLngLatPosition({lngLat:b.aroundLngLat,pos:Kc(a.around,b.around,c)}),2),j=i[0],l=i[1];e.longitude=j,e.latitude=l}return e}}]),e}(id),Ed=function(){},Fd={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},Gd={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new Dd(),transitionInterruption:Fd.BREAK,onTransitionStart:Ed,onTransitionInterrupt:Ed,onTransitionEnd:Ed},Hd=function(){function a(){var b=this,c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};pc(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){b._animationFrame=requestAnimationFrame(b._onTransitionFrame),b._updateViewport()}),this.props=null,this.onViewportChange=c.onViewportChange||Ed,this.onStateChange=c.onStateChange||Ed,this.time=c.getTime||Date.now}return rc(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(a){var b=this.props;if(this.props=a,!b||this._shouldIgnoreViewportChange(b,a))return!1;if(this._isTransitionEnabled(a)){var c=Object.assign({},b),d=Object.assign({},a);if(this._isTransitionInProgress()&&(b.onTransitionInterrupt(),this.state.interruption===Fd.SNAP_TO_END?Object.assign(c,this.state.endProps):Object.assign(c,this.state.propsInTransition),this.state.interruption===Fd.UPDATE)){var e,f,g,h=this.time(),i=(h-this.state.startTime)/this.state.duration;d.transitionDuration=this.state.duration-(h-this.state.startTime),g=(e=this.state.easing)(f=i),d.transitionEasing=function(a){return 1/(1-g)*(e(a*(1-f)+f)-g)},d.transitionInterpolator=c.transitionInterpolator}return d.onTransitionStart(),this._triggerTransition(c,d),!0}return this._isTransitionInProgress()&&(b.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(a,b){return!a||(this._isTransitionInProgress()?this.state.interruption===Fd.IGNORE||this._isUpdateDueToCurrentTransition(b):!this._isTransitionEnabled(b)||b.transitionInterpolator.arePropsEqual(a,b))}},{key:"_triggerTransition",value:function(a,b){Lc(this._isTransitionEnabled(b)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=b.transitionInterpolator,d=c.getDuration?c.getDuration(a,b):b.transitionDuration;if(0!==d){var e=b.transitionInterpolator.initializeProps(a,b),f={inTransition:!0,isZooming:a.zoom!==b.zoom,isPanning:a.longitude!==b.longitude||a.latitude!==b.latitude,isRotating:a.bearing!==b.bearing||a.pitch!==b.pitch};this.state={duration:d,easing:b.transitionEasing,interpolator:b.transitionInterpolator,interruption:b.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var a=this.time(),b=this.state,c=b.startTime,d=b.duration,e=b.easing,f=b.interpolator,g=b.startProps,h=b.endProps,i=!1,j=(a-c)/d;j>=1&&(j=1,i=!0),j=e(j);var k=f.interpolateProps(g,h,j),l=new Qc(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),i&&(this._endTransition(),this.props.onTransitionEnd())}}]),a}();g(Hd,"defaultProps",Gd);var Id=c(840),Jd=c.n(Id);const Kd={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(a,b){for(let c=0;cb.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(Jd().PointerEventInput),Jd().MouseInput.prototype.handler=function(a){let b=Kd[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const Ld=Jd().Manager;var Md=Jd();const Nd=Md?[[Md.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[Md.Rotate,{enable:!1}],[Md.Pinch,{enable:!1}],[Md.Swipe,{enable:!1}],[Md.Pan,{threshold:0,enable:!1}],[Md.Press,{enable:!1}],[Md.Tap,{event:"doubletap",taps:2,enable:!1}],[Md.Tap,{event:"anytap",enable:!1}],[Md.Tap,{enable:!1}]]:null,Od={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},Pd={doubletap:["tap"]},Qd={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},Rd={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},Sd={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"},Td={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},Ud="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",Vd="undefined"!=typeof window?window:c.g;void 0!==c.g&&c.g;let Wd=!1;try{const Xd={get passive(){return Wd=!0,!0}};Vd.addEventListener("test",Xd,Xd),Vd.removeEventListener("test",Xd,Xd)}catch(Yd){}const Zd=-1!==Ud.indexOf("firefox"),{WHEEL_EVENTS:$d}=Rd,_d="wheel";class ae{constructor(be,ce,de={}){this.element=be,this.callback=ce,this.options=Object.assign({enable:!0},de),this.events=$d.concat(de.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>be.addEventListener(a,this.handleEvent,!!Wd&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(ee,fe){ee===_d&&(this.options.enable=fe)}handleEvent(ge){if(!this.options.enable)return;let he=ge.deltaY;Vd.WheelEvent&&(Zd&&ge.deltaMode===Vd.WheelEvent.DOM_DELTA_PIXEL&&(he/=Vd.devicePixelRatio),ge.deltaMode===Vd.WheelEvent.DOM_DELTA_LINE&&(he*=40));const ie={x:ge.clientX,y:ge.clientY};0!==he&&he%4.000244140625==0&&(he=Math.floor(he/4.000244140625)),ge.shiftKey&&he&&(he*=.25),this._onWheel(ge,-he,ie)}_onWheel(je,ke,le){this.callback({type:_d,center:le,delta:ke,srcEvent:je,pointerType:"mouse",target:je.target})}}const{MOUSE_EVENTS:me}=Rd,ne="pointermove",oe="pointerover",pe="pointerout",qe="pointerleave";class re{constructor(se,te,ue={}){this.element=se,this.callback=te,this.pressed=!1,this.options=Object.assign({enable:!0},ue),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=me.concat(ue.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>se.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(ve,we){ve===ne&&(this.enableMoveEvent=we),ve===oe&&(this.enableOverEvent=we),ve===pe&&(this.enableOutEvent=we),ve===qe&&(this.enableLeaveEvent=we)}handleEvent(xe){this.handleOverEvent(xe),this.handleOutEvent(xe),this.handleLeaveEvent(xe),this.handleMoveEvent(xe)}handleOverEvent(ye){this.enableOverEvent&&"mouseover"===ye.type&&this.callback({type:oe,srcEvent:ye,pointerType:"mouse",target:ye.target})}handleOutEvent(ze){this.enableOutEvent&&"mouseout"===ze.type&&this.callback({type:pe,srcEvent:ze,pointerType:"mouse",target:ze.target})}handleLeaveEvent(Ae){this.enableLeaveEvent&&"mouseleave"===Ae.type&&this.callback({type:qe,srcEvent:Ae,pointerType:"mouse",target:Ae.target})}handleMoveEvent(Be){if(this.enableMoveEvent)switch(Be.type){case"mousedown":Be.button>=0&&(this.pressed=!0);break;case"mousemove":0===Be.which&&(this.pressed=!1),this.pressed||this.callback({type:ne,srcEvent:Be,pointerType:"mouse",target:Be.target});break;case"mouseup":this.pressed=!1;break;default:}}}const{KEY_EVENTS:Ce}=Rd,De="keydown",Ee="keyup";class Fe{constructor(Ge,He,Ie={}){this.element=Ge,this.callback=He,this.options=Object.assign({enable:!0},Ie),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=Ce.concat(Ie.events||[]),this.handleEvent=this.handleEvent.bind(this),Ge.tabIndex=Ie.tabIndex||0,Ge.style.outline="none",this.events.forEach(a=>Ge.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(Je,Ke){Je===De&&(this.enableDownEvent=Ke),Je===Ee&&(this.enableUpEvent=Ke)}handleEvent(Le){const Me=Le.target||Le.srcElement;("INPUT"!==Me.tagName||"text"!==Me.type)&&"TEXTAREA"!==Me.tagName&&(this.enableDownEvent&&"keydown"===Le.type&&this.callback({type:De,srcEvent:Le,key:Le.key,target:Le.target}),this.enableUpEvent&&"keyup"===Le.type&&this.callback({type:Ee,srcEvent:Le,key:Le.key,target:Le.target}))}}const Ne="contextmenu";class Oe{constructor(Pe,Qe,Re={}){this.element=Pe,this.callback=Qe,this.options=Object.assign({enable:!0},Re),this.handleEvent=this.handleEvent.bind(this),Pe.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(Se,Te){Se===Ne&&(this.options.enable=Te)}handleEvent(Ue){this.options.enable&&this.callback({type:Ne,center:{x:Ue.clientX,y:Ue.clientY},srcEvent:Ue,pointerType:"mouse",target:Ue.target})}}const Ve={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},We={srcElement:"root",priority:0};class Xe{constructor(Ye){this.eventManager=Ye,this.handlers=[],this.handlersByElement=new Map(),this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(Ze,$e,_e,af=!1,bf=!1){const{handlers:cf,handlersByElement:df}=this;_e&&("object"!=typeof _e||_e.addEventListener)&&(_e={srcElement:_e}),_e=_e?Object.assign({},We,_e):We;let ef=df.get(_e.srcElement);ef||(ef=[],df.set(_e.srcElement,ef));const ff={type:Ze,handler:$e,srcElement:_e.srcElement,priority:_e.priority};af&&(ff.once=!0),bf&&(ff.passive=!0),cf.push(ff),this._active=this._active||!ff.passive;let gf=ef.length-1;for(;gf>=0;){if(ef[gf].priority>=ff.priority)break;gf--}ef.splice(gf+1,0,ff)}remove(hf,jf){const{handlers:kf,handlersByElement:lf}=this;for(let mf=kf.length-1;mf>=0;mf--){const nf=kf[mf];if(nf.type===hf&&nf.handler===jf){kf.splice(mf,1);const of=lf.get(nf.srcElement);of.splice(of.indexOf(nf),1),0===of.length&&lf.delete(nf.srcElement)}}this._active=kf.some(a=>!a.passive)}handleEvent(pf){if(this.isEmpty())return;const qf=this._normalizeEvent(pf);let rf=pf.srcEvent.target;for(;rf&&rf!==qf.rootElement;){if(this._emit(qf,rf),qf.handled)return;rf=rf.parentNode}this._emit(qf,"root")}_emit(sf,tf){const uf=this.handlersByElement.get(tf);if(uf){let vf=!1;const wf=()=>{sf.handled=!0},xf=()=>{sf.handled=!0,vf=!0},yf=[];for(let zf=0;zf{const b=this.manager.get(a);b&&Od[a].forEach(a=>{b.recognizeWith(a)})}),Nf.recognizerOptions){const Qf=this.manager.get(Pf);if(Qf){const Rf=Nf.recognizerOptions[Pf];delete Rf.enable,Qf.set(Rf)}}for(const[Sf,Tf]of(this.wheelInput=new ae(Mf,this._onOtherEvent,{enable:!1}),this.moveInput=new re(Mf,this._onOtherEvent,{enable:!1}),this.keyInput=new Fe(Mf,this._onOtherEvent,{enable:!1,tabIndex:Nf.tabIndex}),this.contextmenuInput=new Oe(Mf,this._onOtherEvent,{enable:!1}),this.events))Tf.isEmpty()||(this._toggleRecognizer(Tf.recognizerName,!0),this.manager.on(Sf,Tf.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(Uf,Vf,Wf){this._addEventHandler(Uf,Vf,Wf,!1)}once(Xf,Yf,Zf){this._addEventHandler(Xf,Yf,Zf,!0)}watch($f,_f,ag){this._addEventHandler($f,_f,ag,!1,!0)}off(bg,cg){this._removeEventHandler(bg,cg)}_toggleRecognizer(dg,eg){const{manager:fg}=this;if(!fg)return;const gg=fg.get(dg);if(gg&&gg.options.enable!==eg){gg.set({enable:eg});const hg=Pd[dg];hg&&!this.options.recognizers&&hg.forEach(a=>{const b=fg.get(a);eg?(b.requireFailure(dg),gg.dropRequireFailure(a)):b.dropRequireFailure(dg)})}this.wheelInput.enableEventType(dg,eg),this.moveInput.enableEventType(dg,eg),this.keyInput.enableEventType(dg,eg),this.contextmenuInput.enableEventType(dg,eg)}_addEventHandler(ig,jg,kg,lg,mg){if("string"!=typeof ig){for(const ng in kg=jg,ig)this._addEventHandler(ng,ig[ng],kg,lg,mg);return}const{manager:og,events:pg}=this,qg=Td[ig]||ig;let rg=pg.get(qg);!rg&&(rg=new Xe(this),pg.set(qg,rg),rg.recognizerName=Sd[qg]||qg,og&&og.on(qg,rg.handleEvent)),rg.add(ig,jg,kg,lg,mg),rg.isEmpty()||this._toggleRecognizer(rg.recognizerName,!0)}_removeEventHandler(sg,tg){if("string"!=typeof sg){for(const ug in sg)this._removeEventHandler(ug,sg[ug]);return}const{events:vg}=this,wg=Td[sg]||sg,xg=vg.get(wg);if(xg&&(xg.remove(sg,tg),xg.isEmpty())){const{recognizerName:yg}=xg;let zg=!1;for(const Ag of vg.values())if(Ag.recognizerName===yg&&!Ag.isEmpty()){zg=!0;break}zg||this._toggleRecognizer(yg,!1)}}_onBasicInput(Bg){const{srcEvent:Cg}=Bg,Dg=Qd[Cg.type];Dg&&this.manager.emit(Dg,Bg)}_onOtherEvent(Eg){this.manager.emit(Eg.type,Eg)}}function Fg(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function Gg(a){for(var b=1;b0),g=f&&!this.state.isHovering,h=!f&&this.state.isHovering;(d||g)&&(a.features=b,d&&d(a)),g&&Sg.call(this,"onMouseEnter",a),h&&Sg.call(this,"onMouseLeave",a),(g||h)&&this.setState({isHovering:f})}}function Wg(a){var b=this.props,c=b.onClick,d=b.onNativeClick,e=b.onDblClick,f=b.doubleClickZoom,g=[],h=e||f;switch(a.type){case"anyclick":g.push(d),h||g.push(c);break;case"click":h&&g.push(c);break;default:}(g=g.filter(Boolean)).length&&((a=Qg.call(this,a)).features=Rg.call(this,a.point),g.forEach(function(b){return b(a)}))}var Xg=(0,i.forwardRef)(function(a,b){var c,g,h=(0,i.useContext)(Wc),j=(0,i.useMemo)(function(){return a.controller||new Lg()},[]),k=(0,i.useMemo)(function(){return new If(null,{touchAction:a.touchAction,recognizerOptions:a.eventRecognizerOptions})},[]),l=(0,i.useRef)(null),m=(0,i.useRef)(null),n=(0,i.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;n.props=a,n.map=m.current&&m.current.getMap(),n.setState=function(b){n.state=Ng(Ng({},n.state),b),l.current.style.cursor=a.getCursor(n.state)};var o=!0,p=function(a,b,d){if(o){c=[a,b,d];return}var e=n.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(a,"position",{get:function(){return[0,0,Yc(n.map,a)]}}),f&&f({viewState:a,interactionState:b,oldViewState:d}),g&&g(a,b,d)};(0,i.useImperativeHandle)(b,function(){var a;return{getMap:(a=m).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var q=(0,i.useMemo)(function(){return Ng(Ng({},h),{},{eventManager:k,container:h.container||l.current})},[h,l.current]);q.onViewportChange=p,q.viewport=h.viewport||ad(n),n.viewport=q.viewport;var r=function(a){var b=a.isDragging,c=void 0!==b&&b;if(c!==n.state.isDragging&&n.setState({isDragging:c}),o){g=a;return}var d=n.props.onInteractionStateChange;d&&d(a)},s=function(){n.width&&n.height&&j.setOptions(Ng(Ng(Ng({},n.props),n.props.viewState),{},{isInteractive:Boolean(n.props.onViewStateChange||n.props.onViewportChange),onViewportChange:p,onStateChange:r,eventManager:k,width:n.width,height:n.height}))},t=function(a){var b=a.width,c=a.height;n.width=b,n.height=c,s(),n.props.onResize({width:b,height:c})};(0,i.useEffect)(function(){return k.setElement(l.current),k.on({pointerdown:Tg.bind(n),pointermove:Vg.bind(n),pointerup:Ug.bind(n),pointerleave:Sg.bind(n,"onMouseOut"),click:Wg.bind(n),anyclick:Wg.bind(n),dblclick:Sg.bind(n,"onDblClick"),wheel:Sg.bind(n,"onWheel"),contextmenu:Sg.bind(n,"onContextMenu")}),function(){k.destroy()}},[]),Xc(function(){if(c){var a;p.apply(void 0,function(a){if(Array.isArray(a))return e(a)}(a=c)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||f(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}g&&r(g)}),s();var u=a.width,v=a.height,w=a.style,x=a.getCursor,y=(0,i.useMemo)(function(){return Ng(Ng({position:"relative"},w),{},{width:u,height:v,cursor:x(n.state)})},[w,u,v,x,n.state]);return c&&n._child||(n._child=i.createElement(Vc,{value:q},i.createElement("div",{key:"event-canvas",ref:l,style:y},i.createElement(gd,d({},a,{width:"100%",height:"100%",style:null,onResize:t,ref:m}))))),o=!1,n._child});Xg.supported=gd.supported,Xg.propTypes=Og,Xg.defaultProps=Pg;var Yg=Xg;function Zg(a,b){if(a===b)return!0;if(!a||!b)return!1;if(Array.isArray(a)){if(!Array.isArray(b)||a.length!==b.length)return!1;for(var c=0;c prop: ".concat(d))}})(l,a,c.current):l=(function(a,b,c){if(a.style&&a.style._loaded){var d=function(a){for(var b=1;b=0||(e[c]=a[c]);return e}(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d=0)&&Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}(c,["layout","paint","filter","minzoom","maxzoom","beforeId"]);if(l!==d.beforeId&&a.moveLayer(b,l),f!==d.layout){var n=d.layout||{};for(var o in f)Zg(f[o],n[o])||a.setLayoutProperty(b,o,f[o]);for(var p in n)f.hasOwnProperty(p)||a.setLayoutProperty(b,p,void 0)}if(h!==d.paint){var q=d.paint||{};for(var r in h)Zg(h[r],q[r])||a.setPaintProperty(b,r,h[r]);for(var s in q)h.hasOwnProperty(s)||a.setPaintProperty(b,s,void 0)}for(var t in Zg(i,d.filter)||a.setFilter(b,i),(j!==d.minzoom||k!==d.maxzoom)&&a.setLayerZoomRange(b,j,k),m)Zg(m[t],d[t])||a.setLayerProperty(b,t,m[t])}(a,b,c,d)}catch(e){console.warn(e)}})(h,g,a,c.current):(function(a,b,c){if(a.style&&a.style._loaded){var d=ch(ch({},c),{},{id:b});delete d.beforeId,a.addLayer(d,c.beforeId)}})(h,g,a),c.current=a,null}).propTypes=dh;var fh={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},gh={captureScroll:j.bool,captureDrag:j.bool,captureClick:j.bool,captureDoubleClick:j.bool,capturePointerMove:j.bool};function hh(){var a=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},b=(0,i.useContext)(Wc),c=(0,i.useRef)(null),d=(0,i.useRef)({props:a,state:{},context:b,containerRef:c}),e=d.current;return e.props=a,e.context=b,(0,i.useEffect)(function(){return(function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(b){var c=a.props;c.captureScroll&&b.stopPropagation(),c.onScroll&&c.onScroll(b,a)},panstart:function(b){var c=a.props;c.captureDrag&&b.stopPropagation(),c.onDragStart&&c.onDragStart(b,a)},anyclick:function(b){var c=a.props;c.captureClick&&b.stopPropagation(),c.onNativeClick&&c.onNativeClick(b,a)},click:function(b){var c=a.props;c.captureClick&&b.stopPropagation(),c.onClick&&c.onClick(b,a)},dblclick:function(b){var c=a.props;c.captureDoubleClick&&b.stopPropagation(),c.onDoubleClick&&c.onDoubleClick(b,a)},pointermove:function(b){var c=a.props;c.capturePointerMove&&b.stopPropagation(),c.onPointerMove&&c.onPointerMove(b,a)}};return c.watch(d,b),function(){c.off(d)}}})(e)},[b.eventManager]),e}function ih(a){var b=a.instance,c=hh(a),d=c.context,e=c.containerRef;return b._context=d,b._containerRef=e,b._render()}var jh=function(a){ld(f,a);var b,c,e=(b=f,c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,d=od(b);if(c){var e=od(this).constructor;a=Reflect.construct(d,arguments,e)}else a=d.apply(this,arguments);return nd(this,a)});function f(){var a;pc(this,f);for(var b=arguments.length,c=new Array(b),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var d="x"===c?a.offsetWidth:a.offsetHeight;return sh(b/100*d)/d*100};function uh(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}var vh=Object.assign({},mh,{className:j.string,longitude:j.number.isRequired,latitude:j.number.isRequired,style:j.object}),wh=Object.assign({},nh,{className:""});function xh(a){var b,c,d,e,f,h,j,l,m=(b=a,d=(c=k((0,i.useState)(null),2))[0],e=c[1],f=k((0,i.useState)(null),2),h=f[0],j=f[1],l=hh(lh(lh({},b),{},{onDragStart:qh})),l.callbacks=b,l.state.dragPos=d,l.state.setDragPos=e,l.state.dragOffset=h,l.state.setDragOffset=j,(0,i.useEffect)(function(){return(function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return(function(a,b){var c=b.props,d=b.callbacks,e=b.state,f=b.context;a.stopPropagation();var g=oh(a);e.setDragPos(g);var h=e.dragOffset;if(d.onDrag&&h){var i=Object.assign({},a);i.lngLat=ph(g,h,c,f),d.onDrag(i)}})(b,a)},panend:function(b){return(function(a,b){var c=b.props,d=b.callbacks,e=b.state,f=b.context;a.stopPropagation();var g=e.dragPos,h=e.dragOffset;if(e.setDragPos(null),e.setDragOffset(null),d.onDragEnd&&g&&h){var i=Object.assign({},a);i.lngLat=ph(g,h,c,f),d.onDragEnd(i)}})(b,a)},pancancel:function(b){var c,d;return c=b,d=a.state,void(c.stopPropagation(),d.setDragPos(null),d.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}})(l)},[l.context.eventManager,Boolean(d)]),l),n=m.state,o=m.containerRef,p=a.children,q=a.className,r=a.draggable,s=a.style,t=n.dragPos,u=function(a){var b=a.props,c=a.state,d=a.context,e=b.longitude,f=b.latitude,g=b.offsetLeft,h=b.offsetTop,i=c.dragPos,j=c.dragOffset,l=d.viewport,m=d.map;if(i&&j)return[i[0]+j[0],i[1]+j[1]];var n=Yc(m,{longitude:e,latitude:f}),o=k(l.project([e,f,n]),2),p=o[0],q=o[1];return[p+=g,q+=h]}(m),v=k(u,2),w=v[0],x=v[1],y="translate(".concat(sh(w),"px, ").concat(sh(x),"px)"),z=r?t?"grabbing":"grab":"auto",A=(0,i.useMemo)(function(){var a=function(a){for(var b=1;b0){var q=m,r=p;for(m=0;m<=1;m+=.5)o=(n=c-m*g)+g,p=Math.max(0,j-n)+Math.max(0,o-e+j),p0){var w=l,x=v;for(l=0;l<=1;l+=s)u=(t=b-l*f)+f,v=Math.max(0,j-t)+Math.max(0,u-d+j),v1||I< -1||G<0||G>B.width||H<0||H>B.height?P.display="none":P.zIndex=Math.floor((1-I)/2*1e5)),P),T=(0,i.useCallback)(function(a){c.props.onClose();var b=c.context.eventManager;b&&b.once("click",function(a){return a.stopPropagation()},a.target)},[]);return i.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(R," ").concat(j),style:S,ref:e},i.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:n}}),i.createElement("div",{key:"content",ref:b,className:"mapboxgl-popup-content"},o&&i.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:T},"\xd7"),p))}function Dh(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}Ch.propTypes=Ah,Ch.defaultProps=Bh,i.memo(Ch);var Eh=Object.assign({},gh,{toggleLabel:j.string,className:j.string,style:j.object,compact:j.bool,customAttribution:j.oneOfType([j.string,j.arrayOf(j.string)])}),Fh=Object.assign({},fh,{className:"",toggleLabel:"Toggle Attribution"});function Gh(a){var b=hh(a),c=b.context,d=b.containerRef,e=(0,i.useRef)(null),f=k((0,i.useState)(!1),2),h=f[0],j=f[1];(0,i.useEffect)(function(){var b,f,g,h,i,j;return c.map&&(b=(f={customAttribution:a.customAttribution},g=c.map,h=d.current,i=e.current,(j=new(Gc()).AttributionControl(f))._map=g,j._container=h,j._innerContainer=i,j._updateAttributions(),j._updateEditLink(),g.on("styledata",j._updateData),g.on("sourcedata",j._updateData),j)),function(){var a;return b&&void((a=b)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[c.map]);var l=void 0===a.compact?c.viewport.width<=640:a.compact;(0,i.useEffect)(function(){!l&&h&&j(!1)},[l]);var m=(0,i.useCallback)(function(){return j(function(a){return!a})},[]),n=(0,i.useMemo)(function(){return(function(a){for(var b=1;bg)return 1}return 0})(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),d=b.viewport.bearing,e={transform:"rotate(".concat(-d,"deg)")},2===c?i.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:e}):i.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:e})))))}function Xh(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}Wh.propTypes=Sh,Wh.defaultProps=Th,i.memo(Wh);var Yh=Object.assign({},gh,{className:j.string,style:j.object,maxWidth:j.number,unit:j.oneOf(["imperial","metric","nautical"])}),Zh=Object.assign({},fh,{className:"",maxWidth:100,unit:"metric"});function $h(a){var b=hh(a),c=b.context,d=b.containerRef,e=k((0,i.useState)(null),2),f=e[0],h=e[1];(0,i.useEffect)(function(){if(c.map){var a=new(Gc()).ScaleControl();a._map=c.map,a._container=d.current,h(a)}},[c.map]),f&&(f.options=a,f._onMove());var j=(0,i.useMemo)(function(){return(function(a){for(var b=1;b\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",b=g.console&&(g.console.warn||g.console.log);return b&&b.call(g.console,d,e),c.apply(this,arguments)}}m="function"!=typeof Object.assign?function(b){if(b===l||null===b)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(b),c=1;c -1}function _(a){return a.trim().split(/\s+/g)}function aa(a,d,c){if(a.indexOf&&!c)return a.indexOf(d);for(var b=0;baa(e,f)&&b.push(c[a]),e[a]=f,a++}return g&&(b=d?b.sort(function(a,b){return a[d]>b[d]}):b.sort()),b}function n(e,a){for(var c,d,f=a[0].toUpperCase()+a.slice(1),b=0;b1&&!b.firstMultiple?b.firstMultiple=na(a):1===h&&(b.firstMultiple=!1);var i=b.firstInput,c=b.firstMultiple,j=c?c.center:i.center,k=a.center=oa(e);a.timeStamp=U(),a.deltaTime=a.timeStamp-i.timeStamp,a.angle=sa(j,k),a.distance=ra(j,k),la(b,a),a.offsetDirection=qa(a.deltaX,a.deltaY);var d=pa(a.deltaTime,a.deltaX,a.deltaY);a.overallVelocityX=d.x,a.overallVelocityY=d.y,a.overallVelocity=T(d.x)>T(d.y)?d.x:d.y,a.scale=c?ua(c.pointers,e):1,a.rotation=c?ta(c.pointers,e):0,a.maxPointers=b.prevInput?a.pointers.length>b.prevInput.maxPointers?a.pointers.length:b.prevInput.maxPointers:a.pointers.length,ma(b,a);var f=g.element;Z(a.srcEvent.target,f)&&(f=a.srcEvent.target),a.target=f}function la(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(1===b.eventType||4===f.eventType)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function ma(h,a){var d,e,f,g,b=h.lastInterval||a,i=a.timeStamp-b.timeStamp;if(8!=a.eventType&&(i>25||l===b.velocity)){var j=a.deltaX-b.deltaX,k=a.deltaY-b.deltaY,c=pa(i,j,k);e=c.x,f=c.y,d=T(c.x)>T(c.y)?c.x:c.y,g=qa(j,k),h.lastInterval=a}else d=b.velocity,e=b.velocityX,f=b.velocityY,g=b.direction;a.velocity=d,a.velocityX=e,a.velocityY=f,a.direction=g}function na(a){for(var c=[],b=0;b=T(b)?a<0?2:4:b<0?8:16}function ra(b,c,a){a||(a=ha);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return Math.sqrt(d*d+e*e)}function sa(b,c,a){a||(a=ha);var d=c[a[0]]-b[a[0]],e=c[a[1]]-b[a[1]];return 180*Math.atan2(e,d)/Math.PI}function ta(a,b){return sa(b[1],b[0],ia)+sa(a[1],a[0],ia)}function ua(a,b){return ra(b[0],b[1],ia)/ra(a[0],a[1],ia)}f.prototype={handler:function(){},init:function(){this.evEl&&H(this.element,this.evEl,this.domHandler),this.evTarget&&H(this.target,this.evTarget,this.domHandler),this.evWin&&H(ea(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&I(this.element,this.evEl,this.domHandler),this.evTarget&&I(this.target,this.evTarget,this.domHandler),this.evWin&&I(ea(this.element),this.evWin,this.domHandler)}};var va={mousedown:1,mousemove:2,mouseup:4};function u(){this.evEl="mousedown",this.evWin="mousemove mouseup",this.pressed=!1,f.apply(this,arguments)}e(u,f,{handler:function(a){var b=va[a.type];1&b&&0===a.button&&(this.pressed=!0),2&b&&1!==a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:L,srcEvent:a}))}});var wa={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},xa={2:K,3:"pen",4:L,5:"kinect"},M="pointerdown",N="pointermove pointerup pointercancel";function v(){this.evEl=M,this.evWin=N,f.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}g.MSPointerEvent&&!g.PointerEvent&&(M="MSPointerDown",N="MSPointerMove MSPointerUp MSPointerCancel"),e(v,f,{handler:function(a){var b=this.store,e=!1,d=wa[a.type.toLowerCase().replace("ms","")],f=xa[a.pointerType]||a.pointerType,c=aa(b,a.pointerId,"pointerId");1&d&&(0===a.button||f==K)?c<0&&(b.push(a),c=b.length-1):12&d&&(e=!0),!(c<0)&&(b[c]=a,this.callback(this.manager,d,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),e&&b.splice(c,1))}});var ya={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function w(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,f.apply(this,arguments)}function za(b,d){var a=ba(b.touches),c=ba(b.changedTouches);return 12&d&&(a=ca(a.concat(c),"identifier",!0)),[a,c]}e(w,f,{handler:function(c){var a=ya[c.type];if(1===a&&(this.started=!0),this.started){var b=za.call(this,c,a);12&a&&b[0].length-b[1].length==0&&(this.started=!1),this.callback(this.manager,a,{pointers:b[0],changedPointers:b[1],pointerType:K,srcEvent:c})}}});var Aa={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function x(){this.evTarget="touchstart touchmove touchend touchcancel",this.targetIds={},f.apply(this,arguments)}function Ba(h,g){var b=ba(h.touches),c=this.targetIds;if(3&g&&1===b.length)return c[b[0].identifier]=!0,[b,b];var a,d,e=ba(h.changedTouches),f=[],i=this.target;if(d=b.filter(function(a){return Z(a.target,i)}),1===g)for(a=0;a -1&&d.splice(a,1)},2500)}}function Ea(b){for(var d=b.srcEvent.clientX,e=b.srcEvent.clientY,a=0;a -1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(d){var c=this,a=this.state;function b(a){c.manager.emit(a,d)}a<8&&b(c.options.event+Ma(a)),b(c.options.event),d.additionalEvent&&b(d.additionalEvent),a>=8&&b(c.options.event+Ma(a))},tryEmit:function(a){if(this.canEmit())return this.emit(a);this.state=32},canEmit:function(){for(var a=0;ac.threshold&&b&c.direction},attrTest:function(a){return h.prototype.attrTest.call(this,a)&&(2&this.state|| !(2&this.state)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=Na(a.direction);b&&(a.additionalEvent=this.options.event+b),this._super.emit.call(this,a)}}),e(p,h,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Ia]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||2&this.state)},emit:function(a){if(1!==a.scale){var b=a.scale<1?"in":"out";a.additionalEvent=this.options.event+b}this._super.emit.call(this,a)}}),e(q,i,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Ga]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distanceb.time;if(this._input=a,d&&c&&(!(12&a.eventType)||e)){if(1&a.eventType)this.reset(),this._timer=V(function(){this.state=8,this.tryEmit()},b.time,this);else if(4&a.eventType)return 8}else this.reset();return 32},reset:function(){clearTimeout(this._timer)},emit:function(a){8===this.state&&(a&&4&a.eventType?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=U(),this.manager.emit(this.options.event,this._input)))}}),e(r,h,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Ia]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||2&this.state)}}),e(s,h,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return o.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return 30&c?b=a.overallVelocity:6&c?b=a.overallVelocityX:24&c&&(b=a.overallVelocityY),this._super.attrTest.call(this,a)&&c&a.offsetDirection&&a.distance>this.options.threshold&&a.maxPointers==this.options.pointers&&T(b)>this.options.velocity&&4&a.eventType},emit:function(a){var b=Na(a.offsetDirection);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),e(j,i,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Ha]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance1)for(var a=1;ac.length)&&(a=c.length);for(var b=0,d=new Array(a);bc?c:a}Math.PI,Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)}),j=new h(4),h!=Float32Array&&(j[0]=0,j[1]=0,j[2]=0,j[3]=0);const Ha=Math.log2||function(a){return Math.log(a)*Math.LOG2E};function Ia(e,f,g){var h=f[0],i=f[1],j=f[2],k=f[3],l=f[4],m=f[5],n=f[6],o=f[7],p=f[8],q=f[9],r=f[10],s=f[11],t=f[12],u=f[13],v=f[14],w=f[15],a=g[0],b=g[1],c=g[2],d=g[3];return e[0]=a*h+b*l+c*p+d*t,e[1]=a*i+b*m+c*q+d*u,e[2]=a*j+b*n+c*r+d*v,e[3]=a*k+b*o+c*s+d*w,a=g[4],b=g[5],c=g[6],d=g[7],e[4]=a*h+b*l+c*p+d*t,e[5]=a*i+b*m+c*q+d*u,e[6]=a*j+b*n+c*r+d*v,e[7]=a*k+b*o+c*s+d*w,a=g[8],b=g[9],c=g[10],d=g[11],e[8]=a*h+b*l+c*p+d*t,e[9]=a*i+b*m+c*q+d*u,e[10]=a*j+b*n+c*r+d*v,e[11]=a*k+b*o+c*s+d*w,a=g[12],b=g[13],c=g[14],d=g[15],e[12]=a*h+b*l+c*p+d*t,e[13]=a*i+b*m+c*q+d*u,e[14]=a*j+b*n+c*r+d*v,e[15]=a*k+b*o+c*s+d*w,e}function Ja(b,a,f){var g,h,i,j,k,l,m,n,o,p,q,r,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],b[0]=g,b[1]=h,b[2]=i,b[3]=j,b[4]=k,b[5]=l,b[6]=m,b[7]=n,b[8]=o,b[9]=p,b[10]=q,b[11]=r,b[12]=g*c+k*d+o*e+a[12],b[13]=h*c+l*d+p*e+a[13],b[14]=i*c+m*d+q*e+a[14],b[15]=j*c+n*d+r*e+a[15]),b}function Ka(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function La(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=b[0],t=b[1],u=b[2],v=b[3],w=b[4],x=b[5],y=b[6],z=b[7],A=b[8],B=b[9],C=b[10],D=b[11],E=b[12],F=b[13],G=b[14],H=b[15];return Math.abs(c-s)<=1e-6*Math.max(1,Math.abs(c),Math.abs(s))&&Math.abs(d-t)<=1e-6*Math.max(1,Math.abs(d),Math.abs(t))&&Math.abs(e-u)<=1e-6*Math.max(1,Math.abs(e),Math.abs(u))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(g-w)<=1e-6*Math.max(1,Math.abs(g),Math.abs(w))&&Math.abs(h-x)<=1e-6*Math.max(1,Math.abs(h),Math.abs(x))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(j-z)<=1e-6*Math.max(1,Math.abs(j),Math.abs(z))&&Math.abs(k-A)<=1e-6*Math.max(1,Math.abs(k),Math.abs(A))&&Math.abs(l-B)<=1e-6*Math.max(1,Math.abs(l),Math.abs(B))&&Math.abs(m-C)<=1e-6*Math.max(1,Math.abs(m),Math.abs(C))&&Math.abs(n-D)<=1e-6*Math.max(1,Math.abs(n),Math.abs(D))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(p-F)<=1e-6*Math.max(1,Math.abs(p),Math.abs(F))&&Math.abs(q-G)<=1e-6*Math.max(1,Math.abs(q),Math.abs(G))&&Math.abs(r-H)<=1e-6*Math.max(1,Math.abs(r),Math.abs(H))}function Ma(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a}function Na(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a}function Oa(a,b){if(!a)throw new Error(b||"@math.gl/web-mercator: assertion failed.")}sb=new h(2),h!=Float32Array&&(sb[0]=0,sb[1]=0),tb=new h(3),h!=Float32Array&&(tb[0]=0,tb[1]=0,tb[2]=0);const o=Math.PI,Pa=o/4,Qa=o/180,Ra=180/o;function Sa(a){return Math.pow(2,a)}function Ta([b,a]){return Oa(Number.isFinite(b)),Oa(Number.isFinite(a)&&a>= -90&&a<=90,"invalid latitude"),[512*(b*Qa+o)/(2*o),512*(o+Math.log(Math.tan(Pa+.5*(a*Qa))))/(2*o)]}function Ua([a,b]){return[(a/512*(2*o)-o)*Ra,2*(Math.atan(Math.exp(b/512*(2*o)-o))-Pa)*Ra]}function Va(a){return 2*Math.atan(.5/a)*Ra}function Wa(a){return .5/Math.tan(.5*a*Qa)}function Xa(i,c,j=0){const[a,b,e]=i;if(Oa(Number.isFinite(a)&&Number.isFinite(b),"invalid pixel coordinate"),Number.isFinite(e)){const k=Da(c,[a,b,e,1]);return k}const f=Da(c,[a,b,0,1]),g=Da(c,[a,b,1,1]),d=f[2],h=g[2];return Na([],f,g,d===h?0:((j||0)-d)/(h-d))}const Ya=Math.PI/180;function Za(a,c,d){const{pixelUnprojectionMatrix:e}=a,b=Da(e,[c,0,1,1]),f=Da(e,[c,a.height,1,1]),h=d*a.distanceScales.unitsPerMeter[2],i=(h-b[2])/(f[2]-b[2]),j=Na([],b,f,i),g=Ua(j);return g[2]=d,g}class $a{constructor({width:f,height:c,latitude:l=0,longitude:m=0,zoom:p=0,pitch:n=0,bearing:q=0,altitude:a=null,fovy:b=null,position:o=null,nearZMultiplier:t=.02,farZMultiplier:u=1.01}={width:1,height:1}){f=f||1,c=c||1,null===b&&null===a?b=Va(a=1.5):null===b?b=Va(a):null===a&&(a=Wa(b));const r=Sa(p);a=Math.max(.75,a);const s=function({latitude:c,longitude:i,highPrecision:j=!1}){Oa(Number.isFinite(c)&&Number.isFinite(i));const b={},d=Math.cos(c*Qa),e=1.4222222222222223/d,a=12790407194604047e-21/d;if(b.unitsPerMeter=[a,a,a],b.metersPerUnit=[1/a,1/a,1/a],b.unitsPerDegree=[1.4222222222222223,e,a],b.degreesPerUnit=[.703125,1/e,1/a],j){const f=Qa*Math.tan(c*Qa)/d,k=1.4222222222222223*f/2,g=12790407194604047e-21*f,h=g/e*a;b.unitsPerDegree2=[0,k,g],b.unitsPerMeter2=[h,0,h]}return b}({longitude:m,latitude:l}),d=Ta([m,l]);if(d[2]=0,o){var e,g,h,i,j,k;i=d,j=d,e=[],g=o,h=s.unitsPerMeter,e[0]=g[0]*h[0],e[1]=g[1]*h[1],e[2]=g[2]*h[2],k=e,i[0]=j[0]+k[0],i[1]=j[1]+k[1],i[2]=j[2]+k[2]}this.projectionMatrix=(function({width:h,height:i,pitch:j,altitude:k,fovy:l,nearZMultiplier:m,farZMultiplier:n}){var a,f,g,c,b,d,e;const{fov:o,aspect:p,near:q,far:r}=function({width:f,height:g,fovy:a=Va(1.5),altitude:d,pitch:h=0,nearZMultiplier:i=1,farZMultiplier:j=1}){void 0!==d&&(a=Va(d));const b=.5*a*Qa,c=Wa(a),e=h*Qa;return{fov:2*b,aspect:f/g,focalDistance:c,near:i,far:(Math.sin(e)*(Math.sin(b)*c/Math.sin(Math.min(Math.max(Math.PI/2-e-b,.01),Math.PI-.01)))+c)*j}}({width:h,height:i,altitude:k,fovy:l,pitch:j,nearZMultiplier:m,farZMultiplier:n}),s=(a=[],f=o,g=p,c=q,b=r,e=1/Math.tan(f/2),a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(d=1/(c-b),a[10]=(b+c)*d,a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a);return s})({width:f,height:c,pitch:n,fovy:b,nearZMultiplier:t,farZMultiplier:u}),this.viewMatrix=(function({height:F,pitch:G,bearing:H,altitude:I,scale:l,center:E=null}){var a,b,m,f,g,n,o,p,q,r,s,t,u,c,d,v,h,i,w,x,y,z,A,B,C,D,j,k;const e=Ca();return Ja(e,e,[0,0,-I]),a=e,b=e,m=-G*Qa,f=Math.sin(m),g=Math.cos(m),n=b[4],o=b[5],p=b[6],q=b[7],r=b[8],s=b[9],t=b[10],u=b[11],b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=n*g+r*f,a[5]=o*g+s*f,a[6]=p*g+t*f,a[7]=q*g+u*f,a[8]=r*g-n*f,a[9]=s*g-o*f,a[10]=t*g-p*f,a[11]=u*g-q*f,c=e,d=e,v=H*Qa,h=Math.sin(v),i=Math.cos(v),w=d[0],x=d[1],y=d[2],z=d[3],A=d[4],B=d[5],C=d[6],D=d[7],d!==c&&(c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15]),c[0]=w*i+A*h,c[1]=x*i+B*h,c[2]=y*i+C*h,c[3]=z*i+D*h,c[4]=A*i-w*h,c[5]=B*i-x*h,c[6]=C*i-y*h,c[7]=D*i-z*h,Ka(e,e,[l/=F,l,l]),E&&Ja(e,e,(j=[],k=E,j[0]=-k[0],j[1]=-k[1],j[2]=-k[2],j)),e})({height:c,scale:r,center:d,pitch:n,bearing:q,altitude:a}),this.width=f,this.height=c,this.scale=r,this.latitude=l,this.longitude=m,this.zoom=p,this.pitch=n,this.bearing=q,this.altitude=a,this.fovy=b,this.center=d,this.meterOffset=o||[0,0,0],this.distanceScales=s,this._initMatrices(),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),Object.freeze(this)}_initMatrices(){var b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,a;const{width:I,height:J,projectionMatrix:K,viewMatrix:L}=this,G=Ca();Ia(G,G,K),Ia(G,G,L),this.viewProjectionMatrix=G;const d=Ca();Ka(d,d,[I/2,-J/2,1]),Ja(d,d,[1,-1,0]),Ia(d,d,G);const H=(b=Ca(),e=(c=d)[0],f=c[1],g=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=c[8],n=c[9],o=c[10],p=c[11],q=c[12],r=c[13],s=c[14],t=c[15],u=e*j-f*i,v=e*k-g*i,w=e*l-h*i,x=f*k-g*j,y=f*l-h*j,z=g*l-h*k,A=m*r-n*q,B=m*s-o*q,C=m*t-p*q,D=n*s-o*r,E=n*t-p*r,F=o*t-p*s,a=u*F-v*E+w*D+x*C-y*B+z*A,a?(a=1/a,b[0]=(j*F-k*E+l*D)*a,b[1]=(g*E-f*F-h*D)*a,b[2]=(r*z-s*y+t*x)*a,b[3]=(o*y-n*z-p*x)*a,b[4]=(k*C-i*F-l*B)*a,b[5]=(e*F-g*C+h*B)*a,b[6]=(s*w-q*z-t*v)*a,b[7]=(m*z-o*w+p*v)*a,b[8]=(i*E-j*C+l*A)*a,b[9]=(f*C-e*E-h*A)*a,b[10]=(q*y-r*w+t*u)*a,b[11]=(n*w-m*y-p*u)*a,b[12]=(j*B-i*D-k*A)*a,b[13]=(e*D-f*B+g*A)*a,b[14]=(r*v-q*x-s*u)*a,b[15]=(m*x-n*v+o*u)*a,b):null);if(!H)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=H}equals(a){return a instanceof $a&&a.width===this.width&&a.height===this.height&&La(a.projectionMatrix,this.projectionMatrix)&&La(a.viewMatrix,this.viewMatrix)}project(a,{topLeft:f=!0}={}){const g=this.projectPosition(a),b=function(d,e){const[a,b,c=0]=d;return Oa(Number.isFinite(a)&&Number.isFinite(b)&&Number.isFinite(c)),Da(e,[a,b,c,1])}(g,this.pixelProjectionMatrix),[c,d]=b,e=f?d:this.height-d;return 2===a.length?[c,e]:[c,e,b[2]]}unproject(f,{topLeft:g=!0,targetZ:a}={}){const[h,d,e]=f,i=g?d:this.height-d,j=a&&a*this.distanceScales.unitsPerMeter[2],k=Xa([h,i,e],this.pixelUnprojectionMatrix,j),[b,c,l]=this.unprojectPosition(k);return Number.isFinite(e)?[b,c,l]:Number.isFinite(a)?[b,c,a]:[b,c]}projectPosition(a){const[b,c]=Ta(a),d=(a[2]||0)*this.distanceScales.unitsPerMeter[2];return[b,c,d]}unprojectPosition(a){const[b,c]=Ua(a),d=(a[2]||0)*this.distanceScales.metersPerUnit[2];return[b,c,d]}projectFlat(a){return Ta(a)}unprojectFlat(a){return Ua(a)}getMapCenterByLngLatPosition({lngLat:c,pos:d}){var a,b;const e=Xa(d,this.pixelUnprojectionMatrix),f=Ta(c),g=Ma([],f,(a=[],b=e,a[0]=-b[0],a[1]=-b[1],a)),h=Ma([],this.center,g);return Ua(h)}getLocationAtPoint({lngLat:a,pos:b}){return this.getMapCenterByLngLatPosition({lngLat:a,pos:b})}fitBounds(c,d={}){const{width:a,height:b}=this,{longitude:e,latitude:f,zoom:g}=function({width:m,height:n,bounds:o,minExtent:f=0,maxZoom:p=24,padding:a=0,offset:g=[0,0]}){const[[q,r],[s,t]]=o;if(Number.isFinite(a)){const b=a;a={top:b,bottom:b,left:b,right:b}}else Oa(Number.isFinite(a.top)&&Number.isFinite(a.bottom)&&Number.isFinite(a.left)&&Number.isFinite(a.right));const c=Ta([q,Ga(t,-85.051129,85.051129)]),d=Ta([s,Ga(r,-85.051129,85.051129)]),h=[Math.max(Math.abs(d[0]-c[0]),f),Math.max(Math.abs(d[1]-c[1]),f)],e=[m-a.left-a.right-2*Math.abs(g[0]),n-a.top-a.bottom-2*Math.abs(g[1])];Oa(e[0]>0&&e[1]>0);const i=e[0]/h[0],j=e[1]/h[1],u=(a.right-a.left)/2/i,v=(a.bottom-a.top)/2/j,w=[(d[0]+c[0])/2+u,(d[1]+c[1])/2+v],k=Ua(w),l=Math.min(p,Ha(Math.abs(Math.min(i,j))));return Oa(Number.isFinite(l)),{longitude:k[0],latitude:k[1],zoom:l}}(Object.assign({width:a,height:b,bounds:c},d));return new $a({width:a,height:b,longitude:e,latitude:f,zoom:g})}getBounds(b){const a=this.getBoundingRegion(b),c=Math.min(...a.map(a=>a[0])),d=Math.max(...a.map(a=>a[0])),e=Math.min(...a.map(a=>a[1])),f=Math.max(...a.map(a=>a[1]));return[[c,e],[d,f]]}getBoundingRegion(a={}){return(function(a,d=0){const{width:e,height:h,unproject:b}=a,c={targetZ:d},i=b([0,h],c),j=b([e,h],c);let f,g;const k=a.fovy?.5*a.fovy*Ya:Math.atan(.5/a.altitude),l=(90-a.pitch)*Ya;return k>l-.01?(f=Za(a,0,d),g=Za(a,e,d)):(f=b([0,0],c),g=b([e,0],c)),[i,j,g,f]})(this,a.z||0)}}const _a=["longitude","latitude","zoom"],ab={curve:1.414,speed:1.2};function bb(d,h,i){var f,j,k,o,p,q;i=Object.assign({},ab,i);const g=i.curve,l=d.zoom,w=[d.longitude,d.latitude],x=Sa(l),y=h.zoom,z=[h.longitude,h.latitude],A=Sa(y-l),r=Ta(w),B=Ta(z),s=(f=[],j=B,k=r,f[0]=j[0]-k[0],f[1]=j[1]-k[1],f),a=Math.max(d.width,d.height),e=a/A,t=(p=(o=s)[0],q=o[1],Math.hypot(p,q)*x),c=Math.max(t,.01),b=g*g,m=(e*e-a*a+b*b*c*c)/(2*a*b*c),n=(e*e-a*a-b*b*c*c)/(2*e*b*c),u=Math.log(Math.sqrt(m*m+1)-m),v=Math.log(Math.sqrt(n*n+1)-n);return{startZoom:l,startCenterXY:r,uDelta:s,w0:a,u1:t,S:(v-u)/g,rho:g,rho2:b,r0:u,r1:v}}var O=function(){if("undefined"!=typeof Map)return Map;function a(a,c){var b=-1;return a.some(function(a,d){return a[0]===c&&(b=d,!0)}),b}return(function(){function b(){this.__entries__=[]}return Object.defineProperty(b.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),b.prototype.get=function(c){var d=a(this.__entries__,c),b=this.__entries__[d];return b&&b[1]},b.prototype.set=function(b,c){var d=a(this.__entries__,b);~d?this.__entries__[d][1]=c:this.__entries__.push([b,c])},b.prototype.delete=function(d){var b=this.__entries__,c=a(b,d);~c&&b.splice(c,1)},b.prototype.has=function(b){return!!~a(this.__entries__,b)},b.prototype.clear=function(){this.__entries__.splice(0)},b.prototype.forEach=function(e,a){void 0===a&&(a=null);for(var b=0,c=this.__entries__;b0},a.prototype.connect_=function(){!cb||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),fb?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},a.prototype.disconnect_=function(){cb&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},a.prototype.onTransitionEnd_=function(b){var a=b.propertyName,c=void 0===a?"":a;eb.some(function(a){return!!~c.indexOf(a)})&&this.refresh()},a.getInstance=function(){return this.instance_||(this.instance_=new a()),this.instance_},a.instance_=null,a}(),hb=function(b,c){for(var a=0,d=Object.keys(c);a0},a}(),rb="undefined"!=typeof WeakMap?new WeakMap():new O(),P=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var c=gb.getInstance(),d=new qb(b,c,this);rb.set(this,d)}return a}();["observe","unobserve","disconnect"].forEach(function(a){P.prototype[a]=function(){var b;return(b=rb.get(this))[a].apply(b,arguments)}});var sb,tb,ub=void 0!==p.ResizeObserver?p.ResizeObserver:P;function vb(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function wb(d,c){for(var b=0;b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function Bb(a,c){if(a){if("string"==typeof a)return Cb(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return Cb(a,c)}}function Cb(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b1&& void 0!==arguments[1]?arguments[1]:"component";b.debug&&a.checkPropTypes(R,b,"prop",c)}var i=function(){function a(b){var c=this;if(vb(this,a),g(this,"props",S),g(this,"width",0),g(this,"height",0),g(this,"_fireLoadEvent",function(){c.props.onLoad({type:"load",target:c._map})}),g(this,"_handleError",function(a){c.props.onError(a)}),!b.mapboxgl)throw new Error("Mapbox not available");this.mapboxgl=b.mapboxgl,a.initialized||(a.initialized=!0,this._checkStyleSheet(this.mapboxgl.version)),this._initialize(b)}return xb(a,[{key:"finalize",value:function(){return this._destroy(),this}},{key:"setProps",value:function(a){return this._update(this.props,a),this}},{key:"redraw",value:function(){var a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}},{key:"getMap",value:function(){return this._map}},{key:"_reuse",value:function(b){this._map=a.savedMap;var d=this._map.getContainer(),c=b.container;for(c.classList.add("mapboxgl-map");d.childNodes.length>0;)c.appendChild(d.childNodes[0]);this._map._container=c,a.savedMap=null,b.mapStyle&&this._map.setStyle(Eb(b.mapStyle),{diff:!1}),this._map.isStyleLoaded()?this._fireLoadEvent():this._map.once("styledata",this._fireLoadEvent)}},{key:"_create",value:function(b){if(b.reuseMaps&&a.savedMap)this._reuse(b);else{if(b.gl){var d=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(){return HTMLCanvasElement.prototype.getContext=d,b.gl}}var c={container:b.container,center:[0,0],zoom:8,pitch:0,bearing:0,maxZoom:24,style:Eb(b.mapStyle),interactive:!1,trackResize:!1,attributionControl:b.attributionControl,preserveDrawingBuffer:b.preserveDrawingBuffer};b.transformRequest&&(c.transformRequest=b.transformRequest),this._map=new this.mapboxgl.Map(Object.assign({},c,b.mapOptions)),this._map.once("load",this._fireLoadEvent),this._map.on("error",this._handleError)}return this}},{key:"_destroy",value:function(){this._map&&(this.props.reuseMaps&&!a.savedMap?(a.savedMap=this._map,this._map.off("load",this._fireLoadEvent),this._map.off("error",this._handleError),this._map.off("styledata",this._fireLoadEvent)):this._map.remove(),this._map=null)}},{key:"_initialize",value:function(a){var d=this;Gb(a=Object.assign({},S,a),"Mapbox"),this.mapboxgl.accessToken=a.mapboxApiAccessToken||S.mapboxApiAccessToken,this.mapboxgl.baseApiUrl=a.mapboxApiUrl,this._create(a);var b=a.container;Object.defineProperty(b,"offsetWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"clientWidth",{configurable:!0,get:function(){return d.width}}),Object.defineProperty(b,"offsetHeight",{configurable:!0,get:function(){return d.height}}),Object.defineProperty(b,"clientHeight",{configurable:!0,get:function(){return d.height}});var c=this._map.getCanvas();c&&(c.style.outline="none"),this._updateMapViewport({},a),this._updateMapSize({},a),this.props=a}},{key:"_update",value:function(b,a){if(this._map){Gb(a=Object.assign({},this.props,a),"Mapbox");var c=this._updateMapViewport(b,a),d=this._updateMapSize(b,a);this._updateMapStyle(b,a),!a.asyncRender&&(c||d)&&this.redraw(),this.props=a}}},{key:"_updateMapStyle",value:function(b,a){b.mapStyle!==a.mapStyle&&this._map.setStyle(Eb(a.mapStyle),{diff:!a.preventStyleDiffing})}},{key:"_updateMapSize",value:function(b,a){var c=b.width!==a.width||b.height!==a.height;return c&&(this.width=a.width,this.height=a.height,this._map.resize()),c}},{key:"_updateMapViewport",value:function(d,e){var b=this._getViewState(d),a=this._getViewState(e),c=a.latitude!==b.latitude||a.longitude!==b.longitude||a.zoom!==b.zoom||a.pitch!==b.pitch||a.bearing!==b.bearing||a.altitude!==b.altitude;return c&&(this._map.jumpTo(this._viewStateToMapboxProps(a)),a.altitude!==b.altitude&&(this._map.transform.altitude=a.altitude)),c}},{key:"_getViewState",value:function(b){var a=b.viewState||b,f=a.longitude,g=a.latitude,h=a.zoom,c=a.pitch,d=a.bearing,e=a.altitude;return{longitude:f,latitude:g,zoom:h,pitch:void 0===c?0:c,bearing:void 0===d?0:d,altitude:void 0===e?1.5:e}}},{key:"_checkStyleSheet",value:function(){var c=arguments.length>0&& void 0!==arguments[0]?arguments[0]:"0.47.0";if(void 0!==Q)try{var a=Q.createElement("div");if(a.className="mapboxgl-map",a.style.display="none",Q.body.appendChild(a),!("static"!==window.getComputedStyle(a).position)){var b=Q.createElement("link");b.setAttribute("rel","stylesheet"),b.setAttribute("type","text/css"),b.setAttribute("href","https://api.tiles.mapbox.com/mapbox-gl-js/v".concat(c,"/mapbox-gl.css")),Q.head.appendChild(b)}}catch(d){}}},{key:"_viewStateToMapboxProps",value:function(a){return{center:[a.longitude,a.latitude],zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}}]),a}();g(i,"initialized",!1),g(i,"propTypes",R),g(i,"defaultProps",S),g(i,"savedMap",null);var T=b(6158),B=b.n(T);function Hb(a){return Array.isArray(a)||ArrayBuffer.isView(a)}function Ib(a,b){if(a===b)return!0;if(Hb(a)&&Hb(b)){if(a.length!==b.length)return!1;for(var c=0;c=Math.abs(a-b)}function Jb(a,b,c){return Math.max(b,Math.min(c,a))}function Kb(a,c,b){return Hb(a)?a.map(function(a,d){return Kb(a,c[d],b)}):b*c+(1-b)*a}function Lb(a,b){if(!a)throw new Error(b||"react-map-gl: assertion failed.")}function Mb(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function Nb(c){for(var a=1;a0,"`scale` must be a positive number");var f=this._state,b=f.startZoom,c=f.startZoomLngLat;Number.isFinite(b)||(b=this._viewportProps.zoom,c=this._unproject(i)||this._unproject(d)),Lb(c,"`startZoomLngLat` prop is required for zoom behavior to calculate where to position the map.");var g=this._calculateNewZoom({scale:e,startZoom:b||0}),j=new $a(Object.assign({},this._viewportProps,{zoom:g})),k=j.getMapCenterByLngLatPosition({lngLat:c,pos:d}),h=Ba(k,2),l=h[0],m=h[1];return this._getUpdatedMapState({zoom:g,longitude:l,latitude:m})}},{key:"zoomEnd",value:function(){return this._getUpdatedMapState({startZoomLngLat:null,startZoom:null})}},{key:"_getUpdatedMapState",value:function(b){return new a(Object.assign({},this._viewportProps,this._state,b))}},{key:"_applyConstraints",value:function(a){var b=a.maxZoom,c=a.minZoom,d=a.zoom;a.zoom=Jb(d,c,b);var e=a.maxPitch,f=a.minPitch,g=a.pitch;return a.pitch=Jb(g,f,e),Object.assign(a,function({width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k=0,bearing:c=0}){(b< -180||b>180)&&(b=Ea(b+180,360)-180),(c< -180||c>180)&&(c=Ea(c+180,360)-180);const f=Ha(e/512);if(d<=f)d=f,a=0;else{const g=e/2/Math.pow(2,d),h=Ua([0,g])[1];if(ai&&(a=i)}}return{width:j,height:e,longitude:b,latitude:a,zoom:d,pitch:k,bearing:c}}(a)),a}},{key:"_unproject",value:function(a){var b=new $a(this._viewportProps);return a&&b.unproject(a)}},{key:"_calculateNewLngLat",value:function(a){var b=a.startPanLngLat,c=a.pos,d=new $a(this._viewportProps);return d.getMapCenterByLngLatPosition({lngLat:b,pos:c})}},{key:"_calculateNewZoom",value:function(a){var c=a.scale,d=a.startZoom,b=this._viewportProps,e=b.maxZoom,f=b.minZoom;return Jb(d+Math.log2(c),f,e)}},{key:"_calculateNewPitchAndBearing",value:function(c){var f=c.deltaScaleX,a=c.deltaScaleY,g=c.startBearing,b=c.startPitch;a=Jb(a,-1,1);var e=this._viewportProps,h=e.minPitch,i=e.maxPitch,d=b;return a>0?d=b+a*(i-b):a<0&&(d=b-a*(h-b)),{pitch:d,bearing:g+180*f}}},{key:"_getRotationParams",value:function(c,d){var h=c[0]-d[0],e=c[1]-d[1],i=c[1],a=d[1],f=this._viewportProps,j=f.width,g=f.height,b=0;return e>0?Math.abs(g-a)>5&&(b=e/(a-g)*1.2):e<0&&a>5&&(b=1-i/a),{deltaScaleX:h/j,deltaScaleY:b=Math.min(1,Math.max(-1,b))}}}]),a}();function Qb(a){return a[0].toLowerCase()+a.slice(1)}function Rb(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function Sb(c){for(var a=1;a1&& void 0!==arguments[1]?arguments[1]:{},b=a.current&&a.current.getMap();return b&&b.queryRenderedFeatures(c,d)}}},[]);var p=(0,c.useCallback)(function(b){var a=b.target;a===o.current&&a.scrollTo(0,0)},[]),q=d&&c.createElement(Tb,{value:Yb(Yb({},b),{},{viewport:b.viewport||$b(Yb({map:d,props:a},m)),map:d,container:b.container||h.current})},c.createElement("div",{key:"map-overlays",className:"overlays",ref:o,style:_b,onScroll:p},a.children)),r=a.className,s=a.width,t=a.height,u=a.style,v=a.visibilityConstraints,w=Object.assign({position:"relative"},u,{width:s,height:t}),x=a.visible&&function(c){var b=arguments.length>1&& void 0!==arguments[1]?arguments[1]:C;for(var a in b){var d=a.slice(0,3),e=Qb(a.slice(3));if("min"===d&&c[e]b[a])return!1}return!0}(a.viewState||a,v),y=Object.assign({},_b,{visibility:x?"inherit":"hidden"});return c.createElement("div",{key:"map-container",ref:h,style:w},c.createElement("div",{key:"map-mapbox",ref:n,style:y,className:r}),q,!l&&!a.disableTokenWarning&&c.createElement(ac,null))});k.supported=function(){return B()&&B().supported()},k.propTypes=U,k.defaultProps=V;var r=k;function bc(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}(this.propNames||[]);try{for(a.s();!(b=a.n()).done;){var c=b.value;if(!Ib(d[c],e[c]))return!1}}catch(f){a.e(f)}finally{a.f()}return!0}},{key:"initializeProps",value:function(a,b){return{start:a,end:b}}},{key:"interpolateProps",value:function(a,b,c){Lb(!1,"interpolateProps is not implemented")}},{key:"getDuration",value:function(b,a){return a.transitionDuration}}]),a}();function cc(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function dc(a,b){return(dc=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a})(a,b)}function ec(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),Object.defineProperty(b,"prototype",{writable:!1}),a&&dc(b,a)}function fc(a){return(fc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function gc(b,a){if(a&&("object"===fc(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return cc(b)}function hc(a){return(hc=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)})(a)}var ic={longitude:1,bearing:1};function jc(a){return Number.isFinite(a)||Array.isArray(a)}function kc(b,c,a){return b in ic&&Math.abs(a-c)>180&&(a=a<0?a+360:a-360),a}function lc(a,c){if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(e=mc(a))||c&&a&&"number"==typeof a.length){e&&(a=e);var d=0,b=function(){};return{s:b,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function mc(a,c){if(a){if("string"==typeof a)return nc(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return nc(a,c)}}function nc(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:b}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var e,f,g=!0,h=!1;return{s:function(){e=a[Symbol.iterator]()},n:function(){var a=e.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==e.return||e.return()}finally{if(h)throw f}}}}function tc(a,c){if(a){if("string"==typeof a)return uc(a,c);var b=Object.prototype.toString.call(a).slice(8,-1);if("Object"===b&&a.constructor&&(b=a.constructor.name),"Map"===b||"Set"===b)return Array.from(a);if("Arguments"===b||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return uc(a,c)}}function uc(c,a){(null==a||a>c.length)&&(a=c.length);for(var b=0,d=new Array(a);b0&& void 0!==arguments[0]?arguments[0]:{};return vb(this,d),g(cc(a=e.call(this)),"propNames",oc),a.props=Object.assign({},rc,b),a}xb(d,[{key:"initializeProps",value:function(h,i){var j,e={},f={},c=lc(pc);try{for(c.s();!(j=c.n()).done;){var a=j.value,g=h[a],k=i[a];Lb(jc(g)&&jc(k),"".concat(a," must be supplied for transition")),e[a]=g,f[a]=kc(a,g,k)}}catch(n){c.e(n)}finally{c.f()}var l,d=lc(qc);try{for(d.s();!(l=d.n()).done;){var b=l.value,m=h[b]||0,o=i[b]||0;e[b]=m,f[b]=kc(b,m,o)}}catch(p){d.e(p)}finally{d.f()}return{start:e,end:f}}},{key:"interpolateProps",value:function(c,d,e){var f,g=function(h,i,j,o={}){var c,d,e;const a={},{startZoom:p,startCenterXY:q,uDelta:r,w0:s,u1:k,S:t,rho:l,rho2:u,r0:b}=bb(h,i,o);if(k<.01){for(const f of _a){const v=h[f],w=i[f];a[f]=Fa(v,w,j)}return a}const m=j*t,x=p+Ha(1/(Math.cosh(b)/Math.cosh(b+l*m))),g=(c=[],d=r,e=s*((Math.cosh(b)*Math.tanh(b+l*m)-Math.sinh(b))/u)/k,c[0]=d[0]*e,c[1]=d[1]*e,c);Ma(g,g,q);const n=Ua(g);return a.longitude=n[0],a.latitude=n[1],a.zoom=x,a}(c,d,e,this.props),a=lc(qc);try{for(a.s();!(f=a.n()).done;){var b=f.value;g[b]=Kb(c[b],d[b],e)}}catch(h){a.e(h)}finally{a.f()}return g}},{key:"getDuration",value:function(c,b){var a=b.transitionDuration;return"auto"===a&&(a=(function(f,g,a={}){a=Object.assign({},ab,a);const{screenSpeed:c,speed:h,maxDuration:d}=a,{S:i,rho:j}=bb(f,g,a),e=1e3*i;let b;return b=Number.isFinite(c)?e/(c/j):e/h,Number.isFinite(d)&&b>d?0:b})(c,b,this.props)),a}}])}(D);var vc=["longitude","latitude","zoom","bearing","pitch"],E=function(b){ec(a,b);var c,d,e=(c=a,d=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=hc(c);if(d){var e=hc(this).constructor;a=Reflect.construct(b,arguments,e)}else a=b.apply(this,arguments);return gc(this,a)});function a(){var c,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};return vb(this,a),c=e.call(this),Array.isArray(b)&&(b={transitionProps:b}),c.propNames=b.transitionProps||vc,b.around&&(c.around=b.around),c}return xb(a,[{key:"initializeProps",value:function(g,c){var d={},e={};if(this.around){d.around=this.around;var h=new $a(g).unproject(this.around);Object.assign(e,c,{around:new $a(c).project(h),aroundLngLat:h})}var i,b=sc(this.propNames);try{for(b.s();!(i=b.n()).done;){var a=i.value,f=g[a],j=c[a];Lb(jc(f)&&jc(j),"".concat(a," must be supplied for transition")),d[a]=f,e[a]=kc(a,f,j)}}catch(k){b.e(k)}finally{b.f()}return{start:d,end:e}}},{key:"interpolateProps",value:function(e,a,f){var g,b={},c=sc(this.propNames);try{for(c.s();!(g=c.n()).done;){var d=g.value;b[d]=Kb(e[d],a[d],f)}}catch(i){c.e(i)}finally{c.f()}if(a.around){var h=Ba(new $a(Object.assign({},a,b)).getMapCenterByLngLatPosition({lngLat:a.aroundLngLat,pos:Kb(e.around,a.around,f)}),2),j=h[0],k=h[1];b.longitude=j,b.latitude=k}return b}}]),a}(D),s=function(){},F={BREAK:1,SNAP_TO_END:2,IGNORE:3,UPDATE:4},W={transitionDuration:0,transitionEasing:function(a){return a},transitionInterpolator:new E(),transitionInterruption:F.BREAK,onTransitionStart:s,onTransitionInterrupt:s,onTransitionEnd:s},G=function(){function a(){var c=this,b=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{};vb(this,a),g(this,"_animationFrame",null),g(this,"_onTransitionFrame",function(){c._animationFrame=requestAnimationFrame(c._onTransitionFrame),c._updateViewport()}),this.props=null,this.onViewportChange=b.onViewportChange||s,this.onStateChange=b.onStateChange||s,this.time=b.getTime||Date.now}return xb(a,[{key:"getViewportInTransition",value:function(){return this._animationFrame?this.state.propsInTransition:null}},{key:"processViewportChange",value:function(c){var a=this.props;if(this.props=c,!a||this._shouldIgnoreViewportChange(a,c))return!1;if(this._isTransitionEnabled(c)){var d=Object.assign({},a),b=Object.assign({},c);if(this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this.state.interruption===F.SNAP_TO_END?Object.assign(d,this.state.endProps):Object.assign(d,this.state.propsInTransition),this.state.interruption===F.UPDATE)){var f,g,h,e=this.time(),i=(e-this.state.startTime)/this.state.duration;b.transitionDuration=this.state.duration-(e-this.state.startTime),h=(f=this.state.easing)(g=i),b.transitionEasing=function(a){return 1/(1-h)*(f(a*(1-g)+g)-h)},b.transitionInterpolator=d.transitionInterpolator}return b.onTransitionStart(),this._triggerTransition(d,b),!0}return this._isTransitionInProgress()&&(a.onTransitionInterrupt(),this._endTransition()),!1}},{key:"_isTransitionInProgress",value:function(){return Boolean(this._animationFrame)}},{key:"_isTransitionEnabled",value:function(a){var b=a.transitionDuration,c=a.transitionInterpolator;return(b>0||"auto"===b)&&Boolean(c)}},{key:"_isUpdateDueToCurrentTransition",value:function(a){return!!this.state.propsInTransition&&this.state.interpolator.arePropsEqual(a,this.state.propsInTransition)}},{key:"_shouldIgnoreViewportChange",value:function(b,a){return!b||(this._isTransitionInProgress()?this.state.interruption===F.IGNORE||this._isUpdateDueToCurrentTransition(a):!this._isTransitionEnabled(a)||a.transitionInterpolator.arePropsEqual(b,a))}},{key:"_triggerTransition",value:function(b,a){Lb(this._isTransitionEnabled(a)),this._animationFrame&&cancelAnimationFrame(this._animationFrame);var c=a.transitionInterpolator,d=c.getDuration?c.getDuration(b,a):a.transitionDuration;if(0!==d){var e=a.transitionInterpolator.initializeProps(b,a),f={inTransition:!0,isZooming:b.zoom!==a.zoom,isPanning:b.longitude!==a.longitude||b.latitude!==a.latitude,isRotating:b.bearing!==a.bearing||b.pitch!==a.pitch};this.state={duration:d,easing:a.transitionEasing,interpolator:a.transitionInterpolator,interruption:a.transitionInterruption,startTime:this.time(),startProps:e.start,endProps:e.end,animation:null,propsInTransition:{}},this._onTransitionFrame(),this.onStateChange(f)}}},{key:"_endTransition",value:function(){this._animationFrame&&(cancelAnimationFrame(this._animationFrame),this._animationFrame=null),this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1})}},{key:"_updateViewport",value:function(){var d=this.time(),a=this.state,e=a.startTime,f=a.duration,g=a.easing,h=a.interpolator,i=a.startProps,j=a.endProps,c=!1,b=(d-e)/f;b>=1&&(b=1,c=!0),b=g(b);var k=h.interpolateProps(i,j,b),l=new Pb(Object.assign({},this.props,k));this.state.propsInTransition=l.getViewportProps(),this.onViewportChange(this.state.propsInTransition,this.props),c&&(this._endTransition(),this.props.onTransitionEnd())}}]),a}();g(G,"defaultProps",W);var X=b(840),l=b.n(X);const wc={mousedown:1,mousemove:2,mouseup:4};!function(a){const b=a.prototype.handler;a.prototype.handler=function(a){const c=this.store;a.button>0&&"pointerdown"===a.type&& !function(b,c){for(let a=0;ab.pointerId===a.pointerId)&&c.push(a),b.call(this,a)}}(l().PointerEventInput),l().MouseInput.prototype.handler=function(a){let b=wc[a.type];1&b&&a.button>=0&&(this.pressed=!0),2&b&&0===a.which&&(b=4),this.pressed&&(4&b&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:"mouse",srcEvent:a}))};const xc=l().Manager;var e=l();const yc=e?[[e.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[e.Rotate,{enable:!1}],[e.Pinch,{enable:!1}],[e.Swipe,{enable:!1}],[e.Pan,{threshold:0,enable:!1}],[e.Press,{enable:!1}],[e.Tap,{event:"doubletap",taps:2,enable:!1}],[e.Tap,{event:"anytap",enable:!1}],[e.Tap,{enable:!1}]]:null,zc={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},Ac={doubletap:["tap"]},Bc={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},t={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},Cc={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},Dc={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},Y="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",H="undefined"!=typeof window?window:b.g;void 0!==b.g&&b.g;let Z=!1;try{const m={get passive(){return Z=!0,!0}};H.addEventListener("test",m,m),H.removeEventListener("test",m,m)}catch(Ec){}const Fc=-1!==Y.indexOf("firefox"),{WHEEL_EVENTS:Gc}=t,Hc="wheel";class Ic{constructor(b,c,a={}){this.element=b,this.callback=c,this.options=Object.assign({enable:!0},a),this.events=Gc.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent,!!Z&&{passive:!1}))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===Hc&&(this.options.enable=b)}handleEvent(b){if(!this.options.enable)return;let a=b.deltaY;H.WheelEvent&&(Fc&&b.deltaMode===H.WheelEvent.DOM_DELTA_PIXEL&&(a/=H.devicePixelRatio),b.deltaMode===H.WheelEvent.DOM_DELTA_LINE&&(a*=40));const c={x:b.clientX,y:b.clientY};0!==a&&a%4.000244140625==0&&(a=Math.floor(a/4.000244140625)),b.shiftKey&&a&&(a*=.25),this._onWheel(b,-a,c)}_onWheel(a,b,c){this.callback({type:Hc,center:c,delta:b,srcEvent:a,pointerType:"mouse",target:a.target})}}const{MOUSE_EVENTS:Jc}=t,Kc="pointermove",Lc="pointerover",Mc="pointerout",Nc="pointerleave";class Oc{constructor(b,c,a={}){this.element=b,this.callback=c,this.pressed=!1,this.options=Object.assign({enable:!0},a),this.enableMoveEvent=this.options.enable,this.enableLeaveEvent=this.options.enable,this.enableOutEvent=this.options.enable,this.enableOverEvent=this.options.enable,this.events=Jc.concat(a.events||[]),this.handleEvent=this.handleEvent.bind(this),this.events.forEach(a=>b.addEventListener(a,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===Kc&&(this.enableMoveEvent=b),a===Lc&&(this.enableOverEvent=b),a===Mc&&(this.enableOutEvent=b),a===Nc&&(this.enableLeaveEvent=b)}handleEvent(a){this.handleOverEvent(a),this.handleOutEvent(a),this.handleLeaveEvent(a),this.handleMoveEvent(a)}handleOverEvent(a){this.enableOverEvent&&"mouseover"===a.type&&this.callback({type:Lc,srcEvent:a,pointerType:"mouse",target:a.target})}handleOutEvent(a){this.enableOutEvent&&"mouseout"===a.type&&this.callback({type:Mc,srcEvent:a,pointerType:"mouse",target:a.target})}handleLeaveEvent(a){this.enableLeaveEvent&&"mouseleave"===a.type&&this.callback({type:Nc,srcEvent:a,pointerType:"mouse",target:a.target})}handleMoveEvent(a){if(this.enableMoveEvent)switch(a.type){case"mousedown":a.button>=0&&(this.pressed=!0);break;case"mousemove":0===a.which&&(this.pressed=!1),this.pressed||this.callback({type:Kc,srcEvent:a,pointerType:"mouse",target:a.target});break;case"mouseup":this.pressed=!1;break;default:}}}const{KEY_EVENTS:Pc}=t,Qc="keydown",Rc="keyup";class Sc{constructor(a,c,b={}){this.element=a,this.callback=c,this.options=Object.assign({enable:!0},b),this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=Pc.concat(b.events||[]),this.handleEvent=this.handleEvent.bind(this),a.tabIndex=b.tabIndex||0,a.style.outline="none",this.events.forEach(b=>a.addEventListener(b,this.handleEvent))}destroy(){this.events.forEach(a=>this.element.removeEventListener(a,this.handleEvent))}enableEventType(a,b){a===Qc&&(this.enableDownEvent=b),a===Rc&&(this.enableUpEvent=b)}handleEvent(a){const b=a.target||a.srcElement;("INPUT"!==b.tagName||"text"!==b.type)&&"TEXTAREA"!==b.tagName&&(this.enableDownEvent&&"keydown"===a.type&&this.callback({type:Qc,srcEvent:a,key:a.key,target:a.target}),this.enableUpEvent&&"keyup"===a.type&&this.callback({type:Rc,srcEvent:a,key:a.key,target:a.target}))}}const Tc="contextmenu";class Uc{constructor(a,b,c={}){this.element=a,this.callback=b,this.options=Object.assign({enable:!0},c),this.handleEvent=this.handleEvent.bind(this),a.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(a,b){a===Tc&&(this.options.enable=b)}handleEvent(a){this.options.enable&&this.callback({type:Tc,center:{x:a.clientX,y:a.clientY},srcEvent:a,pointerType:"mouse",target:a.target})}}const Vc={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},Wc={srcElement:"root",priority:0};class Xc{constructor(a){this.eventManager=a,this.handlers=[],this.handlersByElement=new Map(),this.handleEvent=this.handleEvent.bind(this),this._active=!1}isEmpty(){return!this._active}add(f,g,a,h=!1,i=!1){const{handlers:j,handlersByElement:e}=this;a&&("object"!=typeof a||a.addEventListener)&&(a={srcElement:a}),a=a?Object.assign({},Wc,a):Wc;let b=e.get(a.srcElement);b||(b=[],e.set(a.srcElement,b));const c={type:f,handler:g,srcElement:a.srcElement,priority:a.priority};h&&(c.once=!0),i&&(c.passive=!0),j.push(c),this._active=this._active||!c.passive;let d=b.length-1;for(;d>=0;){if(b[d].priority>=c.priority)break;d--}b.splice(d+1,0,c)}remove(f,g){const{handlers:b,handlersByElement:e}=this;for(let c=b.length-1;c>=0;c--){const a=b[c];if(a.type===f&&a.handler===g){b.splice(c,1);const d=e.get(a.srcElement);d.splice(d.indexOf(a),1),0===d.length&&e.delete(a.srcElement)}}this._active=b.some(a=>!a.passive)}handleEvent(c){if(this.isEmpty())return;const b=this._normalizeEvent(c);let a=c.srcEvent.target;for(;a&&a!==b.rootElement;){if(this._emit(b,a),b.handled)return;a=a.parentNode}this._emit(b,"root")}_emit(e,f){const a=this.handlersByElement.get(f);if(a){let g=!1;const h=()=>{e.handled=!0},i=()=>{e.handled=!0,g=!0},c=[];for(let b=0;b{const b=this.manager.get(a);b&&zc[a].forEach(a=>{b.recognizeWith(a)})}),b.recognizerOptions){const e=this.manager.get(d);if(e){const f=b.recognizerOptions[d];delete f.enable,e.set(f)}}for(const[h,c]of(this.wheelInput=new Ic(a,this._onOtherEvent,{enable:!1}),this.moveInput=new Oc(a,this._onOtherEvent,{enable:!1}),this.keyInput=new Sc(a,this._onOtherEvent,{enable:!1,tabIndex:b.tabIndex}),this.contextmenuInput=new Uc(a,this._onOtherEvent,{enable:!1}),this.events))c.isEmpty()||(this._toggleRecognizer(c.recognizerName,!0),this.manager.on(h,c.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(a,b,c){this._addEventHandler(a,b,c,!1)}once(a,b,c){this._addEventHandler(a,b,c,!0)}watch(a,b,c){this._addEventHandler(a,b,c,!1,!0)}off(a,b){this._removeEventHandler(a,b)}_toggleRecognizer(a,b){const{manager:d}=this;if(!d)return;const c=d.get(a);if(c&&c.options.enable!==b){c.set({enable:b});const e=Ac[a];e&&!this.options.recognizers&&e.forEach(e=>{const f=d.get(e);b?(f.requireFailure(a),c.dropRequireFailure(e)):f.dropRequireFailure(a)})}this.wheelInput.enableEventType(a,b),this.moveInput.enableEventType(a,b),this.keyInput.enableEventType(a,b),this.contextmenuInput.enableEventType(a,b)}_addEventHandler(b,e,d,f,g){if("string"!=typeof b){for(const h in d=e,b)this._addEventHandler(h,b[h],d,f,g);return}const{manager:i,events:j}=this,c=Dc[b]||b;let a=j.get(c);!a&&(a=new Xc(this),j.set(c,a),a.recognizerName=Cc[c]||c,i&&i.on(c,a.handleEvent)),a.add(b,e,d,f,g),a.isEmpty()||this._toggleRecognizer(a.recognizerName,!0)}_removeEventHandler(a,h){if("string"!=typeof a){for(const c in a)this._removeEventHandler(c,a[c]);return}const{events:d}=this,i=Dc[a]||a,b=d.get(i);if(b&&(b.remove(a,h),b.isEmpty())){const{recognizerName:e}=b;let f=!1;for(const g of d.values())if(g.recognizerName===e&&!g.isEmpty()){f=!0;break}f||this._toggleRecognizer(e,!1)}}_onBasicInput(a){const{srcEvent:c}=a,b=Bc[c.type];b&&this.manager.emit(b,a)}_onOtherEvent(a){this.manager.emit(a.type,a)}}function Zc(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}function $c(c){for(var a=1;a0),e=d&&!this.state.isHovering,h=!d&&this.state.isHovering;(c||e)&&(a.features=b,c&&c(a)),e&&hd.call(this,"onMouseEnter",a),h&&hd.call(this,"onMouseLeave",a),(e||h)&&this.setState({isHovering:d})}}function ld(b){var c=this.props,d=c.onClick,f=c.onNativeClick,g=c.onDblClick,h=c.doubleClickZoom,a=[],e=g||h;switch(b.type){case"anyclick":a.push(f),e||a.push(d);break;case"click":e&&a.push(d);break;default:}(a=a.filter(Boolean)).length&&((b=fd.call(this,b)).features=gd.call(this,b.point),a.forEach(function(a){return a(b)}))}var n=(0,c.forwardRef)(function(b,h){var i,t,f=(0,c.useContext)(Ub),u=(0,c.useMemo)(function(){return b.controller||new $()},[]),v=(0,c.useMemo)(function(){return new Yc(null,{touchAction:b.touchAction,recognizerOptions:b.eventRecognizerOptions})},[]),g=(0,c.useRef)(null),e=(0,c.useRef)(null),a=(0,c.useRef)({width:0,height:0,state:{isHovering:!1,isDragging:!1}}).current;a.props=b,a.map=e.current&&e.current.getMap(),a.setState=function(c){a.state=ed(ed({},a.state),c),g.current.style.cursor=b.getCursor(a.state)};var j=!0,k=function(b,c,d){if(j){i=[b,c,d];return}var e=a.props,f=e.onViewStateChange,g=e.onViewportChange;Object.defineProperty(b,"position",{get:function(){return[0,0,Wb(a.map,b)]}}),f&&f({viewState:b,interactionState:c,oldViewState:d}),g&&g(b,c,d)};(0,c.useImperativeHandle)(h,function(){var a;return{getMap:(a=e).current&&a.current.getMap,queryRenderedFeatures:a.current&&a.current.queryRenderedFeatures}},[]);var d=(0,c.useMemo)(function(){return ed(ed({},f),{},{eventManager:v,container:f.container||g.current})},[f,g.current]);d.onViewportChange=k,d.viewport=f.viewport||$b(a),a.viewport=d.viewport;var w=function(b){var c=b.isDragging,d=void 0!==c&&c;if(d!==a.state.isDragging&&a.setState({isDragging:d}),j){t=b;return}var e=a.props.onInteractionStateChange;e&&e(b)},l=function(){a.width&&a.height&&u.setOptions(ed(ed(ed({},a.props),a.props.viewState),{},{isInteractive:Boolean(a.props.onViewStateChange||a.props.onViewportChange),onViewportChange:k,onStateChange:w,eventManager:v,width:a.width,height:a.height}))},m=function(b){var c=b.width,d=b.height;a.width=c,a.height=d,l(),a.props.onResize({width:c,height:d})};(0,c.useEffect)(function(){return v.setElement(g.current),v.on({pointerdown:id.bind(a),pointermove:kd.bind(a),pointerup:jd.bind(a),pointerleave:hd.bind(a,"onMouseOut"),click:ld.bind(a),anyclick:ld.bind(a),dblclick:hd.bind(a,"onDblClick"),wheel:hd.bind(a,"onWheel"),contextmenu:hd.bind(a,"onContextMenu")}),function(){v.destroy()}},[]),Vb(function(){if(i){var a;k.apply(void 0,function(a){if(Array.isArray(a))return ya(a)}(a=i)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||za(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}t&&w(t)}),l();var n=b.width,o=b.height,p=b.style,q=b.getCursor,s=(0,c.useMemo)(function(){return ed(ed({position:"relative"},p),{},{width:n,height:o,cursor:q(a.state)})},[p,n,o,q,a.state]);return i&&a._child||(a._child=c.createElement(Tb,{value:d},c.createElement("div",{key:"event-canvas",ref:g,style:s},c.createElement(r,xa({},b,{width:"100%",height:"100%",style:null,onResize:m,ref:e}))))),j=!1,a._child});n.supported=r.supported,n.propTypes=_,n.defaultProps=aa;var md=n;function nd(b,a){if(b===a)return!0;if(!b||!a)return!1;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!==a.length)return!1;for(var c=0;c prop: ".concat(e))}})(d,a,f.current):d=(function(a,c,d){if(a.style&&a.style._loaded){var b=function(c){for(var a=1;a=0||(d[a]=c[a]);return d}(a,d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(a,b)&&(e[b]=a[b])}return e}(d,["layout","paint","filter","minzoom","maxzoom","beforeId"]);if(p!==a.beforeId&&b.moveLayer(c,p),e!==a.layout){var q=a.layout||{};for(var g in e)nd(e[g],q[g])||b.setLayoutProperty(c,g,e[g]);for(var r in q)e.hasOwnProperty(r)||b.setLayoutProperty(c,r,void 0)}if(f!==a.paint){var s=a.paint||{};for(var h in f)nd(f[h],s[h])||b.setPaintProperty(c,h,f[h]);for(var t in s)f.hasOwnProperty(t)||b.setPaintProperty(c,t,void 0)}for(var i in nd(m,a.filter)||b.setFilter(c,m),(n!==a.minzoom||o!==a.maxzoom)&&b.setLayerZoomRange(c,n,o),j)nd(j[i],a[i])||b.setLayerProperty(c,i,j[i])}(c,d,a,b)}catch(e){console.warn(e)}})(a,d,b,e.current):(function(a,d,b){if(a.style&&a.style._loaded){var c=rd(rd({},b),{},{id:d});delete c.beforeId,a.addLayer(c,b.beforeId)}})(a,d,b),e.current=b,null}).propTypes=ca;var f={captureScroll:!1,captureDrag:!0,captureClick:!0,captureDoubleClick:!0,capturePointerMove:!1},d={captureScroll:a.bool,captureDrag:a.bool,captureClick:a.bool,captureDoubleClick:a.bool,capturePointerMove:a.bool};function td(){var d=arguments.length>0&& void 0!==arguments[0]?arguments[0]:{},a=(0,c.useContext)(Ub),e=(0,c.useRef)(null),f=(0,c.useRef)({props:d,state:{},context:a,containerRef:e}),b=f.current;return b.props=d,b.context=a,(0,c.useEffect)(function(){return(function(a){var b=a.containerRef.current,c=a.context.eventManager;if(b&&c){var d={wheel:function(c){var b=a.props;b.captureScroll&&c.stopPropagation(),b.onScroll&&b.onScroll(c,a)},panstart:function(c){var b=a.props;b.captureDrag&&c.stopPropagation(),b.onDragStart&&b.onDragStart(c,a)},anyclick:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onNativeClick&&b.onNativeClick(c,a)},click:function(c){var b=a.props;b.captureClick&&c.stopPropagation(),b.onClick&&b.onClick(c,a)},dblclick:function(c){var b=a.props;b.captureDoubleClick&&c.stopPropagation(),b.onDoubleClick&&b.onDoubleClick(c,a)},pointermove:function(c){var b=a.props;b.capturePointerMove&&c.stopPropagation(),b.onPointerMove&&b.onPointerMove(c,a)}};return c.watch(d,b),function(){c.off(d)}}})(b)},[a.eventManager]),b}function ud(b){var a=b.instance,c=td(b),d=c.context,e=c.containerRef;return a._context=d,a._containerRef=e,a._render()}var I=function(b){ec(a,b);var d,e,f=(d=a,e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}(),function(){var a,b=hc(d);if(e){var c=hc(this).constructor;a=Reflect.construct(b,arguments,c)}else a=b.apply(this,arguments);return gc(this,a)});function a(){var b;vb(this,a);for(var e=arguments.length,h=new Array(e),d=0;d2&& void 0!==arguments[2]?arguments[2]:"x";if(null===a)return b;var c="x"===d?a.offsetWidth:a.offsetHeight;return Bd(b/100*c)/c*100};function Dd(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}var fa=Object.assign({},da,{className:a.string,longitude:a.number.isRequired,latitude:a.number.isRequired,style:a.object}),ga=Object.assign({},ea,{className:""});function u(b){var d,j,e,k,f,l,m,a,h=(d=b,e=(j=Ba((0,c.useState)(null),2))[0],k=j[1],f=Ba((0,c.useState)(null),2),l=f[0],m=f[1],a=td(wd(wd({},d),{},{onDragStart:zd})),a.callbacks=d,a.state.dragPos=e,a.state.setDragPos=k,a.state.dragOffset=l,a.state.setDragOffset=m,(0,c.useEffect)(function(){return(function(a){var b=a.context.eventManager;if(b&&a.state.dragPos){var c={panmove:function(b){return(function(b,a){var h=a.props,c=a.callbacks,d=a.state,i=a.context;b.stopPropagation();var e=xd(b);d.setDragPos(e);var f=d.dragOffset;if(c.onDrag&&f){var g=Object.assign({},b);g.lngLat=yd(e,f,h,i),c.onDrag(g)}})(b,a)},panend:function(b){return(function(c,a){var h=a.props,d=a.callbacks,b=a.state,i=a.context;c.stopPropagation();var e=b.dragPos,f=b.dragOffset;if(b.setDragPos(null),b.setDragOffset(null),d.onDragEnd&&e&&f){var g=Object.assign({},c);g.lngLat=yd(e,f,h,i),d.onDragEnd(g)}})(b,a)},pancancel:function(d){var c,b;return c=d,b=a.state,void(c.stopPropagation(),b.setDragPos(null),b.setDragOffset(null))}};return b.watch(c),function(){b.off(c)}}})(a)},[a.context.eventManager,Boolean(e)]),a),o=h.state,p=h.containerRef,q=b.children,r=b.className,s=b.draggable,A=b.style,t=o.dragPos,u=function(b){var a=b.props,e=b.state,f=b.context,g=a.longitude,h=a.latitude,j=a.offsetLeft,k=a.offsetTop,c=e.dragPos,d=e.dragOffset,l=f.viewport,m=f.map;if(c&&d)return[c[0]+d[0],c[1]+d[1]];var n=Wb(m,{longitude:g,latitude:h}),i=Ba(l.project([g,h,n]),2),o=i[0],p=i[1];return[o+=j,p+=k]}(h),n=Ba(u,2),v=n[0],w=n[1],x="translate(".concat(Bd(v),"px, ").concat(Bd(w),"px)"),y=s?t?"grabbing":"grab":"auto",z=(0,c.useMemo)(function(){var a=function(c){for(var a=1;a0){var t=b,u=e;for(b=0;b<=1;b+=.5)k=(i=n-b*h)+h,e=Math.max(0,d-i)+Math.max(0,k-p+d),e0){var w=a,x=f;for(a=0;a<=1;a+=v)l=(j=m-a*g)+g,f=Math.max(0,d-j)+Math.max(0,l-o+d),f1||h< -1||f<0||f>p.width||g<0||g>p.height?i.display="none":i.zIndex=Math.floor((1-h)/2*1e5)),i),S=(0,c.useCallback)(function(b){t.props.onClose();var a=t.context.eventManager;a&&a.once("click",function(a){return a.stopPropagation()},b.target)},[]);return c.createElement("div",{className:"mapboxgl-popup mapboxgl-popup-anchor-".concat(L," ").concat(N),style:R,ref:u},c.createElement("div",{key:"tip",className:"mapboxgl-popup-tip",style:{borderWidth:O}}),c.createElement("div",{key:"content",ref:j,className:"mapboxgl-popup-content"},P&&c.createElement("button",{key:"close-button",className:"mapboxgl-popup-close-button",type:"button",onClick:S},"\xd7"),Q))}function Fd(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}v.propTypes=ha,v.defaultProps=ia,c.memo(v);var ja=Object.assign({},d,{toggleLabel:a.string,className:a.string,style:a.object,compact:a.bool,customAttribution:a.oneOfType([a.string,a.arrayOf(a.string)])}),ka=Object.assign({},f,{className:"",toggleLabel:"Toggle Attribution"});function w(a){var b=td(a),d=b.context,i=b.containerRef,j=(0,c.useRef)(null),e=Ba((0,c.useState)(!1),2),f=e[0],m=e[1];(0,c.useEffect)(function(){var h,e,c,f,g,b;return d.map&&(h=(e={customAttribution:a.customAttribution},c=d.map,f=i.current,g=j.current,(b=new(B()).AttributionControl(e))._map=c,b._container=f,b._innerContainer=g,b._updateAttributions(),b._updateEditLink(),c.on("styledata",b._updateData),c.on("sourcedata",b._updateData),b)),function(){var a;return h&&void((a=h)._map.off("styledata",a._updateData),a._map.off("sourcedata",a._updateData))}},[d.map]);var h=void 0===a.compact?d.viewport.width<=640:a.compact;(0,c.useEffect)(function(){!h&&f&&m(!1)},[h]);var k=(0,c.useCallback)(function(){return m(function(a){return!a})},[]),l=(0,c.useMemo)(function(){return(function(c){for(var a=1;ac)return 1}return 0})(b.map.version,"1.6.0")>=0?2:1:2},[b.map]),f=b.viewport.bearing,d={transform:"rotate(".concat(-f,"deg)")},2===e?c.createElement("span",{className:"mapboxgl-ctrl-icon","aria-hidden":"true",style:d}):c.createElement("span",{className:"mapboxgl-ctrl-compass-arrow",style:d})))))}function Nd(c,d){var a=Object.keys(c);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(c);d&&(b=b.filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable})),a.push.apply(a,b)}return a}z.propTypes=pa,z.defaultProps=qa,c.memo(z);var ra=Object.assign({},d,{className:a.string,style:a.object,maxWidth:a.number,unit:a.oneOf(["imperial","metric","nautical"])}),sa=Object.assign({},f,{className:"",maxWidth:100,unit:"metric"});function A(a){var d=td(a),f=d.context,h=d.containerRef,e=Ba((0,c.useState)(null),2),b=e[0],j=e[1];(0,c.useEffect)(function(){if(f.map){var a=new(B()).ScaleControl();a._map=f.map,a._container=h.current,j(a)}},[f.map]),b&&(b.options=a,b._onMove());var i=(0,c.useMemo)(function(){return(function(c){for(var a=1;aisAbsent(a)||""===a&&d|| -1!==a.search(b)})}}(function(){return new a()}).prototype=a.prototype +class a extends BaseSchema{matches(d,a){let e=!1,b,c;return a&&("object"==typeof a?{excludeEmptyString:e=!1,message:b,name:c}=a:b=a),this.test({name:c||"matches",message:b||string.matches,params:{regex:d},test:a=>isAbsent(a)||""===a&&e|| -1!==a.search(d)})}}(function(){return new a()}).prototype=a.prototype diff --git a/crates/swc_ecma_minifier/tests/full/next-33088/output.js b/crates/swc_ecma_minifier/tests/full/next-33088/output.js index 37bc728754d..6e6b1c5944d 100644 --- a/crates/swc_ecma_minifier/tests/full/next-33088/output.js +++ b/crates/swc_ecma_minifier/tests/full/next-33088/output.js @@ -1,10 +1,10 @@ -import*as a from"react";export default function b(){const[b,c]=a.useState({hits:[]}),[d,e]=a.useState("react");return a.useEffect(()=>{""!==d&&a();async function a(){const a=await fetch("https://hn.algolia.com/api/v1/search?query="+d),b=await a.json();c(b)}},[d]),<> +import*as a from"react";export default function b(){const[c,d]=a.useState({hits:[]}),[b,e]=a.useState("react");return a.useEffect(()=>{""!==b&&a();async function a(){const a=await fetch("https://hn.algolia.com/api/v1/search?query="+b),c=await a.json();d(c)}},[b]),<> - e(a.target.value)}/> + e(a.target.value)}/>
    - {b.hits.map(a=>
  • + {c.hits.map(a=>
  • {a.title} diff --git a/crates/swc_ecma_minifier/tests/full/vercel/ms/1/output.js b/crates/swc_ecma_minifier/tests/full/vercel/ms/1/output.js index db79635e619..ebaab060983 100644 --- a/crates/swc_ecma_minifier/tests/full/vercel/ms/1/output.js +++ b/crates/swc_ecma_minifier/tests/full/vercel/ms/1/output.js @@ -1 +1 @@ -export default function(c,e){try{if("string"==typeof c&&c.length>0)return(function(a){if((a=String(a)).length>100)throw new Error("Value exceeds the maximum length of 100 characters.");const b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a);if(!b)return NaN;const c=parseFloat(b[1]),d=(b[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*c;case"weeks":case"week":case"w":return 6048e5*c;case"days":case"day":case"d":return 864e5*c;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*c;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*c;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:throw new Error(`The unit ${d} was matched, but no matching case exists.`)}})(c);if("number"==typeof c&&isFinite(c))return e?.long?b(c):a(c);throw new Error("Value is not a string or number.")}catch(f){const g=d(f)?`${f.message}. value=${JSON.stringify(c)}`:"An unknown error has occured.";throw new Error(g)}};function a(a){const b=Math.abs(a);return b>=864e5?`${Math.round(a/864e5)}d`:b>=36e5?`${Math.round(a/36e5)}h`:b>=6e4?`${Math.round(a/6e4)}m`:b>=1e3?`${Math.round(a/1e3)}s`:`${a}ms`}function b(a){const b=Math.abs(a);return b>=864e5?c(a,b,864e5,"day"):b>=36e5?c(a,b,36e5,"hour"):b>=6e4?c(a,b,6e4,"minute"):b>=1e3?c(a,b,1e3,"second"):`${a} ms`}function c(a,b,c,d){return`${Math.round(a/c)} ${d}${b>=1.5*c?"s":""}`}function d(a){return"object"==typeof a&&null!==a&&"message"in a} +export default function(c,f){try{if("string"==typeof c&&c.length>0)return(function(b){if((b=String(b)).length>100)throw new Error("Value exceeds the maximum length of 100 characters.");const c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(b);if(!c)return NaN;const a=parseFloat(c[1]),d=(c[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return 864e5*a;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*a;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*a;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:throw new Error(`The unit ${d} was matched, but no matching case exists.`)}})(c);if("number"==typeof c&&isFinite(c))return f?.long?b(c):a(c);throw new Error("Value is not a string or number.")}catch(e){const g=d(e)?`${e.message}. value=${JSON.stringify(c)}`:"An unknown error has occured.";throw new Error(g)}};function a(a){const b=Math.abs(a);return b>=864e5?`${Math.round(a/864e5)}d`:b>=36e5?`${Math.round(a/36e5)}h`:b>=6e4?`${Math.round(a/6e4)}m`:b>=1e3?`${Math.round(a/1e3)}s`:`${a}ms`}function b(b){const a=Math.abs(b);return a>=864e5?c(b,a,864e5,"day"):a>=36e5?c(b,a,36e5,"hour"):a>=6e4?c(b,a,6e4,"minute"):a>=1e3?c(b,a,1e3,"second"):`${b} ms`}function c(b,c,a,d){return`${Math.round(b/a)} ${d}${c>=1.5*a?"s":""}`}function d(a){return"object"==typeof a&&null!==a&&"message"in a} diff --git a/crates/swc_ecma_minifier/tests/mangle/1/output.js b/crates/swc_ecma_minifier/tests/mangle/1/output.js index 7c4f3d323d6..840c9af3de0 100644 --- a/crates/swc_ecma_minifier/tests/mangle/1/output.js +++ b/crates/swc_ecma_minifier/tests/mangle/1/output.js @@ -7,18 +7,18 @@ var a = (this && this.__importDefault) || function(a) { Object.defineProperty(exports, "__esModule", { value: true }); -const b = a(require("./config.json")); -function c({ config: a = b.default } = {}) { - function c(b) { - const c = a[b] || null; - if (!c) { +const c = a(require("./config.json")); +function b({ config: a = c.default } = {}) { + function b(e) { + const b = a[e] || null; + if (!b) { return false; } - const { available: d , availableBy: e } = c; - if (!e) { - return d; + const { available: c , availableBy: d } = b; + if (!d) { + return c; } - return Date.now() >= e && d; + return Date.now() >= d && c; } function d(b) { const c = a[b] || null; @@ -26,8 +26,8 @@ function c({ config: a = b.default } = {}) { } return { longlong10: d, - longlong2: c, + longlong2: b, longlong100: a }; } -exports.default = c; +exports.default = b; diff --git a/crates/swc_ecma_minifier/tests/mangle/2/output.js b/crates/swc_ecma_minifier/tests/mangle/2/output.js index babc6b833e7..21e7122f413 100644 --- a/crates/swc_ecma_minifier/tests/mangle/2/output.js +++ b/crates/swc_ecma_minifier/tests/mangle/2/output.js @@ -1,4 +1,4 @@ -const a = 1234123; -var b = mn.dateTime, c = mn.date, d = mn.time, e = mn.periods, f = mn.days, g = mn.shortDays, h = mn.months, i = mn.shortMonths, j = $i(e), k = aj(e), l = $i(f), m = aj(f), n = $i(g), o = aj(g), p = $i(h), q = aj(h), r = $i(i), s = aj(i), t = { - a: a +const f = 1234123; +var g = mn.dateTime, h = mn.date, i = mn.time, a = mn.periods, b = mn.days, c = mn.shortDays, d = mn.months, e = mn.shortMonths, j = $i(a), k = aj(a), l = $i(b), m = aj(b), n = $i(c), o = aj(c), p = $i(d), q = aj(d), r = $i(e), s = aj(e), t = { + a: f }; diff --git a/crates/swc_ecma_minifier/tests/mangle/reuse/1/output.js b/crates/swc_ecma_minifier/tests/mangle/reuse/1/output.js index ee97d65aa66..9261cc936ea 100644 --- a/crates/swc_ecma_minifier/tests/mangle/reuse/1/output.js +++ b/crates/swc_ecma_minifier/tests/mangle/reuse/1/output.js @@ -1,7 +1,7 @@ "use strict"; -const a = (a, b)=>{ - return b; +const a = (b, a)=>{ + return a; }; -const b = (a, b, c)=>{ - return c; +const b = (b, c, a)=>{ + return a; }; diff --git a/crates/swc_ecma_minifier/tests/mangle/reuse/2/output.js b/crates/swc_ecma_minifier/tests/mangle/reuse/2/output.js index f92e96fb53f..cf4623124d5 100644 --- a/crates/swc_ecma_minifier/tests/mangle/reuse/2/output.js +++ b/crates/swc_ecma_minifier/tests/mangle/reuse/2/output.js @@ -1,84 +1,84 @@ -function a(a, b = {}, c = false) { +function g(a, b = {}, c = false) { return { rule: a, params: b, implicit: c }; } -function b(b) { - if (typeof b === "undefined") { - return a("nullable", { - value: b +function h(a) { + if (typeof a === "undefined") { + return g("nullable", { + value: a }, true); } } -function c(a) { - return a.find((a)=>a === b +function i(a) { + return a.find((a)=>a === h ) ? true : false; } -function d(a) { +function j(a) { return a === undefined || a === null || a === ""; } -function e(b) { - return d(b) ? a("required", { - value: b +function a(a) { + return j(a) ? g("required", { + value: a }, true) : undefined; } -function f(a) { - return a.find((a)=>a === e +function k(b) { + return b.find((b)=>b === a ) ? false : true; } -const g = (a, b, c, d)=>{ - b.attr = c; +const l = (a, b, d, e)=>{ + b.attr = d; if (typeof a === "function") { - return a(b, d || ""); + return a(b, e || ""); } else { - for(let e in b){ - a = a.replace(`:${e}`, b[e]); + for(let c in b){ + a = a.replace(`:${c}`, b[c]); } return a; } }; -const h = (a)=>{ - const b = a.split(":"); - b.shift(); - return b.join(":"); +const m = (b)=>{ + const a = b.split(":"); + a.shift(); + return a.join(":"); }; -const i = (a, b, c, d, e)=>{ +const n = (a, b, c, d, e)=>{ return a[`${b}.${c}`] || a[`${b}.${d}`] || a[b] || a[c] || a[d] || e; }; -const j = (a, { messages: b , attributes: c })=>{ - const d = {}; - const e = (b || {})["default"] || ":attr is invalid"; - for(let f in a){ - const k = a[f]; - const l = (c || {})[f] || f; - d[f] = {}; - for (let m of k){ - const n = h(m.rule); - const o = n ? m.rule.substr(0, m.rule.length - n.length - 1) : m.rule; - if (m.rule === "validateObject" && m.params.errors) { - d[f][o] = j(m.params.errors, { - messages: b, - attributes: c +const o = (h, { messages: d , attributes: f })=>{ + const c = {}; + const i = (d || {})["default"] || ":attr is invalid"; + for(let b in h){ + const j = h[b]; + const k = (f || {})[b] || b; + c[b] = {}; + for (let a of j){ + const g = m(a.rule); + const e = g ? a.rule.substr(0, a.rule.length - g.length - 1) : a.rule; + if (a.rule === "validateObject" && a.params.errors) { + c[b][e] = o(a.params.errors, { + messages: d, + attributes: f }); - } else if (m.rule === "validateArray" && m.params.errors) { - d[f][o] = j(m.params.errors, { - messages: b, - attributes: c + } else if (a.rule === "validateArray" && a.params.errors) { + c[b][e] = o(a.params.errors, { + messages: d, + attributes: f }); } else { - const p = i(b || {}, f, m.rule, o, e); - d[f][o] = g(p, m.params, l, n); + const p = n(d || {}, b, a.rule, e, i); + c[b][e] = l(p, a.params, k, g); } } } - return d; + return c; }; -const k = (a)=>{ +const p = (a)=>{ return a.match(/^\d+$/) ? true : false; }; -const l = (a, b)=>{ +const q = (a, b)=>{ if (typeof a[b] !== "undefined") { return a[b]; } @@ -86,7 +86,7 @@ const l = (a, b)=>{ const d = c.reduce((a, b)=>{ if (a && typeof a === "object") { return a[b]; - } else if (a instanceof Array && k(b)) { + } else if (a instanceof Array && p(b)) { const c = parseInt(b); return a[c]; } @@ -95,18 +95,18 @@ const l = (a, b)=>{ }); return d; }; -const m = (a, b)=>{ - const c = l(a, b); +const r = (a, b)=>{ + const c = q(a, b); return typeof c !== "undefined"; }; -const n = (a)=>{ +const s = (a)=>{ return { - getValue: (b)=>l(a, b) + getValue: (b)=>q(a, b) , - hasValue: (b)=>m(a, b) + hasValue: (b)=>r(a, b) }; }; -const o = { +const t = { "fileExists:pathCheck": "file :value doesn't exists", "fileExists:stringCheck": "file path must be a string", isArray: ":attr must be an array", @@ -130,103 +130,103 @@ const o = { required: ":attr is required", default: ":attr is invalid" }; -const p = (a, b)=>{ +const u = (a, b)=>{ return a[b]; }; -const q = new Set([ +const v = new Set([ "requiredWhenRule", "requiredIfRule", "requiredUnlessRule", ]); -const r = async (a, b, e)=>{ - const g = []; - if (d(a) && f(b)) { - const h = b.filter((a)=>q.has(a.name) +const w = async (d, b, f)=>{ + const e = []; + if (j(d) && k(b)) { + const g = b.filter((a)=>v.has(a.name) ); - if (h.length === 0) { + if (g.length === 0) { return []; } - for (let i of b.filter((a)=>q.has(a.name) + for (let h of b.filter((a)=>v.has(a.name) )){ - let j = i(a, e); - if (j instanceof Promise) { - j = await j; + let a = h(d, f); + if (a instanceof Promise) { + a = await a; } - if (j !== undefined && j.noContext) { + if (a !== undefined && a.noContext) { return []; } - if (j !== undefined) { - g.push(j); - if (j.implicit) { - return g; + if (a !== undefined) { + e.push(a); + if (a.implicit) { + return e; } } } - b = b.filter((a)=>!q.has(a.name) + b = b.filter((a)=>!v.has(a.name) ); } - if (typeof a === "object" && a === null && c(b)) { + if (typeof d === "object" && d === null && i(b)) { return []; } - for (let k of b){ - let l = k(a, e); - if (l instanceof Promise) { - l = await l; + for (let l of b){ + let c = l(d, f); + if (c instanceof Promise) { + c = await c; } - if (l !== undefined && !l.noContext) { - g.push(l); - if (l.implicit === true) { + if (c !== undefined && !c.noContext) { + e.push(c); + if (c.implicit === true) { break; } } } - return g; + return e; }; -const s = async (a, b)=>{ - const c = {}; - const d = n(a); - for(let e in b){ - const f = b[e] instanceof Array ? b[e] : [ - b[e] +const x = async (c, b)=>{ + const d = {}; + const f = s(c); + for(let a in b){ + const g = b[a] instanceof Array ? b[a] : [ + b[a] ]; - const g = p(a, e); - const h = await r(g, f, d); - if (h.length) { - c[e] = h; + const h = u(c, a); + const e = await w(h, g, f); + if (e.length) { + d[a] = e; } } - return c; + return d; }; -const t = async (a, b, c = { - messages: o +const b = async (c, d, e = { + messages: t })=>{ - const d = await s(a, b); - const e = Object.keys(d).length === 0; - const f = e ? {} : j(d, c); + const a = await x(c, d); + const b = Object.keys(a).length === 0; + const f = b ? {} : o(a, e); return [ - e, + b, f ]; }; -function u(b) { - if (typeof b !== "number") { - return a("isNumber", { - value: b +function c(a) { + if (typeof a !== "number") { + return g("isNumber", { + value: a }); } } -const v = { +const d = { name: "", age: "20" }; -const [w, x] = await t(v, { - name: e, +const [e, f] = await b(d, { + name: a, age: [ - e, - u + a, + c ] }); console.log({ - passes: w, - errors: x + passes: e, + errors: f }); diff --git a/crates/swc_ecma_minifier/tests/mangle/reuse/3/output.js b/crates/swc_ecma_minifier/tests/mangle/reuse/3/output.js index 86bd7229508..cd8145a8492 100644 --- a/crates/swc_ecma_minifier/tests/mangle/reuse/3/output.js +++ b/crates/swc_ecma_minifier/tests/mangle/reuse/3/output.js @@ -1,52 +1,52 @@ -const a = new TextEncoder(); -function b(b) { - return a.encode(b); +const k = new TextEncoder(); +function l(a) { + return k.encode(a); } new TextDecoder(); -const c = globalThis.Deno?.noColor ?? true; -let d = !c; -function e(a, b) { +const f = globalThis.Deno?.noColor ?? true; +let m = !f; +function n(b, a) { return { - open: `\x1b[${a.join(";")}m`, - close: `\x1b[${b}m`, - regexp: new RegExp(`\\x1b\\[${b}m`, "g") + open: `\x1b[${b.join(";")}m`, + close: `\x1b[${a}m`, + regexp: new RegExp(`\\x1b\\[${a}m`, "g") }; } -function f(a, b) { - return d ? `${b.open}${a.replace(b.regexp, b.open)}${b.close}` : a; +function o(b, a) { + return m ? `${a.open}${b.replace(a.regexp, a.open)}${a.close}` : b; } -function g(a) { - return f(a, e([ +function p(a) { + return o(a, n([ 1 ], 22)); } -function h(a) { - return f(a, e([ +function q(a) { + return o(a, n([ 2 ], 22)); } -function i(a) { - return f(a, e([ +function r(a) { + return o(a, n([ 31 ], 39)); } -function j(a) { - return f(a, e([ +function s(a) { + return o(a, n([ 32 ], 39)); } -function k(a) { - return f(a, e([ +function t(a) { + return o(a, n([ 33 ], 39)); } -function l(a) { - return f(a, e([ +function u(a) { + return o(a, n([ 34 ], 39)); } -function m(a) { - return f(a, e([ +function v(a) { + return o(a, n([ 35 ], 39)); } @@ -54,10 +54,10 @@ new RegExp([ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", ].join("|"), "g"); -const n = /([a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0561-\u0587\u13F8-\u13FD\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7B5\uA7B7\uA7FA\uAB30-\uAB5A\uAB60-\uAB65\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19])([A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AD\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A])/g; -const o = /([A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AD\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A])([A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AD\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A][a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0561-\u0587\u13F8-\u13FD\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7B5\uA7B7\uA7FA\uAB30-\uAB5A\uAB60-\uAB65\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A])/g; -const p = /[^A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]+/g; -const q = { +const w = /([a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0561-\u0587\u13F8-\u13FD\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7B5\uA7B7\uA7FA\uAB30-\uAB5A\uAB60-\uAB65\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19])([A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AD\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A])/g; +const x = /([A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AD\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A])([A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178\u0179\u017B\u017D\u0181\u0182\u0184\u0186\u0187\u0189-\u018B\u018E-\u0191\u0193\u0194\u0196-\u0198\u019C\u019D\u019F\u01A0\u01A2\u01A4\u01A6\u01A7\u01A9\u01AC\u01AE\u01AF\u01B1-\u01B3\u01B5\u01B7\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A\u023B\u023D\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AD\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A][a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0561-\u0587\u13F8-\u13FD\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7B5\uA7B7\uA7FA\uAB30-\uAB5A\uAB60-\uAB65\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A])/g; +const y = /[^A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D66-\u0D75\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]+/g; +const z = { tr: { regexp: /\u0130|\u0049|\u0049\u0307/g, map: { @@ -84,8 +84,8 @@ const q = { } } }; -function r(a, b) { - const c = b && q[b]; +function A(a, b) { + const c = b && z[b]; a = a == null ? '' : String(a); if (c) { a = a.replace(c.regexp, (a)=>c.map[a] @@ -93,21 +93,21 @@ function r(a, b) { } return a.toLowerCase(); } -function s(a, b, c) { +function B(a, c, b) { if (a == null) { return ''; } - c = typeof c !== 'string' ? ' ' : c; - function d(a, b, d) { - if (b === 0 || b === d.length - a.length) { + b = typeof b !== 'string' ? ' ' : b; + function d(c, a, d) { + if (a === 0 || a === d.length - c.length) { return ''; } - return c || ''; + return b || ''; } - a = String(a).replace(n, '$1 $2').replace(o, '$1 $2').replace(p, d); - return r(a, b); + a = String(a).replace(w, '$1 $2').replace(x, '$1 $2').replace(y, d); + return A(a, c); } -const t = { +const C = { tr: { regexp: /[\u0069]/g, map: { @@ -132,8 +132,8 @@ const t = { } } }; -function u(a, b) { - const c = b && t[b]; +function D(a, b) { + const c = b && C[b]; a = a == null ? '' : String(a); if (c) { a = a.replace(c.regexp, function(a) { @@ -142,45 +142,45 @@ function u(a, b) { } return a.toUpperCase(); } -function v(a, b, c) { - let d = s(a, b); - if (!c) { - d = d.replace(/ (?=\d)/g, '_'); +function E(b, c, d) { + let a = B(b, c); + if (!d) { + a = a.replace(/ (?=\d)/g, '_'); } - return d.replace(/ (.)/g, function(a, c) { - return u(c, b); + return a.replace(/ (.)/g, function(b, a) { + return D(a, c); }); } -function w(a, b) { - return s(a, b, '-'); +function F(a, b) { + return B(a, b, '-'); } -function x(a) { +function G(g) { const b = []; let c = false; - for (const d of a){ + for (const a of g){ if (c) { - b.push(d); - } else if (d === '--') { + b.push(a); + } else if (a === '--') { c = true; - b.push(d); - } else if (d[0] === '-') { - const e = d[1] === '-'; - if (d.includes('=')) { - const f = d.split('='); - const g = f.shift(); - if (e) { - b.push(g); + b.push(a); + } else if (a[0] === '-') { + const d = a[1] === '-'; + if (a.includes('=')) { + const e = a.split('='); + const f = e.shift(); + if (d) { + b.push(f); } else { - h(g); + h(f); } - b.push(f.join('=')); - } else if (e) { - b.push(d); + b.push(e.join('=')); + } else if (d) { + b.push(a); } else { - h(d); + h(a); } } else { - b.push(d); + b.push(a); } } return b; @@ -195,340 +195,340 @@ function x(a) { } } } -var y; +var a; (function(a) { a["STRING"] = 'string'; a["NUMBER"] = 'number'; a["BOOLEAN"] = 'boolean'; -})(y || (y = {})); -const z = (a, b, c)=>{ +})(a || (a = {})); +const g = (b, c, a)=>{ if (~[ '1', 'true' - ].indexOf(c)) { + ].indexOf(a)) { return true; } if (~[ '0', 'false' - ].indexOf(c)) { + ].indexOf(a)) { return false; } - throw new Error(`Option --${a.name} must be of type boolean but got: ${c}`); + throw new Error(`Option --${b.name} must be of type boolean but got: ${a}`); }; -const A = (a, b, c)=>{ - if (isNaN(c)) { - throw new Error(`Option --${a.name} must be of type number but got: ${c}`); +const h = (b, c, a)=>{ + if (isNaN(a)) { + throw new Error(`Option --${b.name} must be of type number but got: ${a}`); } - return parseFloat(c); + return parseFloat(a); }; -const B = (a, b, c)=>{ - return c; +const i = (b, c, a)=>{ + return a; }; -const C = { - [y.STRING]: B, - [y.NUMBER]: A, - [y.BOOLEAN]: z +const H = { + [a.STRING]: i, + [a.NUMBER]: h, + [a.BOOLEAN]: g }; -function D(a, b) { - while(b[0] === '-'){ - b = b.slice(1); +function I(c, a) { + while(a[0] === '-'){ + a = a.slice(1); } - for (const c of a){ - if (H(c, b)) { - return c; + for (const b of c){ + if (M(b, a)) { + return b; } } return; } -function E(a, b, c, d) { - const e = {}; - for (const f of a){ - const g = v(f.name); - if (typeof b[g] === 'undefined' && typeof f.default !== 'undefined') { - b[g] = typeof f.default === 'function' ? f.default() : f.default; - e[g] = true; +function J(h, d, l, i) { + const j = {}; + for (const b of h){ + const f = E(b.name); + if (typeof d[f] === 'undefined' && typeof b.default !== 'undefined') { + d[f] = typeof b.default === 'function' ? b.default() : b.default; + j[f] = true; } } - const h = Object.keys(b); - if (h.length === 0 && d) { + const e = Object.keys(d); + if (e.length === 0 && i) { return; } - const i = h.map((b)=>({ - name: b, - option: D(a, w(b)) + const g = e.map((a)=>({ + name: a, + option: I(h, F(a)) }) ); - for (const { name: j , option: k } of i){ - if (!k) { - throw new Error('Unknown option: --' + j); + for (const { name: k , option: a } of g){ + if (!a) { + throw new Error('Unknown option: --' + k); } - if (k.standalone) { - if (h.length > 1) { - if (i.every(({ option: a })=>a && (k === a || e[a.name]) + if (a.standalone) { + if (e.length > 1) { + if (g.every(({ option: b })=>b && (a === b || j[b.name]) )) { return; } - throw new Error(`Option --${k.name} cannot be combined with other options.`); + throw new Error(`Option --${a.name} cannot be combined with other options.`); } return; } - k.conflicts?.forEach((a)=>{ - if (m(a)) { - throw new Error(`Option --${k.name} conflicts with option: --${a}`); + a.conflicts?.forEach((b)=>{ + if (n(b)) { + throw new Error(`Option --${a.name} conflicts with option: --${b}`); } }); - k.depends?.forEach((a)=>{ - if (!m(a) && !e[k.name]) { - throw new Error(`Option --${k.name} depends on option: --${a}`); + a.depends?.forEach((b)=>{ + if (!n(b) && !j[a.name]) { + throw new Error(`Option --${a.name} depends on option: --${b}`); } }); - const l = (k.args?.length || 0) > 1; - k.args?.forEach((a, c)=>{ - if (a.requiredValue && (typeof b[j] === 'undefined' || l && typeof b[j][c] === 'undefined')) { - throw new Error(`Missing value for option: --${k.name}`); + const m = (a.args?.length || 0) > 1; + a.args?.forEach((b, c)=>{ + if (b.requiredValue && (typeof d[k] === 'undefined' || m && typeof d[k][c] === 'undefined')) { + throw new Error(`Missing value for option: --${a.name}`); } }); - function m(a) { - const c = v(a); - return typeof b[c] !== 'undefined'; + function n(a) { + const b = E(a); + return typeof d[b] !== 'undefined'; } } - for (const n of a){ - if (n.required && !(v(n.name) in b)) { - if ((!n.conflicts || !n.conflicts.find((a)=>!!b[a] - )) && !i.find((a)=>a.option?.conflicts?.find((a)=>a === n.name + for (const c of h){ + if (c.required && !(E(c.name) in d)) { + if ((!c.conflicts || !c.conflicts.find((a)=>!!d[a] + )) && !g.find((a)=>a.option?.conflicts?.find((a)=>a === c.name ) )) { - throw new Error(`Missing required option: --${n.name}`); + throw new Error(`Missing required option: --${c.name}`); } } } - if (h.length === 0 && !d) { + if (e.length === 0 && !i) { throw new Error('No arguments.'); } } -function F(a, b = {}) { - !b.flags && (b.flags = []); - const c = x(a); - let d = false; - let e = false; - const f = {}; - const g = []; - const h = []; - let i = false; - b.flags.forEach((a)=>{ +function K(q, d = {}) { + !d.flags && (d.flags = []); + const i = G(q); + let j = false; + let r = false; + const e = {}; + const k = []; + const l = []; + let m = false; + d.flags.forEach((a)=>{ a.depends?.forEach((a)=>{ - if (!b.flags || !D(b.flags, a)) { + if (!d.flags || !I(d.flags, a)) { throw new Error(`Unknown required option: ${a}`); } }); a.conflicts?.forEach((a)=>{ - if (!b.flags || !D(b.flags, a)) { + if (!d.flags || !I(d.flags, a)) { throw new Error(`Unknown conflicting option: ${a}`); } }); }); - for(let j = 0; j < c.length; j++){ - let k; - let l; - const m = c[j]; - if (d) { - g.push(m); + for(let g = 0; g < i.length; g++){ + let b; + let h; + const c = i[g]; + if (j) { + k.push(c); continue; } - if (m === '--') { - d = true; + if (c === '--') { + j = true; continue; } - const n = m.length > 1 && m[0] === '-'; - const o = ()=>c[j + 1] + const s = c.length > 1 && c[0] === '-'; + const u = ()=>i[g + 1] ; - if (n && !i) { - if (m[2] === '-' || m[1] === '-' && m.length === 3) { - throw new Error(`Invalid flag name: ${m}`); + if (s && !m) { + if (c[2] === '-' || c[1] === '-' && c.length === 3) { + throw new Error(`Invalid flag name: ${c}`); } - e = m.indexOf('--no-') === 0; - const p = m.replace(/^-+(no-)?/, ''); - k = D(b.flags, p); - if (!k) { - if (b.flags.length) { - throw new Error(`Unknown option: ${m}`); + r = c.indexOf('--no-') === 0; + const n = c.replace(/^-+(no-)?/, ''); + b = I(d.flags, n); + if (!b) { + if (d.flags.length) { + throw new Error(`Unknown option: ${c}`); } - k = { - name: p, + b = { + name: n, optionalValue: true, - type: y.STRING + type: a.STRING }; } - if (!k.name) { - throw new Error(`Missing name for option: ${m}`); + if (!b.name) { + throw new Error(`Missing name for option: ${c}`); } - const q = v(k.name); - if (typeof f[q] !== 'undefined' && !k.collect) { - throw new Error(`Duplicate option: ${m}`); + const f = E(b.name); + if (typeof e[f] !== 'undefined' && !b.collect) { + throw new Error(`Duplicate option: ${c}`); } - l = k.args?.length ? k.args : [ + h = b.args?.length ? b.args : [ { - type: k.type, - requiredValue: k.requiredValue, - optionalValue: k.optionalValue, - variadic: k.variadic, - list: k.list, - separator: k.separator + type: b.type, + requiredValue: b.requiredValue, + optionalValue: b.optionalValue, + variadic: b.variadic, + list: b.list, + separator: b.separator } ]; - let r = 0; - let s = false; - const t = f[q]; - w(k, l); - if (typeof f[q] === 'undefined') { - if (typeof k.default !== 'undefined') { - f[q] = typeof k.default === 'function' ? k.default() : k.default; - } else if (l[r].requiredValue) { - throw new Error(`Missing value for option: --${k.name}`); + let t = 0; + let v = false; + const o = e[f]; + w(b, h); + if (typeof e[f] === 'undefined') { + if (typeof b.default !== 'undefined') { + e[f] = typeof b.default === 'function' ? b.default() : b.default; + } else if (h[t].requiredValue) { + throw new Error(`Missing value for option: --${b.name}`); } else { - f[q] = true; + e[f] = true; } } - if (typeof k.value !== 'undefined') { - f[q] = k.value(f[q], t); - } else if (k.collect) { - const u = t || []; - u.push(f[q]); - f[q] = u; + if (typeof b.value !== 'undefined') { + e[f] = b.value(e[f], o); + } else if (b.collect) { + const p = o || []; + p.push(e[f]); + e[f] = p; } - function w(a, d) { - const g = d[r]; - if (!g) { - throw new Error('Unknown option: ' + o()); + function w(h, j) { + const b = j[t]; + if (!b) { + throw new Error('Unknown option: ' + u()); } - if (!g.type) { - g.type = y.BOOLEAN; + if (!b.type) { + b.type = a.BOOLEAN; } - if (a.args?.length) { - if ((typeof g.optionalValue === 'undefined' || g.optionalValue === false) && typeof g.requiredValue === 'undefined') { - g.requiredValue = true; + if (h.args?.length) { + if ((typeof b.optionalValue === 'undefined' || b.optionalValue === false) && typeof b.requiredValue === 'undefined') { + b.requiredValue = true; } } else { - if (g.type !== y.BOOLEAN && (typeof g.optionalValue === 'undefined' || g.optionalValue === false) && typeof g.requiredValue === 'undefined') { - g.requiredValue = true; + if (b.type !== a.BOOLEAN && (typeof b.optionalValue === 'undefined' || b.optionalValue === false) && typeof b.requiredValue === 'undefined') { + b.requiredValue = true; } } - if (g.requiredValue) { - if (s) { - throw new Error(`An required argument can not follow an optional argument but found in: ${a.name}`); + if (b.requiredValue) { + if (v) { + throw new Error(`An required argument can not follow an optional argument but found in: ${h.name}`); } } else { - s = true; + v = true; } - if (e) { - if (g.type !== y.BOOLEAN && !g.optionalValue) { - throw new Error(`Negate not supported by --${a.name}. Only optional option or options of type boolean can be negated.`); + if (r) { + if (b.type !== a.BOOLEAN && !b.optionalValue) { + throw new Error(`Negate not supported by --${h.name}. Only optional option or options of type boolean can be negated.`); } - f[q] = false; + e[f] = false; return; } - let h; - let i = false; - if (g.list && l(g)) { - const k = o().split(g.separator || ',').map((b)=>{ - const c = m(a, g, b); + let c; + let l = false; + if (b.list && m(b)) { + const k = u().split(b.separator || ',').map((a)=>{ + const c = n(h, b, a); if (typeof c === 'undefined') { - throw new Error(`List item of option --${a?.name} must be of type ${g.type} but got: ${b}`); + throw new Error(`List item of option --${h?.name} must be of type ${b.type} but got: ${a}`); } return c; }); if (k?.length) { - h = k; + c = k; } } else { - if (l(g)) { - h = m(a, g, o()); - } else if (g.optionalValue && g.type === y.BOOLEAN) { - h = true; + if (m(b)) { + c = n(h, b, u()); + } else if (b.optionalValue && b.type === a.BOOLEAN) { + c = true; } } - if (i) { - j++; - if (!g.variadic) { - r++; - } else if (d[r + 1]) { - throw new Error('An argument cannot follow an variadic argument: ' + o()); + if (l) { + g++; + if (!b.variadic) { + t++; + } else if (j[t + 1]) { + throw new Error('An argument cannot follow an variadic argument: ' + u()); } } - if (typeof h !== 'undefined' && (d.length > 1 || g.variadic)) { - if (!f[q]) { - f[q] = []; + if (typeof c !== 'undefined' && (j.length > 1 || b.variadic)) { + if (!e[f]) { + e[f] = []; } - f[q].push(h); - if (l(g)) { - w(a, d); + e[f].push(c); + if (m(b)) { + w(h, j); } } else { - f[q] = h; + e[f] = c; } - function l(a) { - return !!(c[j + 1] && (a.optionalValue || a.requiredValue || a.variadic) && (c[j + 1][0] !== '-' || a.type === y.NUMBER && !isNaN(c[j + 1])) && a); + function m(b) { + return !!(i[g + 1] && (b.optionalValue || b.requiredValue || b.variadic) && (i[g + 1][0] !== '-' || b.type === a.NUMBER && !isNaN(i[g + 1])) && b); } - function m(a, c, d) { - let e = b.parse ? b.parse(c.type || y.STRING, a, c, d) : G(a, c, d); - if (typeof e !== 'undefined') { - i = true; + function n(c, b, e) { + let f = d.parse ? d.parse(b.type || a.STRING, c, b, e) : L(c, b, e); + if (typeof f !== 'undefined') { + l = true; } - return e; + return f; } } } else { - if (b.stopEarly) { - i = true; + if (d.stopEarly) { + m = true; } - h.push(m); + l.push(c); } } - if (b.flags && b.flags.length) { - E(b.flags, f, b.knownFlaks, b.allowEmpty); + if (d.flags && d.flags.length) { + J(d.flags, e, d.knownFlaks, d.allowEmpty); } return { - flags: f, - unknown: h, - literal: g + flags: e, + unknown: l, + literal: k }; } -function G(a, b, c) { - const d = C[b.type || y.STRING]; - if (!d) { +function L(d, b, e) { + const c = H[b.type || a.STRING]; + if (!c) { throw new Error(`Unknown type ${b.type}`); } - return d(a, b, c); + return c(d, b, e); } -function H(a, b) { +function M(a, b) { return a.name === b || a.aliases && a.aliases.indexOf(b) !== -1; } -function I(a, b = '', c = ' ') { - while(b.length < a){ - b += c; +function N(b, a = '', c = ' ') { + while(a.length < b){ + a += c; } - return b; + return a; } -const { inspect: J } = Deno; -const K = /%[sdjoO%]/g; -function L(...a) { +const { inspect: O } = Deno; +const P = /%[sdjoO%]/g; +function Q(...a) { if (typeof a[0] !== 'string') { - let b = []; + let f = []; for(let c = 0; c < arguments.length; c++){ - b.push(J(arguments[c])); + f.push(O(arguments[c])); } - return b.join(' '); + return f.join(' '); } let d = 1; - const e = a[0]; - const f = a.length; - let g = String(e).replace(K, function(b) { + const g = a[0]; + const h = a.length; + let e = String(g).replace(P, function(b) { if (b === '%%') { return '%'; } - if (d >= f) { + if (d >= h) { return b; } switch(b){ @@ -544,25 +544,25 @@ function L(...a) { } case '%o': case '%O': - return J(a[d++]); + return O(a[d++]); default: return b; } }); - for(let h = a[d]; d < f; h = a[++d]){ - if (h == null || typeof h !== 'object') { - g += ' ' + h; + for(let b = a[d]; d < h; b = a[++d]){ + if (b == null || typeof b !== 'object') { + e += ' ' + b; } else { - g += ' ' + J(h); + e += ' ' + O(b); } } - return g; + return e; } -class M { +class b { } -class N extends M { - parse(O, P, Q) { - return z(O, P, Q); +class R extends b { + parse(a, b, c) { + return g(a, b, c); } complete() { return [ @@ -571,99 +571,99 @@ class N extends M { ]; } } -class R extends M { - parse(S, T, U) { - return A(S, T, U); +class S extends b { + parse(a, b, c) { + return h(a, b, c); } } -class V extends M { - parse(W, X, Y) { - return B(W, X, Y); +class T extends b { + parse(a, b, c) { + return i(a, b, c); } } -class Z { - static splitArguments($) { - const _ = $.trim().split(/[, =] */g); - const aa = []; - while(_[_.length - 1] && this.ARGUMENT_REGEX.test(_[_.length - 1])){ - aa.unshift(_.pop()); +class d { + static splitArguments(c) { + const a = c.trim().split(/[, =] */g); + const b = []; + while(a[a.length - 1] && this.ARGUMENT_REGEX.test(a[a.length - 1])){ + b.unshift(a.pop()); } - const ba = aa.join(' '); + const d = b.join(' '); return { - args: _, - typeDefinition: ba + args: a, + typeDefinition: d }; } - static parseArgumentsDefinition(ca) { - const da = []; - let ea = false; - let fa = false; - const ga = ca.split(/ +/); - for (const ha of ga){ - if (fa) { + static parseArgumentsDefinition(k) { + const f = []; + let g = false; + let h = false; + const l = k.split(/ +/); + for (const c of l){ + if (h) { throw new Error('An argument can not follow an variadic argument.'); } - const ia = ha.split(this.ARGUMENT_DETAILS_REGEX); - const ja = ia[2] || y.STRING; - let ka = { - optionalValue: ha[0] !== '<', - name: ia[1], - action: ia[3] || ja, + const e = c.split(this.ARGUMENT_DETAILS_REGEX); + const d = e[2] || a.STRING; + let b = { + optionalValue: c[0] !== '<', + name: e[1], + action: e[3] || d, variadic: false, - list: ja ? ha.indexOf(ja + '[]') !== -1 : false, - type: ja + list: d ? c.indexOf(d + '[]') !== -1 : false, + type: d }; - if (!ka.optionalValue && ea) { + if (!b.optionalValue && g) { throw new Error('An required argument can not follow an optional argument.'); } - if (ha[0] === '[') { - ea = true; + if (c[0] === '[') { + g = true; } - if (ka.name.length > 3) { - const la = ka.name.slice(0, 3) === '...'; - const ma = ka.name.slice(-3) === '...'; - fa = ka.variadic = la || ma; - if (la) { - ka.name = ka.name.slice(3); - } else if (ma) { - ka.name = ka.name.slice(0, -3); + if (b.name.length > 3) { + const i = b.name.slice(0, 3) === '...'; + const j = b.name.slice(-3) === '...'; + h = b.variadic = i || j; + if (i) { + b.name = b.name.slice(3); + } else if (j) { + b.name = b.name.slice(0, -3); } } - if (ka.name) { - da.push(ka); + if (b.name) { + f.push(b); } } - return da; + return f; } - static highlightArguments(na) { - if (!na) { + static highlightArguments(a) { + if (!a) { return ''; } - return this.parseArgumentsDefinition(na).map((a)=>this.highlightArgumentDetails(a) + return this.parseArgumentsDefinition(a).map((a)=>this.highlightArgumentDetails(a) ).join(' '); } - static highlightArgumentDetails(oa) { - let pa = ''; - pa += k(oa.optionalValue ? '[' : '<'); - let qa = ''; - qa += oa.name; - if (oa.variadic) { - qa += '...'; + static highlightArgumentDetails(b) { + let a = ''; + a += t(b.optionalValue ? '[' : '<'); + let c = ''; + c += b.name; + if (b.variadic) { + c += '...'; } - qa = m(qa); - pa += qa; - pa += k(':'); - pa += i(oa.type); - if (oa.list) { - pa += j('[]'); + c = v(c); + a += c; + a += t(':'); + a += r(b.type); + if (b.list) { + a += s('[]'); } - pa += k(oa.optionalValue ? ']' : '>'); - return pa; + a += t(b.optionalValue ? ']' : '>'); + return a; } } -Z.ARGUMENT_REGEX = /^[<\[].+[\]>]$/; -Z.ARGUMENT_DETAILS_REGEX = /[<\[:>\]]/; -const ra = { +d.ARGUMENT_REGEX = /^[<\[].+[\]>]$/; +d.ARGUMENT_DETAILS_REGEX = /[<\[:>\]]/; +const U = { top: '─', topMid: '┬', topLeft: '┌', @@ -680,48 +680,48 @@ const ra = { rightMid: '┤', middle: '│' }; -class sa { +class V { get length() { return this.toString().length; } - static from(ta) { - const ua = new this(ta); - if (ta instanceof sa) { - ua.options = Object.assign({}, ta.options); + static from(a) { + const b = new this(a); + if (a instanceof V) { + b.options = Object.assign({}, a.options); } - return ua; + return b; } - constructor(va){ - this.value = va; + constructor(a){ + this.value = a; this.options = {}; } toString() { return this.value.toString(); } - setValue(wa) { - this.value = wa; + setValue(a) { + this.value = a; return this; } - clone(xa) { - const ya = new sa(xa ?? this); - ya.options = Object.assign({}, this.options); - return ya; + clone(b) { + const a = new V(b ?? this); + a.options = Object.assign({}, this.options); + return a; } - border(za, Aa = true) { - if (Aa || typeof this.options.border === 'undefined') { - this.options.border = za; + border(a, b = true) { + if (b || typeof this.options.border === 'undefined') { + this.options.border = a; } return this; } - colSpan(Ba, Ca = true) { - if (Ca || typeof this.options.colSpan === 'undefined') { - this.options.colSpan = Ba; + colSpan(a, b = true) { + if (b || typeof this.options.colSpan === 'undefined') { + this.options.colSpan = a; } return this; } - rowSpan(Da, Ea = true) { - if (Ea || typeof this.options.rowSpan === 'undefined') { - this.options.rowSpan = Da; + rowSpan(a, b = true) { + if (b || typeof this.options.rowSpan === 'undefined') { + this.options.rowSpan = a; } return this; } @@ -735,23 +735,23 @@ class sa { return typeof this.options.rowSpan === 'number' && this.options.rowSpan > 0 ? this.options.rowSpan : 1; } } -class Fa extends Array { - static from(Ga) { - const Ha = new this(...Ga); - if (Ga instanceof Fa) { - Ha.options = Object.assign({}, Ga.options); +class W extends Array { + static from(a) { + const b = new this(...a); + if (a instanceof W) { + b.options = Object.assign({}, a.options); } - return Ha; + return b; } clone() { - const Ia = new Fa(...this.map((a)=>a instanceof sa ? a.clone() : a + const a = new W(...this.map((a)=>a instanceof V ? a.clone() : a )); - Ia.options = Object.assign({}, this.options); - return Ia; + a.options = Object.assign({}, this.options); + return a; } - border(Ja, Ka = true) { - if (Ka || typeof this.options.border === 'undefined') { - this.options.border = Ja; + border(a, b = true) { + if (b || typeof this.options.border === 'undefined') { + this.options.border = a; } return this; } @@ -759,56 +759,56 @@ class Fa extends Array { return this.options.border === true; } hasBorder() { - return this.getBorder() || this.some((a)=>a instanceof sa && a.getBorder() + return this.getBorder() || this.some((a)=>a instanceof V && a.getBorder() ); } - constructor(...La){ - super(...La); + constructor(...a){ + super(...a); this.options = {}; } } -function Ma(a, b) { - let c = ''; - const d = b.split(/ /g); - for(let e = 0; e < d.length; e++){ - let f = d[e]; - let g = f.indexOf('\n') !== -1; - if (g) { - f = f.split('\n').shift(); +function X(f, g) { + let b = ''; + const d = g.split(/ /g); + for(let c = 0; c < d.length; c++){ + let a = d[c]; + let e = a.indexOf('\n') !== -1; + if (e) { + a = a.split('\n').shift(); } - if (c) { - const h = Oa(f).length; - const i = Oa(c).length; - if (i + h >= a) { + if (b) { + const h = Z(a).length; + const i = Z(b).length; + if (i + h >= f) { break; } } - c += (e > 0 ? ' ' : '') + f; - if (g) { + b += (c > 0 ? ' ' : '') + a; + if (e) { break; } } - return c; + return b; } -const Na = /(\x1b|\e|\033)\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]/g; -function Oa(a) { - return a.replace(Na, ''); +const Y = /(\x1b|\e|\033)\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]/g; +function Z(a) { + return a.replace(Y, ''); } -function Pa(a, b, c) { - return Math.max(...b.map((b)=>(b[a] instanceof sa && b[a].getColSpan() > 1 ? '' : b[a]?.toString() || '').split('\n').map((a)=>{ - const b = typeof c === 'undefined' ? a : Ma(c, a); - return Oa(b).length || 0; +function $(b, a, c) { + return Math.max(...a.map((a)=>(a[b] instanceof V && a[b].getColSpan() > 1 ? '' : a[b]?.toString() || '').split('\n').map((a)=>{ + const b = typeof c === 'undefined' ? a : X(c, a); + return Z(b).length || 0; }) ).flat()); } -class Qa { - constructor(Ra, Sa){ - this.table = Ra; - this.options = Sa; +class _ { + constructor(a, b){ + this.table = a; + this.options = b; } toString() { - const Ta = this.createLayout(); - return Ta.rows.length ? this.renderRows(Ta) : ''; + const a = this.createLayout(); + return a.rows.length ? this.renderRows(a) : ''; } createLayout() { Object.keys(this.options.chars).forEach((a)=>{ @@ -816,411 +816,411 @@ class Qa { this.options.chars[a] = ''; } }); - const Ua = this.table.getBorder() || this.table.hasBodyBorder(); - const Va = this.table.hasHeaderBorder(); - const Wa = Va || Ua; - const Xa = this.table.getHeader(); - const Ya = this.spanRows(Xa ? [ - Xa, + const e = this.table.getBorder() || this.table.hasBodyBorder(); + const f = this.table.hasHeaderBorder(); + const m = f || e; + const g = this.table.getHeader(); + const b = this.spanRows(g ? [ + g, ...this.table ] : this.table.slice()); - const Za = Math.max(...Ya.map((a)=>a.length + const c = Math.max(...b.map((a)=>a.length )); - for (const $a of Ya){ - const _a = $a.length; - if (_a < Za) { - const ab = Za - _a; - for(let bb = 0; bb < ab; bb++){ - $a.push(this.createCell(null, $a)); + for (const d of b){ + const h = d.length; + if (h < c) { + const n = c - h; + for(let i = 0; i < n; i++){ + d.push(this.createCell(null, d)); } } } - const cb = []; - const db = []; - for(let eb = 0; eb < Za; eb++){ - const fb = Array.isArray(this.options.minCellWidth) ? this.options.minCellWidth[eb] : this.options.minCellWidth; - const gb = Array.isArray(this.options.maxCellWidth) ? this.options.maxCellWidth[eb] : this.options.maxCellWidth; - const hb = Pa(eb, Ya, gb); - db[eb] = Math.min(gb, Math.max(fb, hb)); - cb[eb] = Array.isArray(this.options.padding) ? this.options.padding[eb] : this.options.padding; + const j = []; + const k = []; + for(let a = 0; a < c; a++){ + const o = Array.isArray(this.options.minCellWidth) ? this.options.minCellWidth[a] : this.options.minCellWidth; + const l = Array.isArray(this.options.maxCellWidth) ? this.options.maxCellWidth[a] : this.options.maxCellWidth; + const p = $(a, b, l); + k[a] = Math.min(l, Math.max(o, p)); + j[a] = Array.isArray(this.options.padding) ? this.options.padding[a] : this.options.padding; } return { - padding: cb, - width: db, - rows: Ya, - columns: Za, - hasBorder: Wa, - hasBodyBorder: Ua, - hasHeaderBorder: Va + padding: j, + width: k, + rows: b, + columns: c, + hasBorder: m, + hasBodyBorder: e, + hasHeaderBorder: f }; } - spanRows(ib, jb = 0, kb = 0, lb = [], mb = 1) { - const nb = ib; - if (jb >= nb.length && lb.every((a)=>a === 1 + spanRows(f, c = 0, a = 0, d = [], e = 1) { + const b = f; + if (c >= b.length && d.every((a)=>a === 1 )) { - return nb; - } else if (nb[jb] && kb >= nb[jb].length && kb >= lb.length && mb === 1) { - return this.spanRows(nb, ++jb, 0, lb, 1); + return b; + } else if (b[c] && a >= b[c].length && a >= d.length && e === 1) { + return this.spanRows(b, ++c, 0, d, 1); } - if (mb > 1) { - mb--; - lb[kb] = lb[kb - 1]; - nb[jb].splice(kb - 1, 0, nb[jb][kb - 1]); - return this.spanRows(nb, jb, ++kb, lb, mb); + if (e > 1) { + e--; + d[a] = d[a - 1]; + b[c].splice(a - 1, 0, b[c][a - 1]); + return this.spanRows(b, c, ++a, d, e); } - if (kb === 0) { - nb[jb] = this.createRow(nb[jb] || []); + if (a === 0) { + b[c] = this.createRow(b[c] || []); } - if (lb[kb] > 1) { - lb[kb]--; - nb[jb].splice(kb, 0, nb[jb - 1][kb]); - return this.spanRows(nb, jb, ++kb, lb, mb); + if (d[a] > 1) { + d[a]--; + b[c].splice(a, 0, b[c - 1][a]); + return this.spanRows(b, c, ++a, d, e); } - nb[jb][kb] = this.createCell(nb[jb][kb] || null, nb[jb]); - mb = nb[jb][kb].getColSpan(); - lb[kb] = nb[jb][kb].getRowSpan(); - return this.spanRows(nb, jb, ++kb, lb, mb); + b[c][a] = this.createCell(b[c][a] || null, b[c]); + e = b[c][a].getColSpan(); + d[a] = b[c][a].getRowSpan(); + return this.spanRows(b, c, ++a, d, e); } - createRow(ob) { - return Fa.from(ob).border(this.table.getBorder(), false); + createRow(a) { + return W.from(a).border(this.table.getBorder(), false); } - createCell(pb, qb) { - return sa.from(pb ?? '').border(qb.getBorder(), false); + createCell(a, b) { + return V.from(a ?? '').border(b.getBorder(), false); } - renderRows(rb) { - let sb = ''; - const tb = new Array(rb.columns).fill(1); - for(let ub = 0; ub < rb.rows.length; ub++){ - sb += this.renderRow(tb, ub, rb); + renderRows(a) { + let c = ''; + const d = new Array(a.columns).fill(1); + for(let b = 0; b < a.rows.length; b++){ + c += this.renderRow(d, b, a); } - return sb.slice(0, -1); + return c.slice(0, -1); } - renderRow(vb, wb, xb, yb) { - const zb = xb.rows[wb]; - const Ab = xb.rows[wb - 1]; - const Bb = xb.rows[wb + 1]; - let Cb = ''; - let Db = 1; - if (!yb && wb === 0 && zb.hasBorder()) { - Cb += this.renderBorderRow(undefined, zb, vb, xb); + renderRow(c, f, a, j) { + const d = a.rows[f]; + const g = a.rows[f - 1]; + const k = a.rows[f + 1]; + let e = ''; + let h = 1; + if (!j && f === 0 && d.hasBorder()) { + e += this.renderBorderRow(undefined, d, c, a); } - let Eb = false; - Cb += ' '.repeat(this.options.indent || 0); - for(let Fb = 0; Fb < xb.columns; Fb++){ - if (Db > 1) { - Db--; - vb[Fb] = vb[Fb - 1]; + let i = false; + e += ' '.repeat(this.options.indent || 0); + for(let b = 0; b < a.columns; b++){ + if (h > 1) { + h--; + c[b] = c[b - 1]; continue; } - Cb += this.renderCell(Fb, zb, Ab, vb, xb); - if (vb[Fb] > 1) { - if (!yb) { - vb[Fb]--; + e += this.renderCell(b, d, g, c, a); + if (c[b] > 1) { + if (!j) { + c[b]--; } - } else if (!Ab || Ab[Fb] !== zb[Fb]) { - vb[Fb] = zb[Fb].getRowSpan(); + } else if (!g || g[b] !== d[b]) { + c[b] = d[b].getRowSpan(); } - Db = zb[Fb].getColSpan(); - if (vb[Fb] === 1 && zb[Fb].length) { - Eb = true; + h = d[b].getColSpan(); + if (c[b] === 1 && d[b].length) { + i = true; } } - if (xb.columns > 0) { - if (zb[xb.columns - 1].getBorder()) { - Cb += this.options.chars.right; - } else if (xb.hasBorder) { - Cb += ' '; + if (a.columns > 0) { + if (d[a.columns - 1].getBorder()) { + e += this.options.chars.right; + } else if (a.hasBorder) { + e += ' '; } } - Cb += '\n'; - if (Eb) { - return Cb + this.renderRow(vb, wb, xb, Eb); + e += '\n'; + if (i) { + return e + this.renderRow(c, f, a, i); } - if (wb === 0 && xb.hasHeaderBorder || wb < xb.rows.length - 1 && xb.hasBodyBorder) { - Cb += this.renderBorderRow(zb, Bb, vb, xb); + if (f === 0 && a.hasHeaderBorder || f < a.rows.length - 1 && a.hasBodyBorder) { + e += this.renderBorderRow(d, k, c, a); } - if (wb === xb.rows.length - 1 && zb.hasBorder()) { - Cb += this.renderBorderRow(zb, undefined, vb, xb); + if (f === a.rows.length - 1 && d.hasBorder()) { + e += this.renderBorderRow(d, undefined, c, a); } - return Cb; + return e; } - renderCell(Gb, Hb, Ib, Jb, Kb, Lb) { - let Mb = ''; - const Nb = Hb[Gb - 1]; - const Ob = Hb[Gb]; - if (!Lb) { - if (Gb === 0) { - if (Ob.getBorder()) { - Mb += this.options.chars.left; - } else if (Kb.hasBorder) { - Mb += ' '; + renderCell(b, f, m, n, a, i) { + let c = ''; + const j = f[b - 1]; + const e = f[b]; + if (!i) { + if (b === 0) { + if (e.getBorder()) { + c += this.options.chars.left; + } else if (a.hasBorder) { + c += ' '; } } else { - if (Ob.getBorder() || Nb?.getBorder()) { - Mb += this.options.chars.middle; - } else if (Kb.hasBorder) { - Mb += ' '; + if (e.getBorder() || j?.getBorder()) { + c += this.options.chars.middle; + } else if (a.hasBorder) { + c += ' '; } } } - let Pb = Kb.width[Gb]; - const Qb = Ob.getColSpan(); - if (Qb > 1) { - for(let Rb = 1; Rb < Qb; Rb++){ - Pb += Kb.width[Gb + Rb] + Kb.padding[Gb + Rb]; - if (Kb.hasBorder) { - Pb += Kb.padding[Gb + Rb] + 1; + let g = a.width[b]; + const h = e.getColSpan(); + if (h > 1) { + for(let d = 1; d < h; d++){ + g += a.width[b + d] + a.padding[b + d]; + if (a.hasBorder) { + g += a.padding[b + d] + 1; } } } - const { current: Sb , next: Tb } = this.renderCellValue(Ob, Pb); - Hb[Gb].setValue(Tb); - if (Kb.hasBorder) { - Mb += ' '.repeat(Kb.padding[Gb]); + const { current: k , next: l } = this.renderCellValue(e, g); + f[b].setValue(l); + if (a.hasBorder) { + c += ' '.repeat(a.padding[b]); } - Mb += Sb; - if (Kb.hasBorder || Gb < Kb.columns - 1) { - Mb += ' '.repeat(Kb.padding[Gb]); + c += k; + if (a.hasBorder || b < a.columns - 1) { + c += ' '.repeat(a.padding[b]); } - return Mb; + return c; } - renderCellValue(Ub, Vb) { - const Wb = Math.min(Vb, Oa(Ub.toString()).length); - let Xb = Ma(Wb, Ub.toString()); - const Yb = Oa(Xb).length > Wb; - if (Yb) { - Xb = Xb.slice(0, Wb); + renderCellValue(b, d) { + const c = Math.min(d, Z(b.toString()).length); + let a = X(c, b.toString()); + const e = Z(a).length > c; + if (e) { + a = a.slice(0, c); } - const Zb = Ub.toString().slice(Xb.length + (Yb ? 0 : 1)); - const $b = Vb - Oa(Xb).length; - const _b = Xb + ' '.repeat($b); + const f = b.toString().slice(a.length + (e ? 0 : 1)); + const g = d - Z(a).length; + const h = a + ' '.repeat(g); return { - current: _b, - next: Ub.clone(Zb) + current: h, + next: b.clone(f) }; } - renderBorderRow(ac, bc, cc, dc) { - let ec = ''; - let fc = 1; - for(let gc = 0; gc < dc.columns; gc++){ - if (cc[gc] > 1) { - if (!bc) { + renderBorderRow(g, b, e, f) { + let c = ''; + let d = 1; + for(let a = 0; a < f.columns; a++){ + if (e[a] > 1) { + if (!b) { throw new Error('invalid layout'); } - if (fc > 1) { - fc--; + if (d > 1) { + d--; continue; } } - ec += this.renderBorderCell(gc, ac, bc, cc, dc); - fc = bc?.[gc].getColSpan() ?? 1; + c += this.renderBorderCell(a, g, b, e, f); + d = b?.[a].getColSpan() ?? 1; } - return ec.length ? ' '.repeat(this.options.indent) + ec + '\n' : ''; + return c.length ? ' '.repeat(this.options.indent) + c + '\n' : ''; } - renderBorderCell(hc, ic, jc, kc, lc) { - const mc = ic?.[hc - 1]; - const nc = jc?.[hc - 1]; - const oc = ic?.[hc]; - const pc = jc?.[hc]; - const qc = !!mc?.getBorder(); - const rc = !!nc?.getBorder(); - const sc = !!oc?.getBorder(); - const tc = !!pc?.getBorder(); - const uc = (a)=>(a?.getColSpan() ?? 1) > 1 + renderBorderCell(b, q, j, o, k) { + const e = q?.[b - 1]; + const f = j?.[b - 1]; + const g = q?.[b]; + const h = j?.[b]; + const l = !!e?.getBorder(); + const m = !!f?.getBorder(); + const c = !!g?.getBorder(); + const d = !!h?.getBorder(); + const i = (a)=>(a?.getColSpan() ?? 1) > 1 ; - const vc = (a)=>(a?.getRowSpan() ?? 1) > 1 + const n = (a)=>(a?.getRowSpan() ?? 1) > 1 ; - let wc = ''; - if (hc === 0) { - if (kc[hc] > 1) { - if (sc) { - wc += this.options.chars.left; + let a = ''; + if (b === 0) { + if (o[b] > 1) { + if (c) { + a += this.options.chars.left; } else { - wc += ' '; + a += ' '; } - } else if (sc && tc) { - wc += this.options.chars.leftMid; - } else if (sc) { - wc += this.options.chars.bottomLeft; - } else if (tc) { - wc += this.options.chars.topLeft; + } else if (c && d) { + a += this.options.chars.leftMid; + } else if (c) { + a += this.options.chars.bottomLeft; + } else if (d) { + a += this.options.chars.topLeft; } else { - wc += ' '; + a += ' '; } - } else if (hc < lc.columns) { - if (qc && tc || sc && rc) { - const xc = uc(mc); - const yc = uc(nc); - const zc = uc(oc); - const Ac = uc(pc); - const Bc = vc(mc); - const Cc = vc(nc); - const Dc = vc(oc); - const Ec = vc(pc); - const Fc = qc && tc && sc && rc; - const Gc = Bc && Dc && Cc && Ec; - const Hc = xc && zc && yc && Ac; - if (Gc && Fc) { - wc += this.options.chars.middle; - } else if (Hc && Fc && mc === oc && nc === pc) { - wc += this.options.chars.mid; - } else if (xc && zc && mc === oc) { - wc += this.options.chars.topMid; - } else if (yc && Ac && nc === pc) { - wc += this.options.chars.bottomMid; - } else if (Bc && Cc && mc === nc) { - wc += this.options.chars.leftMid; - } else if (Dc && Ec && oc === pc) { - wc += this.options.chars.rightMid; + } else if (b < k.columns) { + if (l && d || c && m) { + const r = i(e); + const s = i(f); + const t = i(g); + const u = i(h); + const v = n(e); + const w = n(f); + const x = n(g); + const y = n(h); + const z = l && d && c && m; + const A = v && x && w && y; + const B = r && t && s && u; + if (A && z) { + a += this.options.chars.middle; + } else if (B && z && e === g && f === h) { + a += this.options.chars.mid; + } else if (r && t && e === g) { + a += this.options.chars.topMid; + } else if (s && u && f === h) { + a += this.options.chars.bottomMid; + } else if (v && w && e === f) { + a += this.options.chars.leftMid; + } else if (x && y && g === h) { + a += this.options.chars.rightMid; } else { - wc += this.options.chars.midMid; + a += this.options.chars.midMid; } - } else if (qc && sc) { - if (uc(mc) && uc(oc) && mc === oc) { - wc += this.options.chars.bottom; + } else if (l && c) { + if (i(e) && i(g) && e === g) { + a += this.options.chars.bottom; } else { - wc += this.options.chars.bottomMid; + a += this.options.chars.bottomMid; } - } else if (sc && tc) { - if (kc[hc] > 1) { - wc += this.options.chars.left; + } else if (c && d) { + if (o[b] > 1) { + a += this.options.chars.left; } else { - wc += this.options.chars.leftMid; + a += this.options.chars.leftMid; } - } else if (tc && rc) { - if (uc(nc) && uc(pc) && nc === pc) { - wc += this.options.chars.top; + } else if (d && m) { + if (i(f) && i(h) && f === h) { + a += this.options.chars.top; } else { - wc += this.options.chars.topMid; + a += this.options.chars.topMid; } - } else if (qc && rc) { - if (vc(mc) && mc === nc) { - wc += this.options.chars.right; + } else if (l && m) { + if (n(e) && e === f) { + a += this.options.chars.right; } else { - wc += this.options.chars.rightMid; + a += this.options.chars.rightMid; } - } else if (qc) { - wc += this.options.chars.bottomRight; - } else if (sc) { - wc += this.options.chars.bottomLeft; - } else if (rc) { - wc += this.options.chars.topRight; - } else if (tc) { - wc += this.options.chars.topLeft; + } else if (l) { + a += this.options.chars.bottomRight; + } else if (c) { + a += this.options.chars.bottomLeft; + } else if (m) { + a += this.options.chars.topRight; + } else if (d) { + a += this.options.chars.topLeft; } else { - wc += ' '; + a += ' '; } } - const Ic = lc.padding[hc] + lc.width[hc] + lc.padding[hc]; - if (kc[hc] > 1 && jc) { - wc += this.renderCell(hc, jc, ic, kc, lc, true); - if (jc[hc] === jc[jc.length - 1]) { - if (sc) { - wc += this.options.chars.right; + const p = k.padding[b] + k.width[b] + k.padding[b]; + if (o[b] > 1 && j) { + a += this.renderCell(b, j, q, o, k, true); + if (j[b] === j[j.length - 1]) { + if (c) { + a += this.options.chars.right; } else { - wc += ' '; + a += ' '; } - return wc; + return a; } - } else if (sc && tc) { - wc += this.options.chars.mid.repeat(Ic); - } else if (sc) { - wc += this.options.chars.bottom.repeat(Ic); - } else if (tc) { - wc += this.options.chars.top.repeat(Ic); + } else if (c && d) { + a += this.options.chars.mid.repeat(p); + } else if (c) { + a += this.options.chars.bottom.repeat(p); + } else if (d) { + a += this.options.chars.top.repeat(p); } else { - wc += ' '.repeat(Ic); + a += ' '.repeat(p); } - if (hc === lc.columns - 1) { - if (sc && tc) { - wc += this.options.chars.rightMid; - } else if (sc) { - wc += this.options.chars.bottomRight; - } else if (tc) { - wc += this.options.chars.topRight; + if (b === k.columns - 1) { + if (c && d) { + a += this.options.chars.rightMid; + } else if (c) { + a += this.options.chars.bottomRight; + } else if (d) { + a += this.options.chars.topRight; } else { - wc += ' '; + a += ' '; } } - return wc; + return a; } } -class Jc extends Array { - static from(Kc) { - const Lc = new this(...Kc); - if (Kc instanceof Jc) { - Lc.options = Object.assign({}, Kc.options); - Lc.headerRow = Kc.headerRow ? Fa.from(Kc.headerRow) : undefined; +class aa extends Array { + static from(a) { + const b = new this(...a); + if (a instanceof aa) { + b.options = Object.assign({}, a.options); + b.headerRow = a.headerRow ? W.from(a.headerRow) : undefined; } - return Lc; + return b; } - static fromJson(Mc) { - return new this().fromJson(Mc); + static fromJson(a) { + return new this().fromJson(a); } - static render(Nc) { - Jc.from(Nc).render(); + static render(a) { + aa.from(a).render(); } - fromJson(Oc) { - this.header(Object.keys(Oc[0])); - this.body(Oc.map((a)=>Object.values(a) + fromJson(a) { + this.header(Object.keys(a[0])); + this.body(a.map((a)=>Object.values(a) )); return this; } - header(Pc) { - this.headerRow = Pc instanceof Fa ? Pc : Fa.from(Pc); + header(a) { + this.headerRow = a instanceof W ? a : W.from(a); return this; } - body(Qc) { + body(a) { this.length = 0; - this.push(...Qc); + this.push(...a); return this; } clone() { - const Rc = new Jc(...this.map((a)=>a instanceof Fa ? a.clone() : Fa.from(a).clone() + const a = new aa(...this.map((a)=>a instanceof W ? a.clone() : W.from(a).clone() )); - Rc.options = Object.assign({}, this.options); - Rc.headerRow = this.headerRow?.clone(); - return Rc; + a.options = Object.assign({}, this.options); + a.headerRow = this.headerRow?.clone(); + return a; } toString() { - return new Qa(this, this.options).toString(); + return new _(this, this.options).toString(); } render() { - Deno.stdout.writeSync(b(this.toString() + '\n')); + Deno.stdout.writeSync(l(this.toString() + '\n')); return this; } - maxCellWidth(Sc, Tc = true) { - if (Tc || typeof this.options.maxCellWidth === 'undefined') { - this.options.maxCellWidth = Sc; + maxCellWidth(a, b = true) { + if (b || typeof this.options.maxCellWidth === 'undefined') { + this.options.maxCellWidth = a; } return this; } - minCellWidth(Uc, Vc = true) { - if (Vc || typeof this.options.minCellWidth === 'undefined') { - this.options.minCellWidth = Uc; + minCellWidth(a, b = true) { + if (b || typeof this.options.minCellWidth === 'undefined') { + this.options.minCellWidth = a; } return this; } - indent(Wc, Xc = true) { - if (Xc || typeof this.options.indent === 'undefined') { - this.options.indent = Wc; + indent(a, b = true) { + if (b || typeof this.options.indent === 'undefined') { + this.options.indent = a; } return this; } - padding(Yc, Zc = true) { - if (Zc || typeof this.options.padding === 'undefined') { - this.options.padding = Yc; + padding(a, b = true) { + if (b || typeof this.options.padding === 'undefined') { + this.options.padding = a; } return this; } - border($c, _c = true) { - if (_c || typeof this.options.border === 'undefined') { - this.options.border = $c; + border(a, b = true) { + if (b || typeof this.options.border === 'undefined') { + this.options.border = a; } return this; } - chars(ad) { - Object.assign(this.options.chars, ad); + chars(a) { + Object.assign(this.options.chars, a); return this; } getHeader() { @@ -1245,48 +1245,48 @@ class Jc extends Array { return this.options.border === true; } hasHeaderBorder() { - return this.getBorder() || this.headerRow instanceof Fa && this.headerRow.hasBorder(); + return this.getBorder() || this.headerRow instanceof W && this.headerRow.hasBorder(); } hasBodyBorder() { - return this.getBorder() || this.some((a)=>a instanceof Fa ? a.hasBorder() : a.some((a)=>a instanceof sa ? a.getBorder : false + return this.getBorder() || this.some((a)=>a instanceof W ? a.hasBorder() : a.some((a)=>a instanceof V ? a.getBorder : false ) ); } hasBorder() { return this.hasHeaderBorder() || this.hasBodyBorder(); } - constructor(...bd){ - super(...bd); + constructor(...a){ + super(...a); this.options = { indent: 0, border: false, maxCellWidth: Infinity, minCellWidth: 0, padding: 1, - chars: ra + chars: U }; } } -class cd { - static generate(dd) { - return new cd(dd).generate(); +class ba { + static generate(a) { + return new ba(a).generate(); } - constructor(ed){ - this.cmd = ed; + constructor(a){ + this.cmd = a; this.indent = 2; } generate() { return this.generateHeader() + this.generateDescription() + this.generateOptions() + this.generateCommands() + this.generateEnvironmentVariables() + this.generateExamples() + '\n'; } generateHeader() { - return '\n' + Jc.from([ + return '\n' + aa.from([ [ - g('Usage:'), - m(`${this.cmd.getName()}${this.cmd.getArgsDefinition() ? ' ' + this.cmd.getArgsDefinition() : ''}`) + p('Usage:'), + v(`${this.cmd.getName()}${this.cmd.getArgsDefinition() ? ' ' + this.cmd.getArgsDefinition() : ''}`) ], [ - g('Version:'), - k(`v${this.cmd.getVersion()}`) + p('Version:'), + t(`v${this.cmd.getVersion()}`) ] ]).indent(this.indent).padding(1).toString() + '\n'; } @@ -1294,26 +1294,26 @@ class cd { if (!this.cmd.getDescription()) { return ''; } - return this.label('Description') + Jc.from([ + return this.label('Description') + aa.from([ [ this.cmd.getDescription() ] ]).indent(this.indent * 2).maxCellWidth(140).padding(1).toString() + '\n'; } generateOptions() { - const fd = this.cmd.getOptions(false); - if (!fd.length) { + const a = this.cmd.getOptions(false); + if (!a.length) { return ''; } - const gd = !!fd.find((a)=>!!a.typeDefinition + const b = !!a.find((a)=>!!a.typeDefinition ); - if (gd) { - return this.label('Options') + Jc.from([ - ...fd.map((a)=>[ - a.flags.split(/,? +/g).map((a)=>l(a) + if (b) { + return this.label('Options') + aa.from([ + ...a.map((a)=>[ + a.flags.split(/,? +/g).map((a)=>u(a) ).join(', '), - Z.highlightArguments(a.typeDefinition || ''), - i(g('-')) + ' ' + a.description.split('\n').shift(), + d.highlightArguments(a.typeDefinition || ''), + r(p('-')) + ' ' + a.description.split('\n').shift(), this.generateHints(a) ] ) @@ -1328,11 +1328,11 @@ class cd { 60 ]).toString() + '\n'; } - return this.label('Options') + Jc.from([ - ...fd.map((a)=>[ - a.flags.split(/,? +/g).map((a)=>l(a) + return this.label('Options') + aa.from([ + ...a.map((a)=>[ + a.flags.split(/,? +/g).map((a)=>u(a) ).join(', '), - i(g('-')) + ' ' + a.description.split('\n').shift(), + r(p('-')) + ' ' + a.description.split('\n').shift(), this.generateHints(a) ] ) @@ -1346,22 +1346,22 @@ class cd { ]).toString() + '\n'; } generateCommands() { - const hd = this.cmd.getCommands(false); - if (!hd.length) { + const a = this.cmd.getCommands(false); + if (!a.length) { return ''; } - const id = !!hd.find((a)=>!!a.getArgsDefinition() + const b = !!a.find((a)=>!!a.getArgsDefinition() ); - if (id) { - return this.label('Commands') + Jc.from([ - ...hd.map((a)=>[ + if (b) { + return this.label('Commands') + aa.from([ + ...a.map((a)=>[ [ a.getName(), ...a.getAliases() - ].map((a)=>l(a) + ].map((a)=>u(a) ).join(', '), - Z.highlightArguments(a.getArgsDefinition() || ''), - i(g('-')) + ' ' + a.getDescription().split('\n').shift() + d.highlightArguments(a.getArgsDefinition() || ''), + r(p('-')) + ' ' + a.getDescription().split('\n').shift() ] ) ]).padding([ @@ -1370,14 +1370,14 @@ class cd { 2 ]).indent(this.indent * 2).toString() + '\n'; } - return this.label('Commands') + Jc.from([ - ...hd.map((a)=>[ + return this.label('Commands') + aa.from([ + ...a.map((a)=>[ [ a.getName(), ...a.getAliases() - ].map((a)=>l(a) + ].map((a)=>u(a) ).join(', '), - i(g('-')) + ' ' + a.getDescription().split('\n').shift() + r(p('-')) + ' ' + a.getDescription().split('\n').shift() ] ) ]).padding([ @@ -1386,146 +1386,146 @@ class cd { ]).indent(this.indent * 2).toString() + '\n'; } generateEnvironmentVariables() { - const jd = this.cmd.getEnvVars(false); - if (!jd.length) { + const a = this.cmd.getEnvVars(false); + if (!a.length) { return ''; } - return this.label('Environment variables') + Jc.from([ - ...jd.map((a)=>[ - a.names.map((a)=>l(a) + return this.label('Environment variables') + aa.from([ + ...a.map((a)=>[ + a.names.map((a)=>u(a) ).join(', '), - Z.highlightArgumentDetails(a.details), - `${i(g('-'))} ${a.description}` + d.highlightArgumentDetails(a.details), + `${r(p('-'))} ${a.description}` ] ) ]).padding(2).indent(this.indent * 2).toString() + '\n'; } generateExamples() { - const kd = this.cmd.getExamples(); - if (!kd.length) { + const a = this.cmd.getExamples(); + if (!a.length) { return ''; } - return this.label('Examples') + Jc.from(kd.map((a)=>[ - h(g(`${pd(a.name)}:`)), + return this.label('Examples') + aa.from(a.map((a)=>[ + q(p(`${ca(a.name)}:`)), `\n${a.description}` ] )).padding(1).indent(this.indent * 2).maxCellWidth(150).toString() + '\n'; } - generateHints(ld) { - const md = []; - ld.required && md.push(k(`required`)); - typeof ld.default !== 'undefined' && md.push(l(g(`Default: `)) + l(L(ld.default))); - ld.depends && ld.depends.length && md.push(i(g(`depends: `)) + ld.depends.map((a)=>i(a) + generateHints(a) { + const b = []; + a.required && b.push(t(`required`)); + typeof a.default !== 'undefined' && b.push(u(p(`Default: `)) + u(Q(a.default))); + a.depends && a.depends.length && b.push(r(p(`depends: `)) + a.depends.map((a)=>r(a) ).join(', ')); - ld.conflicts && ld.conflicts.length && md.push(i(g(`conflicts: `)) + ld.conflicts.map((a)=>i(a) + a.conflicts && a.conflicts.length && b.push(r(p(`conflicts: `)) + a.conflicts.map((a)=>r(a) ).join(', ')); - if (md.length) { - return `(${md.join(', ')})`; + if (b.length) { + return `(${b.join(', ')})`; } return ''; } - line(...nd) { - return (nd.length ? ' '.repeat(this.indent) + L(...nd) : '') + '\n'; + line(...a) { + return (a.length ? ' '.repeat(this.indent) + Q(...a) : '') + '\n'; } - label(od) { - return '\n' + this.line(g(`${od}:`)) + '\n'; + label(a) { + return '\n' + this.line(p(`${a}:`)) + '\n'; } } -function pd(a) { +function ca(a) { return (a?.charAt(0).toUpperCase() + a.slice(1)) ?? ''; } -const { stdout: qd , stderr: rd } = Deno; -const sd = Deno.permissions; -const td = sd && sd.query && await sd.query({ +const { stdout: da , stderr: ea } = Deno; +const c = Deno.permissions; +const e = c && c.query && await c.query({ name: 'env' }); -const ud = !!td && td.state === 'granted'; -class vd { - versionOption(wd, xd, yd) { - this._versionOption = wd === false ? wd : { - flags: wd, - desc: xd, - opts: typeof yd === 'function' ? { - action: yd - } : yd +const fa = !!e && e.state === 'granted'; +class j { + versionOption(a, c, b) { + this._versionOption = a === false ? a : { + flags: a, + desc: c, + opts: typeof b === 'function' ? { + action: b + } : b }; return this; } - helpOption(zd, Ad, Bd) { - this._helpOption = zd === false ? zd : { - flags: zd, - desc: Ad, - opts: typeof Bd === 'function' ? { - action: Bd - } : Bd + helpOption(a, c, b) { + this._helpOption = a === false ? a : { + flags: a, + desc: c, + opts: typeof b === 'function' ? { + action: b + } : b }; return this; } - command(Cd, Dd, Ed) { - let Fd; - if (typeof Dd === 'string') { - Fd = Dd; - Dd = undefined; + command(g, c, h) { + let f; + if (typeof c === 'string') { + f = c; + c = undefined; } - const Gd = Z.splitArguments(Cd); - const Hd = Gd.args.shift(); - const Id = Gd.args; - if (!Hd) { + const e = d.splitArguments(g); + const a = e.args.shift(); + const i = e.args; + if (!a) { throw this.error(new Error('Missing command name.')); } - if (this.getBaseCommand(Hd, true)) { - if (!Ed) { - throw this.error(new Error(`Duplicate command: ${Hd}`)); + if (this.getBaseCommand(a, true)) { + if (!h) { + throw this.error(new Error(`Duplicate command: ${a}`)); } - this.removeCommand(Hd); + this.removeCommand(a); } - const Jd = (Dd || new vd()).reset(); - Jd._name = Hd; - Jd._parent = this; - if (Fd) { - Jd.isExecutable = true; - Jd.description(Fd); + const b = (c || new j()).reset(); + b._name = a; + b._parent = this; + if (f) { + b.isExecutable = true; + b.description(f); } - if (Gd.typeDefinition) { - Jd.arguments(Gd.typeDefinition); + if (e.typeDefinition) { + b.arguments(e.typeDefinition); } - Id.forEach((a)=>Jd.aliases.push(a) + i.forEach((a)=>b.aliases.push(a) ); - this.commands.set(Hd, Jd); - this.select(Hd); + this.commands.set(a, b); + this.select(a); return this; } - alias(Kd) { + alias(a) { if (this.cmd === this) { - throw this.error(new Error(`Failed to add alias '${Kd}'. No sub command selected.`)); + throw this.error(new Error(`Failed to add alias '${a}'. No sub command selected.`)); } - if (this.cmd.aliases.indexOf(Kd) !== -1) { - throw this.error(new Error(`Duplicate alias: ${Kd}`)); + if (this.cmd.aliases.indexOf(a) !== -1) { + throw this.error(new Error(`Duplicate alias: ${a}`)); } - this.cmd.aliases.push(Kd); + this.cmd.aliases.push(a); return this; } reset() { return this.cmd = this; } - select(Ld) { - const Md = this.getBaseCommand(Ld, true); - if (!Md) { - throw this.error(new Error(`Sub-command not found: ${Ld}`)); + select(a) { + const b = this.getBaseCommand(a, true); + if (!b) { + throw this.error(new Error(`Sub-command not found: ${a}`)); } - this.cmd = Md; + this.cmd = b; return this; } - name(Nd) { - this.cmd._name = Nd; + name(a) { + this.cmd._name = a; return this; } - version(Od) { - this.cmd.ver = Od; + version(a) { + this.cmd.ver = a; return this; } - description(Pd) { - this.cmd.desc = Pd; + description(a) { + this.cmd.desc = a; return this; } hidden() { @@ -1536,53 +1536,53 @@ class vd { this.cmd.isGlobal = true; return this; } - arguments(Qd) { - this.cmd.argsDefinition = Qd; + arguments(a) { + this.cmd.argsDefinition = a; return this; } - action(Rd) { - this.cmd.fn = Rd; + action(a) { + this.cmd.fn = a; return this; } - allowEmpty(Sd = true) { - this.cmd._allowEmpty = Sd; + allowEmpty(a = true) { + this.cmd._allowEmpty = a; return this; } - stopEarly(Td = true) { - this.cmd._stopEarly = Td; + stopEarly(a = true) { + this.cmd._stopEarly = a; return this; } - useRawArgs(Ud = true) { - this.cmd._useRawArgs = Ud; + useRawArgs(a = true) { + this.cmd._useRawArgs = a; return this; } - default(Vd) { - this.cmd.defaultCommand = Vd; + default(a) { + this.cmd.defaultCommand = a; return this; } - type(Wd, Xd, Yd) { - if (this.cmd.types.get(Wd) && !Yd?.override) { - throw this.error(new Error(`Type '${Wd}' already exists.`)); + type(a, c, d) { + if (this.cmd.types.get(a) && !d?.override) { + throw this.error(new Error(`Type '${a}' already exists.`)); } - this.cmd.types.set(Wd, { - ...Yd, - name: Wd, - handler: Xd + this.cmd.types.set(a, { + ...d, + name: a, + handler: c }); - if (Xd instanceof M && typeof Xd.complete !== 'undefined') { - this.complete(Wd, (a, b)=>Xd.complete?.(a, b) || [] - , Yd); + if (c instanceof b && typeof c.complete !== 'undefined') { + this.complete(a, (a, b)=>c.complete?.(a, b) || [] + , d); } return this; } - complete(Zd, $d, _d) { - if (this.cmd.completions.has(Zd) && !_d?.override) { - throw this.error(new Error(`Completion '${Zd}' already exists.`)); + complete(a, c, b) { + if (this.cmd.completions.has(a) && !b?.override) { + throw this.error(new Error(`Completion '${a}' already exists.`)); } - this.cmd.completions.set(Zd, { - name: Zd, - complete: $d, - ..._d + this.cmd.completions.set(a, { + name: a, + complete: c, + ...b }); return this; } @@ -1600,138 +1600,138 @@ class vd { return Array.from(this.completions.values()); } getGlobalCompletions() { - const ae = (a, b = [], c = [])=>{ - if (a) { - if (a.completions.size) { - a.completions.forEach((a)=>{ - if (a.global && !this.completions.has(a.name) && c.indexOf(a.name) === -1) { - c.push(a.name); - b.push(a); + const a = (b, c = [], d = [])=>{ + if (b) { + if (b.completions.size) { + b.completions.forEach((a)=>{ + if (a.global && !this.completions.has(a.name) && d.indexOf(a.name) === -1) { + d.push(a.name); + c.push(a); } }); } - return ae(a._parent, b, c); + return a(b._parent, c, d); } - return b; + return c; }; - return ae(this._parent); + return a(this._parent); } - getCompletion(be) { - return this.getBaseCompletion(be) ?? this.getGlobalCompletion(be); + getCompletion(a) { + return this.getBaseCompletion(a) ?? this.getGlobalCompletion(a); } - getBaseCompletion(ce) { - return this.completions.get(ce); + getBaseCompletion(a) { + return this.completions.get(a); } - getGlobalCompletion(de) { + getGlobalCompletion(a) { if (!this._parent) { return; } - let ee = this._parent.getBaseCompletion(de); - if (!ee?.global) { - return this._parent.getGlobalCompletion(de); + let b = this._parent.getBaseCompletion(a); + if (!b?.global) { + return this._parent.getGlobalCompletion(a); } - return ee; + return b; } - option(fe, ge, he) { - if (typeof he === 'function') { - return this.option(fe, ge, { - value: he + option(g, h, e) { + if (typeof e === 'function') { + return this.option(g, h, { + value: e }); } - const ie = Z.splitArguments(fe); - const je = ie.typeDefinition ? Z.parseArgumentsDefinition(ie.typeDefinition) : []; - const ke = { + const c = d.splitArguments(g); + const i = c.typeDefinition ? d.parseArgumentsDefinition(c.typeDefinition) : []; + const a = { name: '', - description: ge, - args: je, - flags: ie.args.join(', '), - typeDefinition: ie.typeDefinition, - ...he + description: h, + args: i, + flags: c.args.join(', '), + typeDefinition: c.typeDefinition, + ...e }; - if (ke.separator) { - for (const le of je){ - if (le.list) { - le.separator = ke.separator; + if (a.separator) { + for (const j of i){ + if (j.list) { + j.separator = a.separator; } } } - for (const me of ie.args){ - const ne = me.trim(); - const oe = /^--/.test(ne); - const pe = oe ? ne.slice(2) : ne.slice(1); - if (ke.name === pe || ke.aliases && ~ke.aliases.indexOf(pe)) { - throw this.error(new Error(`Duplicate command name: ${pe}`)); + for (const l of c.args){ + const f = l.trim(); + const k = /^--/.test(f); + const b = k ? f.slice(2) : f.slice(1); + if (a.name === b || a.aliases && ~a.aliases.indexOf(b)) { + throw this.error(new Error(`Duplicate command name: ${b}`)); } - if (!ke.name && oe) { - ke.name = pe; - } else if (!ke.aliases) { - ke.aliases = [ - pe + if (!a.name && k) { + a.name = b; + } else if (!a.aliases) { + a.aliases = [ + b ]; } else { - ke.aliases.push(pe); + a.aliases.push(b); } - if (this.cmd.getBaseOption(pe, true)) { - if (he?.override) { - this.removeOption(pe); + if (this.cmd.getBaseOption(b, true)) { + if (e?.override) { + this.removeOption(b); } else { - throw this.error(new Error(`Duplicate option name: ${pe}`)); + throw this.error(new Error(`Duplicate option name: ${b}`)); } } } - if (ke.prepend) { - this.cmd.options.unshift(ke); + if (a.prepend) { + this.cmd.options.unshift(a); } else { - this.cmd.options.push(ke); + this.cmd.options.push(a); } return this; } - example(qe, re) { - if (this.cmd.hasExample(qe)) { + example(a, b) { + if (this.cmd.hasExample(a)) { throw this.error(new Error('Example already exists.')); } this.cmd.examples.push({ - name: qe, - description: re + name: a, + description: b }); return this; } - env(se, te, ue) { - const ve = Z.splitArguments(se); - if (!ve.typeDefinition) { - ve.typeDefinition = ''; + env(b, e, f) { + const c = d.splitArguments(b); + if (!c.typeDefinition) { + c.typeDefinition = ''; } - if (ve.args.some((a)=>this.cmd.getBaseEnvVar(a, true) + if (c.args.some((a)=>this.cmd.getBaseEnvVar(a, true) )) { - throw this.error(new Error(`Environment variable already exists: ${se}`)); + throw this.error(new Error(`Environment variable already exists: ${b}`)); } - const we = Z.parseArgumentsDefinition(ve.typeDefinition); - if (we.length > 1) { - throw this.error(new Error(`An environment variable can only have one value but got: ${se}`)); - } else if (we.length && we[0].optionalValue) { - throw this.error(new Error(`An environment variable can not have an optional value but '${se}' is defined as optional.`)); - } else if (we.length && we[0].variadic) { - throw this.error(new Error(`An environment variable can not have an variadic value but '${se}' is defined as variadic.`)); + const a = d.parseArgumentsDefinition(c.typeDefinition); + if (a.length > 1) { + throw this.error(new Error(`An environment variable can only have one value but got: ${b}`)); + } else if (a.length && a[0].optionalValue) { + throw this.error(new Error(`An environment variable can not have an optional value but '${b}' is defined as optional.`)); + } else if (a.length && a[0].variadic) { + throw this.error(new Error(`An environment variable can not have an variadic value but '${b}' is defined as variadic.`)); } this.cmd.envVars.push({ - names: ve.args, - description: te, - type: we[0].type, - details: we.shift(), - ...ue + names: c.args, + description: e, + type: a[0].type, + details: a.shift(), + ...f }); return this; } - async parse(xe = Deno.args, ye) { + async parse(e = Deno.args, a) { this.reset().registerDefaults(); - this.rawArgs = xe; - const ze = this.rawArgs.length > 0 && this.getCommand(this.rawArgs[0], true); - if (ze) { - ze._globalParent = this; - return await ze.parse(this.rawArgs.slice(1), ye); + this.rawArgs = e; + const b = this.rawArgs.length > 0 && this.getCommand(this.rawArgs[0], true); + if (b) { + b._globalParent = this; + return await b.parse(this.rawArgs.slice(1), a); } if (this.isExecutable) { - if (!ye) { + if (!a) { await this.executeExecutable(this.rawArgs); } return { @@ -1741,7 +1741,7 @@ class vd { literal: this.literalArgs }; } else if (this._useRawArgs) { - if (ye) { + if (a) { return { options: {}, args: this.rawArgs, @@ -1751,19 +1751,19 @@ class vd { } return await this.execute({}, ...this.rawArgs); } else { - const { flags: Ae , unknown: Be , literal: Ce } = this.parseFlags(this.rawArgs); - this.literalArgs = Ce; - const De = this.parseArguments(Be, Ae); + const { flags: c , unknown: f , literal: g } = this.parseFlags(this.rawArgs); + this.literalArgs = g; + const d = this.parseArguments(f, c); this.validateEnvVars(); - if (ye) { + if (a) { return { - options: Ae, - args: De, + options: c, + args: d, cmd: this, literal: this.literalArgs }; } - return await this.execute(Ae, ...De); + return await this.execute(c, ...d); } } registerDefaults() { @@ -1777,7 +1777,7 @@ class vd { standalone: true, prepend: true, action: async function() { - await Deno.stdout.writeSync(b(this.getVersion() + '\n')); + await Deno.stdout.writeSync(l(this.getVersion() + '\n')); Deno.exit(0); } }, this._versionOption?.opts ?? {})); @@ -1795,100 +1795,100 @@ class vd { } return this; } - async execute(Ee, ...Fe) { - const Ge = this.findActionFlag(Ee); - if (Ge && Ge.action) { - await Ge.action.call(this, Ee, ...Fe); + async execute(a, ...b) { + const c = this.findActionFlag(a); + if (c && c.action) { + await c.action.call(this, a, ...b); return { - options: Ee, - args: Fe, + options: a, + args: b, cmd: this, literal: this.literalArgs }; } if (this.fn) { try { - await this.fn(Ee, ...Fe); - } catch (He) { - throw this.error(He); + await this.fn(a, ...b); + } catch (e) { + throw this.error(e); } } else if (this.defaultCommand) { - const Ie = this.getCommand(this.defaultCommand, true); - if (!Ie) { + const d = this.getCommand(this.defaultCommand, true); + if (!d) { throw this.error(new Error(`Default command '${this.defaultCommand}' not found.`)); } - Ie._globalParent = this; + d._globalParent = this; try { - await Ie.execute(Ee, ...Fe); - } catch (Je) { - throw this.error(Je); + await d.execute(a, ...b); + } catch (f) { + throw this.error(f); } } return { - options: Ee, - args: Fe, + options: a, + args: b, cmd: this, literal: this.literalArgs }; } - async executeExecutable(Ke) { - const [Le, ...Me] = this.getPath().split(' '); - Me.unshift(Le.replace(/\.ts$/, '')); - const Ne = Me.join('-'); + async executeExecutable(b) { + const [f, ...c] = this.getPath().split(' '); + c.unshift(f.replace(/\.ts$/, '')); + const a = c.join('-'); try { await Deno.run({ cmd: [ - Ne, - ...Ke + a, + ...b ] }); return; - } catch (Oe) { - if (!Oe.message.match(/No such file or directory/)) { - throw Oe; + } catch (d) { + if (!d.message.match(/No such file or directory/)) { + throw d; } } try { await Deno.run({ cmd: [ - Ne + '.ts', - ...Ke + a + '.ts', + ...b ] }); return; - } catch (Pe) { - if (!Pe.message.match(/No such file or directory/)) { - throw Pe; + } catch (e) { + if (!e.message.match(/No such file or directory/)) { + throw e; } } - throw this.error(new Error(`Sub-command executable not found: ${Ne}${h('(.ts)')}`)); + throw this.error(new Error(`Sub-command executable not found: ${a}${q('(.ts)')}`)); } - parseFlags(Qe) { + parseFlags(a) { try { - return F(Qe, { + return K(a, { stopEarly: this._stopEarly, allowEmpty: this._allowEmpty, flags: this.getOptions(true), parse: (a, b, c, d)=>this.parseType(a, b, c, d) }); - } catch (Re) { - throw this.error(Re); + } catch (b) { + throw this.error(b); } } - parseType(Se, Te, Ue, Ve) { - const We = this.getType(Se); - if (!We) { - throw this.error(new Error(`No type registered with name: ${Se}`)); + parseType(c, d, e, f) { + const a = this.getType(c); + if (!a) { + throw this.error(new Error(`No type registered with name: ${c}`)); } - return We.handler instanceof M ? We.handler.parse(Te, Ue, Ve) : We.handler(Te, Ue, Ve); + return a.handler instanceof b ? a.handler.parse(d, e, f) : a.handler(d, e, f); } validateEnvVars() { - const Xe = this.getEnvVars(true); - if (!Xe.length) { + const a = this.getEnvVars(true); + if (!a.length) { return; } - if (ud) { - Xe.forEach((a)=>{ + if (fa) { + a.forEach((a)=>{ const b = a.names.find((a)=>!!Deno.env.get(a) ); if (b) { @@ -1904,58 +1904,58 @@ class vd { }); } } - parseArguments(Ye, Ze) { - const $e = []; - Ye = Ye.slice(0); + parseArguments(a, f) { + const c = []; + a = a.slice(0); if (!this.hasArguments()) { - if (Ye.length) { + if (a.length) { if (this.hasCommands(true)) { - throw this.error(new Error(`Unknown command: ${Ye.join(' ')}`)); + throw this.error(new Error(`Unknown command: ${a.join(' ')}`)); } else { throw this.error(new Error(`No arguments allowed for command: ${this._name}`)); } } } else { - if (!Ye.length) { - const _e = this.getArguments().filter((a)=>!a.optionalValue + if (!a.length) { + const e = this.getArguments().filter((a)=>!a.optionalValue ).map((a)=>a.name ); - if (_e.length) { - const af = Object.keys(Ze); - const bf = !!af.find((a)=>this.getOption(a, true)?.standalone + if (e.length) { + const g = Object.keys(f); + const h = !!g.find((a)=>this.getOption(a, true)?.standalone ); - if (!bf) { - throw this.error(new Error('Missing argument(s): ' + _e.join(', '))); + if (!h) { + throw this.error(new Error('Missing argument(s): ' + e.join(', '))); } } - return $e; + return c; } - for (const cf of this.getArguments()){ - if (!cf.optionalValue && !Ye.length) { - throw this.error(new Error(`Missing argument: ${cf.name}`)); + for (const d of this.getArguments()){ + if (!d.optionalValue && !a.length) { + throw this.error(new Error(`Missing argument: ${d.name}`)); } - let df; - if (cf.variadic) { - df = Ye.splice(0, Ye.length); + let b; + if (d.variadic) { + b = a.splice(0, a.length); } else { - df = Ye.shift(); + b = a.shift(); } - if (df) { - $e.push(df); + if (b) { + c.push(b); } } - if (Ye.length) { - throw this.error(new Error(`To many arguments: ${Ye.join(' ')}`)); + if (a.length) { + throw this.error(new Error(`To many arguments: ${a.join(' ')}`)); } } - return $e; + return c; } - findActionFlag(ef) { - const ff = Object.keys(ef); - for (const gf of ff){ - const hf = this.getOption(gf, true); - if (hf?.action) { - return hf; + findActionFlag(b) { + const c = Object.keys(b); + for (const d of c){ + const a = this.getOption(d, true); + if (a?.action) { + return a; } } return; @@ -1981,13 +1981,13 @@ class vd { getArgsDefinition() { return this.argsDefinition; } - getArgument(jf) { - return this.getArguments().find((a)=>a.name === jf + getArgument(a) { + return this.getArguments().find((b)=>b.name === a ); } getArguments() { if (!this.args.length && this.argsDefinition) { - this.args = Z.parseArgumentsDefinition(this.argsDefinition); + this.args = d.parseArgumentsDefinition(this.argsDefinition); } return this.args; } @@ -2003,120 +2003,120 @@ class vd { getShortDescription() { return this.getDescription().trim().split('\n').shift(); } - hasOptions(kf) { - return this.getOptions(kf).length > 0; + hasOptions(a) { + return this.getOptions(a).length > 0; } - getOptions(lf) { - return this.getGlobalOptions(lf).concat(this.getBaseOptions(lf)); + getOptions(a) { + return this.getGlobalOptions(a).concat(this.getBaseOptions(a)); } - getBaseOptions(mf) { + getBaseOptions(a) { if (!this.options.length) { return []; } - return mf ? this.options.slice(0) : this.options.filter((a)=>!a.hidden + return a ? this.options.slice(0) : this.options.filter((a)=>!a.hidden ); } - getGlobalOptions(nf) { - const of = (a, b = [], c = [])=>{ - if (a) { - if (a.options.length) { - a.options.forEach((a)=>{ + getGlobalOptions(b) { + const a = (c, d = [], e = [])=>{ + if (c) { + if (c.options.length) { + c.options.forEach((a)=>{ if (a.global && !this.options.find((b)=>b.name === a.name - ) && c.indexOf(a.name) === -1 && (nf || !a.hidden)) { - c.push(a.name); - b.push(a); + ) && e.indexOf(a.name) === -1 && (b || !a.hidden)) { + e.push(a.name); + d.push(a); } }); } - return of(a._parent, b, c); + return a(c._parent, d, e); } - return b; + return d; }; - return of(this._parent); + return a(this._parent); } - hasOption(pf, qf) { - return !!this.getOption(pf, qf); + hasOption(a, b) { + return !!this.getOption(a, b); } - getOption(rf, sf) { - return this.getBaseOption(rf, sf) ?? this.getGlobalOption(rf, sf); + getOption(a, b) { + return this.getBaseOption(a, b) ?? this.getGlobalOption(a, b); } - getBaseOption(tf, uf) { - const vf = this.options.find((a)=>a.name === tf + getBaseOption(c, b) { + const a = this.options.find((a)=>a.name === c ); - return vf && (uf || !vf.hidden) ? vf : undefined; + return a && (b || !a.hidden) ? a : undefined; } - getGlobalOption(wf, xf) { + getGlobalOption(b, c) { if (!this._parent) { return; } - let yf = this._parent.getBaseOption(wf, xf); - if (!yf || !yf.global) { - return this._parent.getGlobalOption(wf, xf); + let a = this._parent.getBaseOption(b, c); + if (!a || !a.global) { + return this._parent.getGlobalOption(b, c); } - return yf; + return a; } - removeOption(zf) { - const Af = this.options.findIndex((a)=>a.name === zf + removeOption(b) { + const a = this.options.findIndex((a)=>a.name === b ); - if (Af === -1) { + if (a === -1) { return; } - return this.options.splice(Af, 1)[0]; + return this.options.splice(a, 1)[0]; } - hasCommands(Bf) { - return this.getCommands(Bf).length > 0; + hasCommands(a) { + return this.getCommands(a).length > 0; } - getCommands(Cf) { - return this.getGlobalCommands(Cf).concat(this.getBaseCommands(Cf)); + getCommands(a) { + return this.getGlobalCommands(a).concat(this.getBaseCommands(a)); } - getBaseCommands(Df) { - const Ef = Array.from(this.commands.values()); - return Df ? Ef : Ef.filter((a)=>!a.isHidden + getBaseCommands(b) { + const a = Array.from(this.commands.values()); + return b ? a : a.filter((a)=>!a.isHidden ); } - getGlobalCommands(Ff) { - const Gf = (a, b = [], c = [])=>{ - if (a) { - if (a.commands.size) { - a.commands.forEach((a)=>{ - if (a.isGlobal && this !== a && !this.commands.has(a._name) && c.indexOf(a._name) === -1 && (Ff || !a.isHidden)) { - c.push(a._name); - b.push(a); + getGlobalCommands(b) { + const a = (c, d = [], e = [])=>{ + if (c) { + if (c.commands.size) { + c.commands.forEach((a)=>{ + if (a.isGlobal && this !== a && !this.commands.has(a._name) && e.indexOf(a._name) === -1 && (b || !a.isHidden)) { + e.push(a._name); + d.push(a); } }); } - return Gf(a._parent, b, c); + return a(c._parent, d, e); } - return b; + return d; }; - return Gf(this._parent); + return a(this._parent); } - hasCommand(Hf, If) { - return !!this.getCommand(Hf, If); + hasCommand(a, b) { + return !!this.getCommand(a, b); } - getCommand(Jf, Kf) { - return this.getBaseCommand(Jf, Kf) ?? this.getGlobalCommand(Jf, Kf); + getCommand(a, b) { + return this.getBaseCommand(a, b) ?? this.getGlobalCommand(a, b); } - getBaseCommand(Lf, Mf) { - let Nf = this.commands.get(Lf); - return Nf && (Mf || !Nf.isHidden) ? Nf : undefined; + getBaseCommand(b, c) { + let a = this.commands.get(b); + return a && (c || !a.isHidden) ? a : undefined; } - getGlobalCommand(Of, Pf) { + getGlobalCommand(a, b) { if (!this._parent) { return; } - let Qf = this._parent.getBaseCommand(Of, Pf); - if (!Qf?.isGlobal) { - return this._parent.getGlobalCommand(Of, Pf); + let c = this._parent.getBaseCommand(a, b); + if (!c?.isGlobal) { + return this._parent.getGlobalCommand(a, b); } - return Qf; + return c; } - removeCommand(Rf) { - const Sf = this.getBaseCommand(Rf, true); - if (Sf) { - this.commands.delete(Rf); + removeCommand(a) { + const b = this.getBaseCommand(a, true); + if (b) { + this.commands.delete(a); } - return Sf; + return b; } getTypes() { return this.getGlobalTypes().concat(this.getBaseTypes()); @@ -2125,89 +2125,89 @@ class vd { return Array.from(this.types.values()); } getGlobalTypes() { - const Tf = (a, b = [], c = [])=>{ - if (a) { - if (a.types.size) { - a.types.forEach((a)=>{ - if (a.global && !this.types.has(a.name) && c.indexOf(a.name) === -1) { - c.push(a.name); - b.push(a); + const a = (b, c = [], d = [])=>{ + if (b) { + if (b.types.size) { + b.types.forEach((a)=>{ + if (a.global && !this.types.has(a.name) && d.indexOf(a.name) === -1) { + d.push(a.name); + c.push(a); } }); } - return Tf(a._parent, b, c); + return a(b._parent, c, d); } - return b; + return c; }; - return Tf(this._parent); + return a(this._parent); } - getType(Uf) { - return this.getBaseType(Uf) ?? this.getGlobalType(Uf); + getType(a) { + return this.getBaseType(a) ?? this.getGlobalType(a); } - getBaseType(Vf) { - return this.types.get(Vf); + getBaseType(a) { + return this.types.get(a); } - getGlobalType(Wf) { + getGlobalType(a) { if (!this._parent) { return; } - let Xf = this._parent.getBaseType(Wf); - if (!Xf?.global) { - return this._parent.getGlobalType(Wf); + let b = this._parent.getBaseType(a); + if (!b?.global) { + return this._parent.getGlobalType(a); } - return Xf; + return b; } - hasEnvVars(Yf) { - return this.getEnvVars(Yf).length > 0; + hasEnvVars(a) { + return this.getEnvVars(a).length > 0; } - getEnvVars(Zf) { - return this.getGlobalEnvVars(Zf).concat(this.getBaseEnvVars(Zf)); + getEnvVars(a) { + return this.getGlobalEnvVars(a).concat(this.getBaseEnvVars(a)); } - getBaseEnvVars($f) { + getBaseEnvVars(a) { if (!this.envVars.length) { return []; } - return $f ? this.envVars.slice(0) : this.envVars.filter((a)=>!a.hidden + return a ? this.envVars.slice(0) : this.envVars.filter((a)=>!a.hidden ); } - getGlobalEnvVars(_f) { - const ag = (a, b = [], c = [])=>{ - if (a) { - if (a.envVars.length) { - a.envVars.forEach((a)=>{ + getGlobalEnvVars(b) { + const a = (c, d = [], e = [])=>{ + if (c) { + if (c.envVars.length) { + c.envVars.forEach((a)=>{ if (a.global && !this.envVars.find((b)=>b.names[0] === a.names[0] - ) && c.indexOf(a.names[0]) === -1 && (_f || !a.hidden)) { - c.push(a.names[0]); - b.push(a); + ) && e.indexOf(a.names[0]) === -1 && (b || !a.hidden)) { + e.push(a.names[0]); + d.push(a); } }); } - return ag(a._parent, b, c); + return a(c._parent, d, e); } - return b; + return d; }; - return ag(this._parent); + return a(this._parent); } - hasEnvVar(bg, cg) { - return !!this.getEnvVar(bg, cg); + hasEnvVar(a, b) { + return !!this.getEnvVar(a, b); } - getEnvVar(dg, eg) { - return this.getBaseEnvVar(dg, eg) ?? this.getGlobalEnvVar(dg, eg); + getEnvVar(a, b) { + return this.getBaseEnvVar(a, b) ?? this.getGlobalEnvVar(a, b); } - getBaseEnvVar(fg, gg) { - const hg = this.envVars.find((a)=>a.names.indexOf(fg) !== -1 + getBaseEnvVar(c, b) { + const a = this.envVars.find((a)=>a.names.indexOf(c) !== -1 ); - return hg && (gg || !hg.hidden) ? hg : undefined; + return a && (b || !a.hidden) ? a : undefined; } - getGlobalEnvVar(ig, jg) { + getGlobalEnvVar(a, b) { if (!this._parent) { return; } - let kg = this._parent.getBaseEnvVar(ig, jg); - if (!kg?.global) { - return this._parent.getGlobalEnvVar(ig, jg); + let c = this._parent.getBaseEnvVar(a, b); + if (!c?.global) { + return this._parent.getGlobalEnvVar(a, b); } - return kg; + return c; } hasExamples() { return this.examples.length > 0; @@ -2215,11 +2215,11 @@ class vd { getExamples() { return this.examples; } - hasExample(lg) { - return !!this.getExample(lg); + hasExample(a) { + return !!this.getExample(a); } - getExample(mg) { - return this.examples.find((a)=>a.name === mg + getExample(a) { + return this.examples.find((b)=>b.name === a ); } getRawArgs() { @@ -2228,34 +2228,34 @@ class vd { getLiteralArgs() { return this.literalArgs; } - write(...ng) { - qd.writeSync(b(I(2) + L(...ng))); + write(...a) { + da.writeSync(l(N(2) + Q(...a))); } - writeError(...og) { - rd.writeSync(b(I(2) + i(L(`[ERROR:${this._name}]`, ...og)))); + writeError(...a) { + ea.writeSync(l(N(2) + r(Q(`[ERROR:${this._name}]`, ...a)))); } - log(...pg) { - this.write(...pg, '\n'); + log(...a) { + this.write(...a, '\n'); } - logError(...qg) { - this.writeError(...qg, '\n'); + logError(...a) { + this.writeError(...a, '\n'); } - error(rg, sg = true) { + error(a, b = true) { if (this.shouldThrowErrors()) { - return rg; + return a; } - const tg = ud ? !!Deno.env.get('CLIFFY_DEBUG') : false; - sg && this.help(); - this.logError(tg ? rg : rg.message); + const c = fa ? !!Deno.env.get('CLIFFY_DEBUG') : false; + b && this.help(); + this.logError(c ? a : a.message); this.log(); Deno.exit(1); } help() { - Deno.stdout.writeSync(b(this.getHelp())); + Deno.stdout.writeSync(l(this.getHelp())); } getHelp() { this.registerDefaults(); - return cd.generate(this); + return ba.generate(this); } constructor(){ this.types = new Map([ @@ -2263,21 +2263,21 @@ class vd { 'string', { name: 'string', - handler: new V() + handler: new T() } ], [ 'number', { name: 'number', - handler: new R() + handler: new S() } ], [ 'boolean', { name: 'boolean', - handler: new N() + handler: new R() } ] ]); @@ -2304,20 +2304,20 @@ class vd { this.hasDefaults = false; } } -function ug(a, b) { - return s(a, b, '_'); +function ga(a, b) { + return B(a, b, '_'); } -class vg { - static generate(wg) { - return new vg(wg).generate(); +class ha { + static generate(a) { + return new ha(a).generate(); } - constructor(xg){ - this.cmd = xg; + constructor(a){ + this.cmd = a; this.actions = new Map(); } generate() { return ` -# compdef _${ug(this.cmd.getPath())} ${this.cmd.getPath()} +# compdef _${ga(this.cmd.getPath())} ${this.cmd.getPath()} # # zsh completion for ${this.cmd.getPath()} # @@ -2326,8 +2326,8 @@ class vg { autoload -U is-at-least -(( $+functions[__${ug(this.cmd.getName())}_complete] )) || -function __${ug(this.cmd.getName())}_complete { +(( $+functions[__${ga(this.cmd.getName())}_complete] )) || +function __${ga(this.cmd.getName())}_complete { local name="$1"; shift local action="$1"; shift integer ret=1 @@ -2348,9 +2348,9 @@ function __${ug(this.cmd.getName())}_complete { ${this.generateCompletions(this.cmd).trim()} -# _${ug(this.cmd.getPath())} "\${@}" +# _${ga(this.cmd.getPath())} "\${@}" -compdef _${ug(this.cmd.getPath())} ${this.cmd.getPath()} +compdef _${ga(this.cmd.getPath())} ${this.cmd.getPath()} # # Local Variables: @@ -2362,144 +2362,144 @@ compdef _${ug(this.cmd.getPath())} ${this.cmd.getPath()} # vim: ft=zsh sw=4 ts=4 et `.trim(); } - generateCompletions(yg, zg = '') { - if (!yg.hasCommands(false) && !yg.hasOptions(false) && !yg.hasArguments()) { + generateCompletions(a, b = '') { + if (!a.hasCommands(false) && !a.hasOptions(false) && !a.hasArguments()) { return ''; } - zg = (zg ? zg + ' ' : '') + yg.getName(); - return `(( $+functions[_${ug(zg)}] )) || -function _${ug(zg)}() {` + (!yg.getParent() ? `\n\n local context state state_descr line\n typeset -A opt_args` : '') + this.generateCommandCompletions(yg, zg) + this.generateSubCommandCompletions(yg, zg) + this.generateArgumentCompletions(yg, zg) + this.generateActions(yg) + `\n}\n\n` + yg.getCommands(false).filter((a)=>a !== yg - ).map((a)=>this.generateCompletions(a, zg) + b = (b ? b + ' ' : '') + a.getName(); + return `(( $+functions[_${ga(b)}] )) || +function _${ga(b)}() {` + (!a.getParent() ? `\n\n local context state state_descr line\n typeset -A opt_args` : '') + this.generateCommandCompletions(a, b) + this.generateSubCommandCompletions(a, b) + this.generateArgumentCompletions(a, b) + this.generateActions(a) + `\n}\n\n` + a.getCommands(false).filter((b)=>b !== a + ).map((a)=>this.generateCompletions(a, b) ).join(''); } - generateCommandCompletions(Ag, Bg) { - const Cg = Ag.getCommands(false); - let Dg = Cg.map((a)=>`'${a.getName()}:${a.getShortDescription()}'` + generateCommandCompletions(c, d) { + const e = c.getCommands(false); + let a = e.map((a)=>`'${a.getName()}:${a.getShortDescription()}'` ).join('\n '); - if (Dg) { - Dg = ` + if (a) { + a = ` local -a commands commands=( - ${Dg} + ${a} ) _describe 'command' commands`; } - if (Ag.hasArguments()) { - const Eg = Bg.split(' ').slice(1).join(' '); - const Fg = Ag.getArguments()[0]; - const Gg = this.addAction(Fg, Eg); - if (Gg) { - Dg += `\n __${ug(this.cmd.getName())}_complete ${Gg.arg.name} ${Gg.arg.action} ${Gg.cmd}`; + if (c.hasArguments()) { + const f = d.split(' ').slice(1).join(' '); + const g = c.getArguments()[0]; + const b = this.addAction(g, f); + if (b) { + a += `\n __${ga(this.cmd.getName())}_complete ${b.arg.name} ${b.arg.action} ${b.cmd}`; } } - if (Dg) { - Dg = `\n\n function _commands() {${Dg}\n }`; + if (a) { + a = `\n\n function _commands() {${a}\n }`; } - return Dg; + return a; } - generateSubCommandCompletions(Hg, Ig) { - if (Hg.hasCommands(false)) { - const Jg = Hg.getCommands(false).map((a)=>`${a.getName()}) _${ug(Ig + ' ' + a.getName())} ;;` + generateSubCommandCompletions(a, c) { + if (a.hasCommands(false)) { + const b = a.getCommands(false).map((a)=>`${a.getName()}) _${ga(c + ' ' + a.getName())} ;;` ).join('\n '); return `\n function _command_args() { - case "$words[1]" in\n ${Jg}\n esac + case "$words[1]" in\n ${b}\n esac }`; } return ''; } - generateArgumentCompletions(Kg, Lg) { + generateArgumentCompletions(a, c) { this.actions.clear(); - const Mg = this.generateOptions(Kg, Lg); - let Ng = 0; - let Og = '\n\n _arguments -w -s -S -C'; - if (Kg.hasOptions()) { - Og += ` \\\n ${Mg.join(' \\\n ')}`; + const g = this.generateOptions(a, c); + let d = 0; + let b = '\n\n _arguments -w -s -S -C'; + if (a.hasOptions()) { + b += ` \\\n ${g.join(' \\\n ')}`; } - if (Kg.hasCommands(false) || Kg.hasArguments()) { - Og += ` \\\n '${++Ng}: :_commands'`; + if (a.hasCommands(false) || a.hasArguments()) { + b += ` \\\n '${++d}: :_commands'`; } - if (Kg.hasArguments() || Kg.hasCommands(false)) { - const Pg = []; - for (const Qg of Kg.getArguments().slice(1)){ - const Rg = Lg.split(' ').slice(1).join(' '); - const Sg = this.addAction(Qg, Rg); - Pg.push(`${++Ng}${Qg.optionalValue ? '::' : ':'}${Sg.name}`); + if (a.hasArguments() || a.hasCommands(false)) { + const e = []; + for (const f of a.getArguments().slice(1)){ + const h = c.split(' ').slice(1).join(' '); + const i = this.addAction(f, h); + e.push(`${++d}${f.optionalValue ? '::' : ':'}${i.name}`); } - Og += Pg.map((a)=>`\\\n '${a}'` + b += e.map((a)=>`\\\n '${a}'` ).join(''); - if (Kg.hasCommands(false)) { - Og += ` \\\n '*:: :->command_args'`; + if (a.hasCommands(false)) { + b += ` \\\n '*:: :->command_args'`; } } - return Og; + return b; } - generateOptions(Tg, Ug) { - const Vg = []; - const Wg = Ug.split(' '); - Wg.shift(); - const Xg = Wg.join(' '); - const Yg = Tg.getOptions(false).map((a)=>a.standalone ? a.flags.split(/[, ] */g) : false + generateOptions(a, d) { + const b = []; + const c = d.split(' '); + c.shift(); + const e = c.join(' '); + const f = a.getOptions(false).map((a)=>a.standalone ? a.flags.split(/[, ] */g) : false ).flat().filter((a)=>typeof a === 'string' ); - for (const Zg of Tg.getOptions(false)){ - Vg.push(this.generateOption(Zg, Xg, Yg)); + for (const g of a.getOptions(false)){ + b.push(this.generateOption(g, e, f)); } - return Vg; + return b; } - generateOption($g, _g, ah) { - let bh = $g.conflicts?.length ? [ - ...ah, - ...$g.conflicts - ] : ah; - bh = $g.collect ? bh : [ - ...bh, - ...$g.flags.split(/[, ] */g) + generateOption(a, j, e) { + let c = a.conflicts?.length ? [ + ...e, + ...a.conflicts + ] : e; + c = a.collect ? c : [ + ...c, + ...a.flags.split(/[, ] */g) ]; - let ch = ''; - for (const dh of $g.args){ - const eh = this.addAction(dh, _g); - if (dh.variadic) { - ch += `${dh.optionalValue ? '::' : ':'}${dh.name}:->${eh.name}`; + let d = ''; + for (const b of a.args){ + const f = this.addAction(b, j); + if (b.variadic) { + d += `${b.optionalValue ? '::' : ':'}${b.name}:->${f.name}`; } else { - ch += `${dh.optionalValue ? '::' : ':'}${dh.name}:->${eh.name}`; + d += `${b.optionalValue ? '::' : ':'}${b.name}:->${f.name}`; } } - const fh = $g.description.trim().split('\n').shift(); - const gh = $g.collect ? '*' : ''; - const hh = $g.flags.replace(/ +/g, ''); - if ($g.standalone) { - return `'(- *)'{${gh}${hh}}'[${fh}]${ch}'`; + const g = a.description.trim().split('\n').shift(); + const h = a.collect ? '*' : ''; + const i = a.flags.replace(/ +/g, ''); + if (a.standalone) { + return `'(- *)'{${h}${i}}'[${g}]${d}'`; } else { - const ih = bh.length ? `'(${bh.join(' ')})'` : ''; - return `${ih}{${gh}${hh}}'[${fh}]${ch}'`; + const k = c.length ? `'(${c.join(' ')})'` : ''; + return `${k}{${h}${i}}'[${g}]${d}'`; } } - addAction(jh, kh) { - const lh = `${jh.name}-${jh.action}`; - if (!this.actions.has(lh)) { - this.actions.set(lh, { - arg: jh, - label: `${jh.name}: ${jh.action}`, - name: lh, - cmd: kh + addAction(a, c) { + const b = `${a.name}-${a.action}`; + if (!this.actions.has(b)) { + this.actions.set(b, { + arg: a, + label: `${a.name}: ${a.action}`, + name: b, + cmd: c }); } - return this.actions.get(lh); + return this.actions.get(b); } - generateActions(mh) { - let nh = []; + generateActions(b) { + let a = []; if (this.actions.size) { - nh = Array.from(this.actions).map(([a, b])=>`${a}) __${ug(this.cmd.getName())}_complete ${b.arg.name} ${b.arg.action} ${b.cmd} ;;` + a = Array.from(this.actions).map(([b, a])=>`${b}) __${ga(this.cmd.getName())}_complete ${a.arg.name} ${a.arg.action} ${a.cmd} ;;` ); } - if (mh.hasCommands(false)) { - nh.unshift(`command_args) _command_args ;;`); + if (b.hasCommands(false)) { + a.unshift(`command_args) _command_args ;;`); } - if (nh.length) { - return `\n\n case "$state" in\n ${nh.join('\n ')}\n esac`; + if (a.length) { + return `\n\n case "$state" in\n ${a.join('\n ')}\n esac`; } return ''; } } -new vd(); +new j(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/export/dynamic_import/output.js b/crates/swc_ecma_minifier/tests/terser/compress/export/dynamic_import/output.js index ebc0d0aee63..1a81d5b825d 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/export/dynamic_import/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/export/dynamic_import/output.js @@ -1,7 +1,7 @@ -import a from "./traditional.js"; -function b(a) { +import b from "./traditional.js"; +function c(a) { return import(a); } import("module_for_side_effects.js"); -let c = import("some/module.js"); -c.foo(); +let a = import("some/module.js"); +a.foo(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/rename/function_catch_catch/output.js b/crates/swc_ecma_minifier/tests/terser/compress/rename/function_catch_catch/output.js index aae4b6f56ae..74251a49864 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/rename/function_catch_catch/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/rename/function_catch_catch/output.js @@ -2,12 +2,12 @@ var o = 0; function f() { try { throw 1; - } catch (a) { + } catch (b) { try { throw 2; - } catch (b) { - var b = 3; - console.log(b); + } catch (a) { + var a = 3; + console.log(a); } } console.log(o); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/try-catch/broken_safari_catch_scope/output.js b/crates/swc_ecma_minifier/tests/terser/compress/try-catch/broken_safari_catch_scope/output.js index 37f38e818d8..68a9bda1f29 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/try-catch/broken_safari_catch_scope/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/try-catch/broken_safari_catch_scope/output.js @@ -1,13 +1,13 @@ "AAAAAAAA"; "BBBBBBB"; new class { - f(a) { + f(b) { try { throw { m: "PASS" }; - } catch ({ m: b }) { - console.log(b); + } catch ({ m: a }) { + console.log(a); } } }().f(); diff --git a/crates/swc_ecma_minifier/tests/terser/compress/try-catch/broken_safari_catch_scope_caveat/output.js b/crates/swc_ecma_minifier/tests/terser/compress/try-catch/broken_safari_catch_scope_caveat/output.js index 37f38e818d8..68a9bda1f29 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/try-catch/broken_safari_catch_scope_caveat/output.js +++ b/crates/swc_ecma_minifier/tests/terser/compress/try-catch/broken_safari_catch_scope_caveat/output.js @@ -1,13 +1,13 @@ "AAAAAAAA"; "BBBBBBB"; new class { - f(a) { + f(b) { try { throw { m: "PASS" }; - } catch ({ m: b }) { - console.log(b); + } catch ({ m: a }) { + console.log(a); } } }().f();